* bfd.c (bfd_record_phdr): New function.
authorIan Lance Taylor <ian@airs.com>
Fri, 1 Dec 1995 21:45:33 +0000 (21:45 +0000)
committerIan Lance Taylor <ian@airs.com>
Fri, 1 Dec 1995 21:45:33 +0000 (21:45 +0000)
* bfd-in.h (bfd_record_phdr): Declare.
* bfd_in2.h: Rebuild.

bfd/ChangeLog
bfd/bfd-in.h
bfd/bfd-in2.h
bfd/bfd.c

index 8d2bcf9..9c190c8 100644 (file)
@@ -1,5 +1,15 @@
 Fri Dec  1 14:46:51 1995  Ian Lance Taylor  <ian@cygnus.com>
 
+       * elf.c (assign_file_positions_for_segments): Sort the sections in
+       each segment.
+       (get_program_header_size): Return the right size if segment_map is
+       not NULL.
+       (copy_private_bfd_data): Don't bother to sort the sections.
+
+       * bfd.c (bfd_record_phdr): New function.
+       * bfd-in.h (bfd_record_phdr): Declare.
+       * bfd_in2.h: Rebuild.
+
        * elf32-sparc.c (elf32_sparc_relocate_section): Remove bogus
        BFD_ASSERT.
 
index de096c5..e0f8d04 100644 (file)
@@ -482,6 +482,10 @@ extern int bfd_stat PARAMS ((bfd *abfd, struct stat *));
 
 #define bfd_set_cacheable(abfd,bool) (((abfd)->cacheable = (boolean)(bool)), true)
 
+extern boolean bfd_record_phdr
+  PARAMS ((bfd *, unsigned long, boolean, flagword, boolean, bfd_vma,
+          boolean, boolean, unsigned int, struct sec **));
+
 /* Byte swapping routines.  */
 
 bfd_vma                bfd_getb64         PARAMS ((const unsigned char *));
@@ -641,6 +645,6 @@ extern boolean bfd_xcoff_record_link_assignment
 extern boolean bfd_xcoff_size_dynamic_sections
   PARAMS ((bfd *, struct bfd_link_info *, const char *, const char *,
           unsigned long, unsigned long, unsigned long, boolean,
-          int, boolean));
+          int, boolean, struct sec **));
 
 /* And more from the source.  */
index 3621b55..925ab3e 100644 (file)
@@ -482,6 +482,10 @@ extern int bfd_stat PARAMS ((bfd *abfd, struct stat *));
 
 #define bfd_set_cacheable(abfd,bool) (((abfd)->cacheable = (boolean)(bool)), true)
 
+extern boolean bfd_record_phdr
+  PARAMS ((bfd *, unsigned long, boolean, flagword, boolean, bfd_vma,
+          boolean, boolean, unsigned int, struct sec **));
+
 /* Byte swapping routines.  */
 
 bfd_vma                bfd_getb64         PARAMS ((const unsigned char *));
@@ -641,7 +645,7 @@ extern boolean bfd_xcoff_record_link_assignment
 extern boolean bfd_xcoff_size_dynamic_sections
   PARAMS ((bfd *, struct bfd_link_info *, const char *, const char *,
           unsigned long, unsigned long, unsigned long, boolean,
-          int, boolean));
+          int, boolean, struct sec **));
 
 /* And more from the source.  */
 void 
@@ -2249,7 +2253,7 @@ CAT(NAME,_bfd_print_private_bfd_data)\
   boolean       (*_bfd_set_private_flags) PARAMS ((bfd *, flagword));
 
    /* Called to print private BFD data */
-  boolean       (*_bfd_print_private_bfd_data) PARAMS ((bfd *, void  *));
+  boolean       (*_bfd_print_private_bfd_data) PARAMS ((bfd *, PTR));
 
    /* Core file entry points.  */
 #define BFD_JUMP_TABLE_CORE(NAME)\
index d98ad62..3fa0e08 100644 (file)
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -153,6 +153,7 @@ CODE_FRAGMENT
 .      struct _oasys_ar_data *oasys_ar_data;
 .      struct coff_tdata *coff_obj_data;
 .      struct pe_tdata *pe_obj_data;
+.      struct xcoff_tdata *xcoff_obj_data;
 .      struct ecoff_tdata *ecoff_obj_data;
 .      struct ieee_data_struct *ieee_data;
 .      struct ieee_ar_data_struct *ieee_ar_data;
@@ -199,7 +200,7 @@ CODE_FRAGMENT
 #include "libcoff.h"
 #include "libecoff.h"
 #undef obj_symbols
-#include "libelf.h"
+#include "elf-bfd.h"
 
 #include <ctype.h>
 \f
@@ -647,7 +648,7 @@ bfd_assert (file, line)
      const char *file;
      int line;
 {
-  (*_bfd_error_handler) ("bfd assertion fail %s:%d\n", file, line);
+  (*_bfd_error_handler) ("bfd assertion fail %s:%d", file, line);
 }
 
 
@@ -1043,5 +1044,49 @@ bfd_get_relocated_section_contents (abfd, link_info, link_order, data,
   return (*fn) (abfd, link_info, link_order, data, relocateable, symbols);
 }
 
+/* Record information about an ELF program header.  */
 
+boolean
+bfd_record_phdr (abfd, type, flags_valid, flags, at_valid, at,
+                includes_filehdr, includes_phdrs, count, secs)
+     bfd *abfd;
+     unsigned long type;
+     boolean flags_valid;
+     flagword flags;
+     boolean at_valid;
+     bfd_vma at;
+     boolean includes_filehdr;
+     boolean includes_phdrs;
+     unsigned int count;
+     asection **secs;
+{
+  struct elf_segment_map *m, **pm;
+
+  if (bfd_get_flavour (abfd) != bfd_target_elf_flavour)
+    return true;
 
+  m = ((struct elf_segment_map *)
+       bfd_alloc (abfd,
+                 (sizeof (struct elf_segment_map)
+                  + (count - 1) * sizeof (asection *))));
+  if (m == NULL)
+    return false;
+
+  m->next = NULL;
+  m->p_type = type;
+  m->p_flags = flags;
+  m->p_paddr = at;
+  m->p_flags_valid = flags_valid;
+  m->p_paddr_valid = at_valid;
+  m->includes_filehdr = includes_filehdr;
+  m->includes_phdrs = includes_phdrs;
+  m->count = count;
+  if (count > 0)
+    memcpy (m->sections, secs, count * sizeof (asection *));
+
+  for (pm = &elf_tdata (abfd)->segment_map; *pm != NULL; pm = &(*pm)->next)
+    ;
+  *pm = m;
+
+  return true;
+}