summaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2001-12-07 11:12:18 +0000
committerJakub Jelinek <jakub@redhat.com>2001-12-07 11:12:18 +0000
commit63f9185c1a573204fee22b3084fbe37747530fe9 (patch)
treecd2cb5c5f33b2de8ec67d637ebe5377d5765c772 /bfd
parent38f5f6e935d787bc0af0b2d001879781ae5dbaf9 (diff)
downloadgdb-63f9185c1a573204fee22b3084fbe37747530fe9.tar.gz
* 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.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog29
-rw-r--r--bfd/elf-bfd.h4
-rw-r--r--bfd/elf.c37
-rw-r--r--bfd/elf32-arm.h25
-rw-r--r--bfd/elf32-cris.c21
-rw-r--r--bfd/elf32-hppa.c20
-rw-r--r--bfd/elf32-i370.c21
-rw-r--r--bfd/elf32-i386.c22
-rw-r--r--bfd/elf32-m68k.c21
-rw-r--r--bfd/elf32-mips.c27
-rw-r--r--bfd/elf32-ppc.c21
-rw-r--r--bfd/elf32-s390.c18
-rw-r--r--bfd/elf32-sh.c25
-rw-r--r--bfd/elf32-sparc.c21
-rw-r--r--bfd/elf64-alpha.c24
-rw-r--r--bfd/elf64-ppc.c19
-rw-r--r--bfd/elf64-s390.c17
-rw-r--r--bfd/elf64-sparc.c20
-rw-r--r--bfd/elf64-x86-64.c20
-rw-r--r--bfd/elfxx-ia64.c30
20 files changed, 157 insertions, 285 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 0086e7bdd97..a87aa9faf05 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,32 @@
+2001-12-07 Jakub Jelinek <jakub@redhat.com>
+
+ * 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 <amodra@bigpond.net.au>
* elf32-hppa.c (clobber_millicode_symbols): Don't do anything if
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index 026d8cf4224..3323aaaa767 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 81923d176dd..9c4c0870f4a 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 3ef2c197d9b..26e0b7523a8 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 674a7b12e26..5f7c6670c8f 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 0aaf346b36a..934c8e82b8a 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 3b9ad347e6e..315689e5043 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 9299b1c27c0..9fae870350b 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 68f4a23005c..e4b41be5904 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 78e89b17d05..ff758fa7869 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 2af84004ab4..e174603ce74 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 f608fb0aa6d..ac1c6d0035d 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 74b725a0ee2..9fe9873e3ff 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 60a4dc76fa5..6a82d72f513 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 950d051bf56..e3720466f84 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 02d2913d3b6..477225469e7 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 222e1e44bf8..da037fff087 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 9a918166dea..50b0cd58cc6 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 349540f2700..9f7fdd3dc3f 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 2e34a3071c6..ca1d7e1966c 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,