Fix TLS relocations against local symbols on powerpc32, sparc32 and sparc64
commit8644588807215ab09716ac04a150f91ac83acffd
authorJames Clarke <jrtc27@jrtc27.com>
Fri, 13 Oct 2017 18:44:39 +0000 (13 15:44 -0300)
committerTulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
Fri, 13 Oct 2017 19:14:16 +0000 (13 16:14 -0300)
treea102e789349ae949df505458c19b41abf5f327d2
parente8dbd6a36d8e4d30e736e28a364f7a4d1404079a
Fix TLS relocations against local symbols on powerpc32, sparc32 and sparc64

Normally, TLS relocations against local symbols are optimised by the linker
to be absolute.  However, gold does not do this, and so it is possible to
end up with, for example, R_SPARC_TLS_DTPMOD64 referring to a local symbol.
Since sym_map is left as null in elf_machine_rela for the special local
symbol case, the relocation handling thinks it has nothing to do, and so
the module gets left as 0.  Havoc then ensues when the variable in question
is accessed.

Before this fix, the main_local_gold program would receive a SIGBUS on
sparc64, and SIGSEGV on powerpc32.  With this fix applied, that test now
passes like the rest of them.

* sysdeps/powerpc/powerpc32/dl-machine.h (elf_machine_rela):
Assign sym_map to be map for local symbols, as TLS relocations
use sym_map to determine whether the symbol is defined and to
extract the TLS information.
* sysdeps/sparc/sparc32/dl-machine.h (elf_machine_rela): Likewise.
* sysdeps/sparc/sparc64/dl-machine.h (elf_machine_rela): Likewise.
ChangeLog
sysdeps/powerpc/powerpc32/dl-machine.h
sysdeps/sparc/sparc32/dl-machine.h
sysdeps/sparc/sparc64/dl-machine.h