Date: Sun, 6 Mar 2011 15:20:11 +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: r219340 - in head: libexec/rtld-elf/sparc64 sys/sparc64/sparc64 Message-ID: <201103061520.p26FKBiQ002097@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201103061520.p26FKBiQ002097>