From owner-svn-src-all@FreeBSD.ORG Fri Mar 11 20:00:39 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1369E1065670; Fri, 11 Mar 2011 20:00:39 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EBD1B8FC0C; Fri, 11 Mar 2011 20:00:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2BK0cRh091885; Fri, 11 Mar 2011 20:00:38 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2BK0cC6091883; Fri, 11 Mar 2011 20:00:38 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201103112000.p2BK0cC6091883@svn.freebsd.org> From: Marius Strobl Date: Fri, 11 Mar 2011 20:00:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r219530 - head/contrib/binutils/bfd X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Mar 2011 20:00:39 -0000 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,