Date: Fri, 11 Mar 2011 20:00:38 +0000 (UTC) From: Marius Strobl <marius@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r219530 - head/contrib/binutils/bfd Message-ID: <201103112000.p2BK0cC6091883@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: marius Date: Fri Mar 11 20:00:38 2011 New Revision: 219530 URL: http://svn.freebsd.org/changeset/base/219530 Log: 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 Modified: head/contrib/binutils/bfd/elfxx-sparc.c Modified: head/contrib/binutils/bfd/elfxx-sparc.c ============================================================================== --- head/contrib/binutils/bfd/elfxx-sparc.c Fri Mar 11 19:44:06 2011 (r219529) +++ head/contrib/binutils/bfd/elfxx-sparc.c Fri Mar 11 20:00:38 2011 (r219530) @@ -2474,11 +2474,13 @@ _bfd_sparc_elf_relocate_section (bfd *ou 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 *ou { 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 *ou 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,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201103112000.p2BK0cC6091883>