summaryrefslogtreecommitdiffstats
path: root/contrib/binutils/bfd
diff options
context:
space:
mode:
authormarius <marius@FreeBSD.org>2011-03-11 20:00:38 +0000
committermarius <marius@FreeBSD.org>2011-03-11 20:00:38 +0000
commitd3cd30fe16f1e5cde039af5d0a5ab5708bb3570d (patch)
tree8a806cdeeab2d90a39bd389a9d06b16fa7e1553b /contrib/binutils/bfd
parent2d07803115870d2c7b7c79225efb17823ae34056 (diff)
downloadFreeBSD-src-d3cd30fe16f1e5cde039af5d0a5ab5708bb3570d.zip
FreeBSD-src-d3cd30fe16f1e5cde039af5d0a5ab5708bb3570d.tar.gz
In the upstream rev. 1.61 of elf64-sparc.c the following bug was fixed:
* elf64-sparc.c (sparc64_elf_relocate_section): Adjust addend of dynamic relocs against section symbols for the output section vma. However, with the addition of TLS support in the upstream rev. 1.104 this fix was essentially reverted. After factoring out the common parts of elf32-sparc.c and elf64-sparc.c a comment was added to elfxx-sparc.c in the upstream rev. 1.27 as part of unrelated changes, saying that the fix from elf64-sparc.c rev. 1.61 indeed should be implemented, but given that some unspecified OS has a broken ld.so expecting broken relocations deliberately is omitted. As the current behavior actually violates the SPARC ABI, FreeBSD never had such a broken ld.so and this is actually causing problems with at least kernel modules linked with binutils 2.17.50 committed in r218822 without the workaround committed in r219340 in place, re-implement the above fix in a way so that is only applied if the output format is ELFOSABI_FREEBSD. In the upstream version it probably would make sense to invert this check and only skip adjusting the addend for the OS with the broken ld.so, once it's determine which one that is. Approved by: dim
Diffstat (limited to 'contrib/binutils/bfd')
-rw-r--r--contrib/binutils/bfd/elfxx-sparc.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/contrib/binutils/bfd/elfxx-sparc.c b/contrib/binutils/bfd/elfxx-sparc.c
index 708af29..c411a48 100644
--- a/contrib/binutils/bfd/elfxx-sparc.c
+++ b/contrib/binutils/bfd/elfxx-sparc.c
@@ -2474,11 +2474,13 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd,
Elf_Internal_Rela *rel;
Elf_Internal_Rela *relend;
int num_relocs;
+ const struct elf_backend_data *bed;
htab = _bfd_sparc_elf_hash_table (info);
symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
sym_hashes = elf_sym_hashes (input_bfd);
local_got_offsets = elf_local_got_offsets (input_bfd);
+ bed = get_elf_backend_data (output_bfd);
if (elf_hash_table (info)->hgot == NULL)
got_base = 0;
@@ -2876,11 +2878,6 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd,
{
asection *osec;
- /* We are turning this relocation into one
- against a section symbol. It would be
- proper to subtract the symbol's value,
- osec->vma, from the emitted reloc addend,
- but ld.so expects buggy relocs. */
osec = sec->output_section;
indx = elf_section_data (osec)->dynindx;
@@ -2901,6 +2898,15 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd,
bfd_set_error (bfd_error_bad_value);
return FALSE;
}
+
+ /* We are turning this relocation into one
+ against a section symbol, so subtract out
+ the output section's address but not the
+ offset of the input section in the output
+ section on OSes where ld.so doesn't expect
+ buggy relocs. */
+ if (bed->elf_osabi == ELFOSABI_FREEBSD)
+ outrel.r_addend -= osec->vma;
}
outrel.r_info = SPARC_ELF_R_INFO (htab, rel, indx,
OpenPOWER on IntegriCloud