fix powerpc dynamic linker thread-pointer-relative relocations
authorRich Felker <dalias@aerifal.cx>
Tue, 17 Jun 2014 18:32:43 +0000 (14:32 -0400)
committerRich Felker <dalias@aerifal.cx>
Mon, 28 Jul 2014 04:27:58 +0000 (00:27 -0400)
processing of R_PPC_TPREL32 was ignoring the addend provided by the
RELA-style relocation and instead using the inline value as the
addend. this presumably broke dynamic-linked access to initial TLS in
cases where the addend was nonzero.

(cherry picked from commit 94cf991bf4b18bb87a15a96e7b5e7d92fab787ba)

arch/powerpc/reloc.h

index 38034c5642b6d684759a68262bb0dd3e5a2953e6..6b98a7ca268aa1e13e3114b405cf6e84566ccc5a 100644 (file)
@@ -32,9 +32,9 @@ static inline void do_single_reloc(
                *reloc_addr = def.sym->st_value + addend;
                break;
        case R_PPC_TPREL32:
-               *reloc_addr += def.sym
-                       ? def.sym->st_value + def.dso->tls_offset - 0x7000
-                       : self->tls_offset - 0x7000;
+               *reloc_addr = (def.sym
+                       ? def.sym->st_value + def.dso->tls_offset
+                       : self->tls_offset) - 0x7000 + addend;
                break;
        }
 }