From c629eae01a0ff6a72882b1a7aad636d38c98bc50 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 7 Dec 2001 11:12:18 +0000 Subject: [PATCH] * elf.c (_bfd_elf_rela_local_sym): Only call _bfd_merged_section_offset if merge_info is non-NULL. (_bfd_elf_rel_local_sym, _bfd_elf_section_offset): New. * elf-bfd.h (_bfd_elf_rel_local_sym, _bfd_elf_section_offset): New prototypes. * elf32-arm.h (elf32_arm_final_link_relocate): Use _bfd_elf_section_offset. (elf32_arm_relocate_section): Use _bfd_elf_rel_local_sym. * elf32-i386.c (elf_i386_relocate_section): Use _bfd_elf_section_offset and _bfd_elf_rel_local_sym. * elf32-sh.c (sh_elf_relocate_section): Likewise. * elf32-sparc.c (elf32_sparc_relocate_section): Use _bfd_elf_section_offset. * elf32-cris.c (cris_elf_relocate_section): Likewise. * elf32-hppa.c (elf32_hppa_relocate_section): Likewise. * elf32-i370.c (i370_elf_relocate_section): Likewise. * elf32-m68k.c (elf_m68k_relocate_section): Likewise. * elf32-mips.c (mips_elf_create_dynamic_relocation): Likewise. * elf32-ppc.c (ppc_elf_relocate_section): Likewise. * elf32-s390.c (elf_s390_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-ppc.c (ppc64_elf_relocate_section): Likewise. * elf64-s390.c (elf_s390_relocate_section): Likewise. * elf64-sparc.c (sparc64_elf_relocate_section): Likewise. * elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise. * elfxx-ia64.c (elfNN_ia64_install_dyn_reloc): Likewise. --- bfd/ChangeLog | 29 +++++++++++++++++++++++++++++ bfd/elf-bfd.h | 4 ++++ bfd/elf.c | 37 ++++++++++++++++++++++++++++++++++++- bfd/elf32-arm.h | 25 ++++++------------------- bfd/elf32-cris.c | 21 +++++---------------- bfd/elf32-hppa.c | 20 ++++---------------- bfd/elf32-i370.c | 21 +++++---------------- bfd/elf32-i386.c | 22 ++++++---------------- bfd/elf32-m68k.c | 21 +++++---------------- bfd/elf32-mips.c | 27 ++++----------------------- bfd/elf32-ppc.c | 21 +++++---------------- bfd/elf32-s390.c | 18 +++++------------- bfd/elf32-sh.c | 25 ++++++------------------- bfd/elf32-sparc.c | 21 +++++---------------- bfd/elf64-alpha.c | 24 ++++-------------------- bfd/elf64-ppc.c | 19 +++++-------------- bfd/elf64-s390.c | 17 +++++------------ bfd/elf64-sparc.c | 20 +++++--------------- bfd/elf64-x86-64.c | 20 +++++--------------- bfd/elfxx-ia64.c | 30 ++++++++---------------------- 20 files changed, 157 insertions(+), 285 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 0086e7b..a87aa9f 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,32 @@ +2001-12-07 Jakub Jelinek + + * elf.c (_bfd_elf_rela_local_sym): Only call + _bfd_merged_section_offset if merge_info is non-NULL. + (_bfd_elf_rel_local_sym, _bfd_elf_section_offset): New. + * elf-bfd.h (_bfd_elf_rel_local_sym, _bfd_elf_section_offset): New + prototypes. + * elf32-arm.h (elf32_arm_final_link_relocate): Use + _bfd_elf_section_offset. + (elf32_arm_relocate_section): Use _bfd_elf_rel_local_sym. + * elf32-i386.c (elf_i386_relocate_section): Use + _bfd_elf_section_offset and _bfd_elf_rel_local_sym. + * elf32-sh.c (sh_elf_relocate_section): Likewise. + * elf32-sparc.c (elf32_sparc_relocate_section): Use + _bfd_elf_section_offset. + * elf32-cris.c (cris_elf_relocate_section): Likewise. + * elf32-hppa.c (elf32_hppa_relocate_section): Likewise. + * elf32-i370.c (i370_elf_relocate_section): Likewise. + * elf32-m68k.c (elf_m68k_relocate_section): Likewise. + * elf32-mips.c (mips_elf_create_dynamic_relocation): Likewise. + * elf32-ppc.c (ppc_elf_relocate_section): Likewise. + * elf32-s390.c (elf_s390_relocate_section): Likewise. + * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. + * elf64-ppc.c (ppc64_elf_relocate_section): Likewise. + * elf64-s390.c (elf_s390_relocate_section): Likewise. + * elf64-sparc.c (sparc64_elf_relocate_section): Likewise. + * elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise. + * elfxx-ia64.c (elfNN_ia64_install_dyn_reloc): Likewise. + 2001-12-07 Alan Modra * elf32-hppa.c (clobber_millicode_symbols): Don't do anything if diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index 026d8cf..3323aaa 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -1142,6 +1142,10 @@ extern enum elf_reloc_type_class _bfd_elf_reloc_type_class PARAMS ((const Elf_Internal_Rela *)); extern bfd_vma _bfd_elf_rela_local_sym PARAMS ((bfd *, Elf_Internal_Sym *, asection *, Elf_Internal_Rela *)); +extern bfd_vma _bfd_elf_rel_local_sym + PARAMS ((bfd *, Elf_Internal_Sym *, asection **, bfd_vma)); +extern bfd_vma _bfd_elf_section_offset + PARAMS ((bfd *, struct bfd_link_info *, asection *, bfd_vma)); extern unsigned long bfd_elf_hash PARAMS ((const char *)); diff --git a/bfd/elf.c b/bfd/elf.c index 81923d1..9c4c087 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -6393,7 +6393,8 @@ _bfd_elf_rela_local_sym (abfd, sym, sec, rel) + sec->output_offset + sym->st_value); if ((sec->flags & SEC_MERGE) - && ELF_ST_TYPE (sym->st_info) == STT_SECTION) + && ELF_ST_TYPE (sym->st_info) == STT_SECTION + && elf_section_data (sec)->merge_info) { asection *msec; @@ -6408,3 +6409,37 @@ _bfd_elf_rela_local_sym (abfd, sym, sec, rel) } return relocation; } + +bfd_vma +_bfd_elf_rel_local_sym (abfd, sym, psec, addend) + bfd *abfd; + Elf_Internal_Sym *sym; + asection **psec; + bfd_vma addend; +{ + asection *sec = *psec; + + if (elf_section_data (sec)->merge_info == NULL) + return sym->st_value + addend; + + return _bfd_merged_section_offset (abfd, psec, + elf_section_data (sec)->merge_info, + sym->st_value + addend, (bfd_vma) 0); +} + +bfd_vma +_bfd_elf_section_offset (abfd, info, sec, offset) + bfd *abfd; + struct bfd_link_info *info; + asection *sec; + bfd_vma offset; +{ + struct bfd_elf_section_data *sec_data; + + sec_data = elf_section_data (sec); + if (sec_data->stab_info != NULL) + return _bfd_stab_section_offset + (abfd, &elf_hash_table (info)->stab_info, + sec, &sec_data->stab_info, offset); + return offset; +} diff --git a/bfd/elf32-arm.h b/bfd/elf32-arm.h index 3ef2c19..26e0b75 100644 --- a/bfd/elf32-arm.h +++ b/bfd/elf32-arm.h @@ -1149,22 +1149,11 @@ elf32_arm_final_link_relocate (howto, input_bfd, output_bfd, skip = false; - if (elf_section_data (input_section)->stab_info == NULL) - outrel.r_offset = rel->r_offset; - else - { - bfd_vma off; - - off = (_bfd_stab_section_offset - (output_bfd, &elf_hash_table (info)->stab_info, - input_section, - & elf_section_data (input_section)->stab_info, - rel->r_offset)); - if (off == (bfd_vma) -1) - skip = true; - outrel.r_offset = off; - } - + outrel.r_offset = + _bfd_elf_section_offset (output_bfd, info, input_section, + rel->r_offset); + if (outrel.r_offset == (bfd_vma) -1) + skip = true; outrel.r_offset += (input_section->output_section->vma + input_section->output_offset); @@ -1892,9 +1881,7 @@ elf32_arm_relocate_section (output_bfd, info, input_bfd, input_section, } msec = sec; addend = - _bfd_merged_section_offset (output_bfd, &msec, - elf_section_data (sec)->merge_info, - sym->st_value + addend, (bfd_vma) 0) + _bfd_elf_rel_local_sym (output_bfd, sym, &msec, addend) - relocation; addend += msec->output_section->vma + msec->output_offset; value = (value & ~ howto->dst_mask) | (addend & howto->dst_mask); diff --git a/bfd/elf32-cris.c b/bfd/elf32-cris.c index 674a7b1..5f7c667 100644 --- a/bfd/elf32-cris.c +++ b/bfd/elf32-cris.c @@ -1283,22 +1283,11 @@ cris_elf_relocate_section (output_bfd, info, input_bfd, input_section, skip = false; - if (elf_section_data (input_section)->stab_info == NULL) - outrel.r_offset = rel->r_offset; - else - { - bfd_vma off; - - off = (_bfd_stab_section_offset - (output_bfd, &elf_hash_table (info)->stab_info, - input_section, - &elf_section_data (input_section)->stab_info, - rel->r_offset)); - if (off == (bfd_vma) -1) - skip = true; - outrel.r_offset = off; - } - + outrel.r_offset = + _bfd_elf_section_offset (output_bfd, info, input_section, + rel->r_offset); + if (outrel.r_offset == (bfd_vma) -1) + skip = true; outrel.r_offset += (input_section->output_section->vma + input_section->output_offset); diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c index 0aaf346..934c8e8 100644 --- a/bfd/elf32-hppa.c +++ b/bfd/elf32-hppa.c @@ -3949,23 +3949,11 @@ elf32_hppa_relocate_section (output_bfd, info, input_bfd, input_section, are copied into the output file to be resolved at run time. */ - outrel.r_offset = rel->r_offset; outrel.r_addend = rel->r_addend; - skip = false; - if (elf_section_data (input_section)->stab_info != NULL) - { - bfd_vma off; - - off = (_bfd_stab_section_offset - (output_bfd, &htab->elf.stab_info, - input_section, - &elf_section_data (input_section)->stab_info, - rel->r_offset)); - if (off == (bfd_vma) -1) - skip = true; - outrel.r_offset = off; - } - + outrel.r_offset = + _bfd_elf_section_offset (output_bfd, info, input_section, + rel->r_offset); + skip = (outrel.r_offset == (bfd_vma) -1); outrel.r_offset += (input_section->output_offset + input_section->output_section->vma); diff --git a/bfd/elf32-i370.c b/bfd/elf32-i370.c index 3b9ad34..315689e 100644 --- a/bfd/elf32-i370.c +++ b/bfd/elf32-i370.c @@ -1486,22 +1486,11 @@ i370_elf_relocate_section (output_bfd, info, input_bfd, input_section, skip = false; - if (elf_section_data (input_section)->stab_info == NULL) - outrel.r_offset = rel->r_offset; - else - { - bfd_vma off; - - off = (_bfd_stab_section_offset - (output_bfd, &elf_hash_table (info)->stab_info, - input_section, - &elf_section_data (input_section)->stab_info, - rel->r_offset)); - if (off == (bfd_vma) -1) - skip = true; - outrel.r_offset = off; - } - + outrel.r_offset = + _bfd_elf_section_offset (output_bfd, info, input_section, + rel->r_offset); + if (outrel.r_offset == (bfd_vma) -1) + skip = true; outrel.r_offset += (input_section->output_section->vma + input_section->output_offset); diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index 9299b1c..9fae870 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -1789,9 +1789,7 @@ elf_i386_relocate_section (output_bfd, info, input_bfd, input_section, addend = bfd_get_32 (input_bfd, contents + rel->r_offset); msec = sec; addend = - _bfd_merged_section_offset (output_bfd, &msec, - elf_section_data (sec)->merge_info, - sym->st_value + addend, (bfd_vma) 0) + _bfd_elf_rel_local_sym (output_bfd, sym, &msec, addend) - relocation; addend += msec->output_section->vma + msec->output_offset; bfd_put_32 (input_bfd, addend, contents + rel->r_offset); @@ -2009,19 +2007,11 @@ elf_i386_relocate_section (output_bfd, info, input_bfd, input_section, skip = false; - if (elf_section_data (input_section)->stab_info == NULL) - outrel.r_offset = rel->r_offset; - else - { - off = (_bfd_stab_section_offset - (output_bfd, htab->elf.stab_info, input_section, - &elf_section_data (input_section)->stab_info, - rel->r_offset)); - if (off == (bfd_vma) -1) - skip = true; - outrel.r_offset = off; - } - + outrel.r_offset = + _bfd_elf_section_offset (output_bfd, info, input_section, + rel->r_offset); + if (outrel.r_offset == (bfd_vma) -1) + skip = true; outrel.r_offset += (input_section->output_section->vma + input_section->output_offset); diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c index 68f4a23..e4b41be 100644 --- a/bfd/elf32-m68k.c +++ b/bfd/elf32-m68k.c @@ -1680,22 +1680,11 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section, skip = false; - if (elf_section_data (input_section)->stab_info == NULL) - outrel.r_offset = rel->r_offset; - else - { - bfd_vma off; - - off = (_bfd_stab_section_offset - (output_bfd, &elf_hash_table (info)->stab_info, - input_section, - &elf_section_data (input_section)->stab_info, - rel->r_offset)); - if (off == (bfd_vma) -1) - skip = true; - outrel.r_offset = off; - } - + outrel.r_offset = + _bfd_elf_section_offset (output_bfd, info, input_section, + rel->r_offset); + if (outrel.r_offset == (bfd_vma) -1) + skip = true; outrel.r_offset += (input_section->output_section->vma + input_section->output_offset); diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c index 78e89b1..ff758fa 100644 --- a/bfd/elf32-mips.c +++ b/bfd/elf32-mips.c @@ -6358,29 +6358,10 @@ mips_elf_create_dynamic_relocation (output_bfd, info, rel, h, sec, < sreloc->_raw_size); skip = false; - - /* We begin by assuming that the offset for the dynamic relocation - is the same as for the original relocation. We'll adjust this - later to reflect the correct output offsets. */ - if (elf_section_data (input_section)->stab_info == NULL) - outrel.r_offset = rel->r_offset; - else - { - /* Except that in a stab section things are more complex. - Because we compress stab information, the offset given in the - relocation may not be the one we want; we must let the stabs - machinery tell us the offset. */ - outrel.r_offset - = (_bfd_stab_section_offset - (output_bfd, &elf_hash_table (info)->stab_info, - input_section, - &elf_section_data (input_section)->stab_info, - rel->r_offset)); - /* If we didn't need the relocation at all, this value will be - -1. */ - if (outrel.r_offset == (bfd_vma) -1) - skip = true; - } + outrel.r_offset = + _bfd_elf_section_offset (output_bfd, info, input_section, rel->r_offset); + if (outrel.r_offset == (bfd_vma) -1) + skip = true; /* If we've decided to skip this relocation, just output an empty record. Note that R_MIPS_NONE == 0, so that this call to memset diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index 2af8400..e174603 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -3210,22 +3210,11 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section, skip = false; - if (elf_section_data (input_section)->stab_info == NULL) - outrel.r_offset = rel->r_offset; - else - { - bfd_vma off; - - off = (_bfd_stab_section_offset - (output_bfd, &elf_hash_table (info)->stab_info, - input_section, - &elf_section_data (input_section)->stab_info, - rel->r_offset)); - if (off == (bfd_vma) -1) - skip = true; - outrel.r_offset = off; - } - + outrel.r_offset = + _bfd_elf_section_offset (output_bfd, info, input_section, + rel->r_offset); + if (outrel.r_offset == (bfd_vma) -1) + skip = true; outrel.r_offset += (input_section->output_section->vma + input_section->output_offset); diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c index f608fb0..ac1c6d0 100644 --- a/bfd/elf32-s390.c +++ b/bfd/elf32-s390.c @@ -1891,19 +1891,11 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section, skip = false; - if (elf_section_data (input_section)->stab_info == NULL) - outrel.r_offset = rel->r_offset; - else - { - off = (_bfd_stab_section_offset - (output_bfd, htab->elf.stab_info, input_section, - &elf_section_data (input_section)->stab_info, - rel->r_offset)); - if (off == (bfd_vma) -1) - skip = true; - outrel.r_offset = off; - } - + outrel.r_offset = + _bfd_elf_section_offset (output_bfd, info, input_section, + rel->r_offset); + if (outrel.r_offset == (bfd_vma) -1) + skip = true; outrel.r_offset += (input_section->output_section->vma + input_section->output_offset); diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c index 74b725a..9fe9873 100644 --- a/bfd/elf32-sh.c +++ b/bfd/elf32-sh.c @@ -3101,9 +3101,7 @@ sh_elf_relocate_section (output_bfd, info, input_bfd, input_section, addend = bfd_get_32 (input_bfd, contents + rel->r_offset); msec = sec; addend = - _bfd_merged_section_offset (output_bfd, &msec, - elf_section_data (sec)->merge_info, - sym->st_value + addend, (bfd_vma) 0) + _bfd_elf_rel_local_sym (output_bfd, sym, &msec, addend) - relocation; addend += msec->output_section->vma + msec->output_offset; bfd_put_32 (input_bfd, addend, contents + rel->r_offset); @@ -3284,22 +3282,11 @@ sh_elf_relocate_section (output_bfd, info, input_bfd, input_section, skip = false; - if (elf_section_data (input_section)->stab_info == NULL) - outrel.r_offset = rel->r_offset; - else - { - bfd_vma off; - - off = (_bfd_stab_section_offset - (output_bfd, &elf_hash_table (info)->stab_info, - input_section, - &elf_section_data (input_section)->stab_info, - rel->r_offset)); - if (off == (bfd_vma) -1) - skip = true; - outrel.r_offset = off; - } - + outrel.r_offset = + _bfd_elf_section_offset (output_bfd, info, input_section, + rel->r_offset); + if (outrel.r_offset == (bfd_vma) -1) + skip = true; outrel.r_offset += (input_section->output_section->vma + input_section->output_offset); diff --git a/bfd/elf32-sparc.c b/bfd/elf32-sparc.c index 60a4dc7..6a82d72 100644 --- a/bfd/elf32-sparc.c +++ b/bfd/elf32-sparc.c @@ -1448,22 +1448,11 @@ elf32_sparc_relocate_section (output_bfd, info, input_bfd, input_section, skip = false; - if (elf_section_data (input_section)->stab_info == NULL) - outrel.r_offset = rel->r_offset; - else - { - bfd_vma off; - - off = (_bfd_stab_section_offset - (output_bfd, &elf_hash_table (info)->stab_info, - input_section, - &elf_section_data (input_section)->stab_info, - rel->r_offset)); - if (off == (bfd_vma) -1) - skip = true; - outrel.r_offset = off; - } - + outrel.r_offset = + _bfd_elf_section_offset (output_bfd, info, input_section, + rel->r_offset); + if (outrel.r_offset == (bfd_vma) -1) + skip = true; outrel.r_offset += (input_section->output_section->vma + input_section->output_offset); diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c index 950d051..e372046 100644 --- a/bfd/elf64-alpha.c +++ b/bfd/elf64-alpha.c @@ -3534,7 +3534,6 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section, case R_ALPHA_REFQUAD: { Elf_Internal_Rela outrel; - boolean skip; /* Careful here to remember RELATIVE relocations for global variables for symbolic shared objects. */ @@ -3569,25 +3568,10 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section, BFD_ASSERT(srel != NULL); } - skip = false; - - if (elf_section_data (input_section)->stab_info == NULL) - outrel.r_offset = rel->r_offset; - else - { - bfd_vma off; - - off = (_bfd_stab_section_offset - (output_bfd, &elf_hash_table (info)->stab_info, - input_section, - &elf_section_data (input_section)->stab_info, - rel->r_offset)); - if (off == (bfd_vma) -1) - skip = true; - outrel.r_offset = off; - } - - if (! skip) + outrel.r_offset = + _bfd_elf_section_offset (output_bfd, info, input_section, + rel->r_offset); + if (outrel.r_offset != (bfd_vma) -1) outrel.r_offset += (input_section->output_section->vma + input_section->output_offset); else diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index 02d2913..4772254 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -3494,20 +3494,11 @@ ppc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, skip = false; - if (elf_section_data (input_section)->stab_info == NULL) - outrel.r_offset = offset; - else - { - bfd_vma off; - - off = (_bfd_stab_section_offset - (output_bfd, htab->elf.stab_info, input_section, - &elf_section_data (input_section)->stab_info, - offset)); - if (off == (bfd_vma) -1) - skip = true; - outrel.r_offset = off; - } + outrel.r_offset = + _bfd_elf_section_offset (output_bfd, info, input_section, + rel->r_offset); + if (outrel.r_offset == (bfd_vma) -1) + skip = true; outrel.r_offset += (input_section->output_section->vma + input_section->output_offset); diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c index 222e1e4..da037ff 100644 --- a/bfd/elf64-s390.c +++ b/bfd/elf64-s390.c @@ -1891,18 +1891,11 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section, skip = false; - if (elf_section_data (input_section)->stab_info == NULL) - outrel.r_offset = rel->r_offset; - else - { - off = (_bfd_stab_section_offset - (output_bfd, htab->elf.stab_info, input_section, - &elf_section_data (input_section)->stab_info, - rel->r_offset)); - if (off == (bfd_vma) -1) - skip = true; - outrel.r_offset = off; - } + outrel.r_offset = + _bfd_elf_section_offset (output_bfd, info, input_section, + rel->r_offset); + if (outrel.r_offset == (bfd_vma) -1) + skip = true; outrel.r_offset += (input_section->output_section->vma + input_section->output_offset); diff --git a/bfd/elf64-sparc.c b/bfd/elf64-sparc.c index 9a91816..50b0cd5 100644 --- a/bfd/elf64-sparc.c +++ b/bfd/elf64-sparc.c @@ -2184,21 +2184,11 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, skip = false; - if (elf_section_data (input_section)->stab_info == NULL) - outrel.r_offset = rel->r_offset; - else - { - bfd_vma off; - - off = (_bfd_stab_section_offset - (output_bfd, &elf_hash_table (info)->stab_info, - input_section, - &elf_section_data (input_section)->stab_info, - rel->r_offset)); - if (off == MINUS_ONE) - skip = true; - outrel.r_offset = off; - } + outrel.r_offset = + _bfd_elf_section_offset (output_bfd, info, input_section, + rel->r_offset); + if (outrel.r_offset == (bfd_vma) -1) + skip = true; outrel.r_offset += (input_section->output_section->vma + input_section->output_offset); diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index 349540f..9f7fdd3 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -1473,21 +1473,11 @@ elf64_x86_64_relocate_section (output_bfd, info, input_bfd, input_section, skip = false; - if (elf_section_data (input_section)->stab_info == NULL) - outrel.r_offset = rela->r_offset; - else - { - bfd_vma off; - - off = (_bfd_stab_section_offset - (output_bfd, &elf_hash_table (info)->stab_info, - input_section, - &elf_section_data (input_section)->stab_info, - rela->r_offset)); - if (off == (bfd_vma) -1) - skip = true; - outrel.r_offset = off; - } + outrel.r_offset = + _bfd_elf_section_offset (output_bfd, info, input_section, + rela->r_offset); + if (outrel.r_offset == (bfd_vma) -1) + skip = true; outrel.r_offset += (input_section->output_section->vma + input_section->output_offset); diff --git a/bfd/elfxx-ia64.c b/bfd/elfxx-ia64.c index 2e34a30..ca1d7e1 100644 --- a/bfd/elfxx-ia64.c +++ b/bfd/elfxx-ia64.c @@ -3014,33 +3014,19 @@ elfNN_ia64_install_dyn_reloc (abfd, info, sec, srel, offset, type, { Elf_Internal_Rela outrel; - outrel.r_offset = (sec->output_section->vma - + sec->output_offset - + offset); + offset += sec->output_section->vma + sec->output_offset; BFD_ASSERT (dynindx != -1); outrel.r_info = ELFNN_R_INFO (dynindx, type); outrel.r_addend = addend; - - if (elf_section_data (sec)->stab_info != NULL) + outrel.r_offset = _bfd_elf_section_offset (abfd, info, sec, offset); + if (outrel.r_offset == (bfd_vma) -1) { - /* This may be NULL for linker-generated relocations, as it is - inconvenient to pass all the bits around. And this shouldn't - happen. */ - BFD_ASSERT (info != NULL); - - offset = (_bfd_stab_section_offset - (abfd, &elf_hash_table (info)->stab_info, sec, - &elf_section_data (sec)->stab_info, offset)); - if (offset == (bfd_vma) -1) - { - /* Run for the hills. We shouldn't be outputting a relocation - for this. So do what everyone else does and output a no-op. */ - outrel.r_info = ELFNN_R_INFO (0, R_IA64_NONE); - outrel.r_addend = 0; - offset = 0; - } - outrel.r_offset = offset; + /* Run for the hills. We shouldn't be outputting a relocation + for this. So do what everyone else does and output a no-op. */ + outrel.r_info = ELFNN_R_INFO (0, R_IA64_NONE); + outrel.r_addend = 0; + outrel.r_offset = 0; } bfd_elfNN_swap_reloca_out (abfd, &outrel, -- 2.7.4