From owner-svn-src-all@FreeBSD.ORG Sun Mar 6 15:20:12 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 3AFDD1065674; Sun, 6 Mar 2011 15:20:12 +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 0FFA88FC12; Sun, 6 Mar 2011 15:20:12 +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 p26FKB1Y002100; Sun, 6 Mar 2011 15:20:11 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p26FKBiQ002097; Sun, 6 Mar 2011 15:20:11 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201103061520.p26FKBiQ002097@svn.freebsd.org> From: Marius Strobl Date: Sun, 6 Mar 2011 15:20:11 +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: r219340 - in head: libexec/rtld-elf/sparc64 sys/sparc64/sparc64 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: Sun, 06 Mar 2011 15:20:12 -0000 Author: marius Date: Sun Mar 6 15:20:11 2011 New Revision: 219340 URL: http://svn.freebsd.org/changeset/base/219340 Log: - With the addition of TLS support binutils started to make the addend values for resolved symbols relative to relocbase instead of sections so detect this case and handle as appropriate, which allows using kernel modules linked with affected versions of binutils. Actually I think this is a bug in binutils but given that apparently nobody complained for nearly six years and powerpc has basically the same workaround I decided to put it in for the sparc64 kernel, too. - Fix R_SPARC_HIX22 relocations. Apparently these are hardly ever used. Modified: head/libexec/rtld-elf/sparc64/reloc.c head/sys/sparc64/sparc64/elf_machdep.c Modified: head/libexec/rtld-elf/sparc64/reloc.c ============================================================================== --- head/libexec/rtld-elf/sparc64/reloc.c Sun Mar 6 13:25:46 2011 (r219339) +++ head/libexec/rtld-elf/sparc64/reloc.c Sun Mar 6 15:20:11 2011 (r219340) @@ -355,6 +355,9 @@ reloc_nonplt_object(Obj_Entry *obj, cons if (type == R_SPARC_OLO10) value = (value & 0x3ff) + ELF64_R_TYPE_DATA(rela->r_info); + if (type == R_SPARC_HIX22) + value ^= 0xffffffffffffffff; + if (RELOC_PC_RELATIVE(type)) value -= (Elf_Addr)where; Modified: head/sys/sparc64/sparc64/elf_machdep.c ============================================================================== --- head/sys/sparc64/sparc64/elf_machdep.c Sun Mar 6 13:25:46 2011 (r219339) +++ head/sys/sparc64/sparc64/elf_machdep.c Sun Mar 6 15:20:11 2011 (r219340) @@ -332,7 +332,14 @@ elf_reloc(linker_file_t lf, Elf_Addr rel addr = lookup(lf, symidx, 1); if (addr == 0) return (-1); - value += addr; + /* + * With the addition of TLS support binutils started to make + * addend values relative to relocbase instead of sections. + */ + if (addr > relocbase && addr <= relocbase + value) + value += relocbase; + else + value += addr; if (RELOC_BARE_SYMBOL(rtype)) value = elf_relocaddr(lf, value); } @@ -340,6 +347,9 @@ elf_reloc(linker_file_t lf, Elf_Addr rel if (rtype == R_SPARC_OLO10) value = (value & 0x3ff) + ELF64_R_TYPE_DATA(rela->r_info); + if (rtype == R_SPARC_HIX22) + value ^= 0xffffffffffffffff; + if (RELOC_PC_RELATIVE(rtype)) value -= (Elf_Addr)where;