From: Ian Lance Taylor Date: Fri, 1 Dec 1995 21:45:33 +0000 (+0000) Subject: * bfd.c (bfd_record_phdr): New function. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ae0a6bea51963cb58d2df3e5b453efdcfdd41628;p=binutils-gdb.git * bfd.c (bfd_record_phdr): New function. * bfd-in.h (bfd_record_phdr): Declare. * bfd_in2.h: Rebuild. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 8d2bcf97aca..9c190c8996c 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,15 @@ Fri Dec 1 14:46:51 1995 Ian Lance Taylor + * 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. diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h index de096c5bbe8..e0f8d04fd13 100644 --- a/bfd/bfd-in.h +++ b/bfd/bfd-in.h @@ -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. */ diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 3621b55a7aa..925ab3ef723 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -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)\ diff --git a/bfd/bfd.c b/bfd/bfd.c index d98ad629ad6..3fa0e081c86 100644 --- 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 @@ -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; +}