From 040dd1342911cf326025d453035ed65d2516e92f Mon Sep 17 00:00:00 2001 From: amodra Date: Thu, 17 Jan 2002 13:02:39 +0000 Subject: [PATCH] * elf-bfd.h (elf_backend_data ): Remove "Elf_Internal_Shdr *" param. (_bfd_mips_elf_section_from_bfd_section): Ditto. * elf32-mips.c (_bfd_mips_elf_section_from_bfd_section): Ditto. * elf32-m32r.c (_bfd_m32r_elf_section_from_bfd_section): Ditto. * elf32-v850.c (v850_elf_section_from_bfd_section): Ditto. * elf64-mmix.c (mmix_elf_section_from_bfd_section): Ditto. * elfxx-ia64.c (elfNN_hpux_backend_section_from_bfd_section): Ditto. * elf.c (_bfd_elf_section_from_bfd_section): Allow backend function to override special sections. Remove hdr arg from backend call, and don't loop. --- bfd/ChangeLog | 14 ++++++++++++++ bfd/elf-bfd.h | 4 ++-- bfd/elf.c | 53 +++++++++++++++++++++++++---------------------------- bfd/elf32-m32r.c | 5 ++--- bfd/elf32-mips.c | 3 +-- bfd/elf32-v850.c | 5 ++--- bfd/elf64-mmix.c | 5 ++--- bfd/elfxx-ia64.c | 5 ++--- 8 files changed, 50 insertions(+), 44 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index f366a997c9..09e3eca648 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,17 @@ +2002-01-17 Alan Modra + + * elf-bfd.h (elf_backend_data ): + Remove "Elf_Internal_Shdr *" param. + (_bfd_mips_elf_section_from_bfd_section): Ditto. + * elf32-mips.c (_bfd_mips_elf_section_from_bfd_section): Ditto. + * elf32-m32r.c (_bfd_m32r_elf_section_from_bfd_section): Ditto. + * elf32-v850.c (v850_elf_section_from_bfd_section): Ditto. + * elf64-mmix.c (mmix_elf_section_from_bfd_section): Ditto. + * elfxx-ia64.c (elfNN_hpux_backend_section_from_bfd_section): Ditto. + * elf.c (_bfd_elf_section_from_bfd_section): Allow backend + function to override special sections. Remove hdr arg from + backend call, and don't loop. + 2002-01-16 Eric Christopher * elf32-mips.c (mips_elf_calculate_relocation): Set require_jalxp diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index c5f7a740da..4a1ee2af4e 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -493,7 +493,7 @@ struct elf_backend_data section, *RETVAL should be left unchanged. If it is not a normal ELF section *RETVAL should be set to the SHN_xxxx index. */ boolean (*elf_backend_section_from_bfd_section) - PARAMS ((bfd *, Elf32_Internal_Shdr *, asection *, int *retval)); + PARAMS ((bfd *, asection *, int *retval)); /* If this field is not NULL, it is called by the add_symbols phase of a link just before adding a symbol to the global linker hash @@ -1541,7 +1541,7 @@ extern boolean _bfd_mips_elf_section_from_shdr extern boolean _bfd_mips_elf_fake_sections PARAMS ((bfd *, Elf_Internal_Shdr *, asection *)); extern boolean _bfd_mips_elf_section_from_bfd_section - PARAMS ((bfd *, Elf_Internal_Shdr *, asection *, int *)); + PARAMS ((bfd *, asection *, int *)); extern boolean _bfd_mips_elf_section_processing PARAMS ((bfd *, Elf_Internal_Shdr *)); extern void _bfd_mips_elf_symbol_processing diff --git a/bfd/elf.c b/bfd/elf.c index 080d517bb6..2c14de8a60 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -4050,50 +4050,47 @@ _bfd_elf_section_from_bfd_section (abfd, asect) bfd *abfd; struct sec *asect; { - struct elf_backend_data *bed = get_elf_backend_data (abfd); - Elf_Internal_Shdr **i_shdrp = elf_elfsections (abfd); + struct elf_backend_data *bed; int index; - Elf_Internal_Shdr *hdr; - int maxindex = elf_numsections (abfd); if (elf_section_data (asect) != NULL && elf_section_data (asect)->this_idx != 0) return elf_section_data (asect)->this_idx; if (bfd_is_abs_section (asect)) - return SHN_ABS; - if (bfd_is_com_section (asect)) - return SHN_COMMON; - if (bfd_is_und_section (asect)) - return SHN_UNDEF; - - for (index = 1; index < maxindex; index++) + index = SHN_ABS; + else if (bfd_is_com_section (asect)) + index = SHN_COMMON; + else if (bfd_is_und_section (asect)) + index = SHN_UNDEF; + else { - hdr = i_shdrp[index]; - if (hdr != NULL && hdr->bfd_section == asect) - return index; + Elf_Internal_Shdr **i_shdrp = elf_elfsections (abfd); + int maxindex = elf_numsections (abfd); + + for (index = 1; index < maxindex; index++) + { + Elf_Internal_Shdr *hdr = i_shdrp[index]; + + if (hdr != NULL && hdr->bfd_section == asect) + return index; + } + index = -1; } + bed = get_elf_backend_data (abfd); if (bed->elf_backend_section_from_bfd_section) { - for (index = 0; index < maxindex; index++) - { - int retval; + int retval = index; - hdr = i_shdrp[index]; - if (hdr == NULL) - continue; - - retval = index; - if ((*bed->elf_backend_section_from_bfd_section) - (abfd, hdr, asect, &retval)) - return retval; - } + if ((*bed->elf_backend_section_from_bfd_section) (abfd, asect, &retval)) + return retval; } - bfd_set_error (bfd_error_nonrepresentable_section); + if (index == -1) + bfd_set_error (bfd_error_nonrepresentable_section); - return SHN_BAD; + return index; } /* Given a BFD symbol, return the index in the ELF symbol table, or -1 diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c index b565b5774a..1ce1827aca 100644 --- a/bfd/elf32-m32r.c +++ b/bfd/elf32-m32r.c @@ -45,7 +45,7 @@ static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup static void m32r_info_to_howto_rel PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *)); boolean _bfd_m32r_elf_section_from_bfd_section - PARAMS ((bfd *, Elf32_Internal_Shdr *, asection *, int *)); + PARAMS ((bfd *, asection *, int *)); void _bfd_m32r_elf_symbol_processing PARAMS ((bfd *, asymbol *)); static boolean m32r_elf_add_symbol_hook @@ -765,9 +765,8 @@ m32r_info_to_howto_rel (abfd, cache_ptr, dst) index. */ boolean -_bfd_m32r_elf_section_from_bfd_section (abfd, hdr, sec, retval) +_bfd_m32r_elf_section_from_bfd_section (abfd, sec, retval) bfd *abfd ATTRIBUTE_UNUSED; - Elf32_Internal_Shdr *hdr ATTRIBUTE_UNUSED; asection *sec; int *retval; { diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c index 4bb1fcbc19..110b6098e8 100644 --- a/bfd/elf32-mips.c +++ b/bfd/elf32-mips.c @@ -3585,9 +3585,8 @@ _bfd_mips_elf_fake_sections (abfd, hdr, sec) the .scommon section. */ boolean -_bfd_mips_elf_section_from_bfd_section (abfd, hdr, sec, retval) +_bfd_mips_elf_section_from_bfd_section (abfd, sec, retval) bfd *abfd ATTRIBUTE_UNUSED; - Elf_Internal_Shdr *hdr ATTRIBUTE_UNUSED; asection *sec; int *retval; { diff --git a/bfd/elf32-v850.c b/bfd/elf32-v850.c index a1117305be..ae0a0c4e88 100644 --- a/bfd/elf32-v850.c +++ b/bfd/elf32-v850.c @@ -69,7 +69,7 @@ static boolean v850_elf_merge_private_bfd_data static boolean v850_elf_print_private_bfd_data PARAMS ((bfd *, PTR)); static boolean v850_elf_section_from_bfd_section - PARAMS ((bfd *, Elf32_Internal_Shdr *, asection *, int *)); + PARAMS ((bfd *, asection *, int *)); static void v850_elf_symbol_processing PARAMS ((bfd *, asymbol *)); static boolean v850_elf_add_symbol_hook @@ -1930,9 +1930,8 @@ static asymbol * v850_elf_zcom_symbol_ptr; corresponding ELF section index. */ static boolean -v850_elf_section_from_bfd_section (abfd, hdr, sec, retval) +v850_elf_section_from_bfd_section (abfd, sec, retval) bfd * abfd ATTRIBUTE_UNUSED; - Elf32_Internal_Shdr * hdr ATTRIBUTE_UNUSED; asection * sec; int * retval; { diff --git a/bfd/elf64-mmix.c b/bfd/elf64-mmix.c index 3911976a25..8ad8d00175 100644 --- a/bfd/elf64-mmix.c +++ b/bfd/elf64-mmix.c @@ -77,7 +77,7 @@ static bfd_reloc_status_type mmix_elf_perform_relocation PARAMS ((asection *, reloc_howto_type *, PTR, bfd_vma, bfd_vma)); static boolean mmix_elf_section_from_bfd_section - PARAMS ((bfd *, Elf64_Internal_Shdr *, asection *, int *)); + PARAMS ((bfd *, asection *, int *)); static boolean mmix_elf_add_symbol_hook PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *, @@ -1557,9 +1557,8 @@ mmix_elf_symbol_processing (abfd, asym) index. */ static boolean -mmix_elf_section_from_bfd_section (abfd, hdr, sec, retval) +mmix_elf_section_from_bfd_section (abfd, sec, retval) bfd * abfd ATTRIBUTE_UNUSED; - Elf64_Internal_Shdr * hdr ATTRIBUTE_UNUSED; asection * sec; int * retval; { diff --git a/bfd/elfxx-ia64.c b/bfd/elfxx-ia64.c index c377f06743..ee49f5a9c1 100644 --- a/bfd/elfxx-ia64.c +++ b/bfd/elfxx-ia64.c @@ -312,7 +312,7 @@ static boolean elfNN_ia64_hpux_vec static void elfNN_hpux_post_process_headers PARAMS ((bfd *abfd, struct bfd_link_info *info)); boolean elfNN_hpux_backend_section_from_bfd_section - PARAMS ((bfd *abfd, ElfNN_Internal_Shdr *hdr, asection *sec, int *retval)); + PARAMS ((bfd *abfd, asection *sec, int *retval)); /* ia64-specific relocation */ @@ -4481,9 +4481,8 @@ elfNN_hpux_post_process_headers (abfd, info) } boolean -elfNN_hpux_backend_section_from_bfd_section (abfd, hdr, sec, retval) +elfNN_hpux_backend_section_from_bfd_section (abfd, sec, retval) bfd *abfd ATTRIBUTE_UNUSED; - Elf32_Internal_Shdr *hdr ATTRIBUTE_UNUSED; asection *sec; int *retval; { -- 2.11.0