about summary refs log tree commit diff
path: root/arch/i386
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2016-12-20 14:19:32 -0500
committerRich Felker <dalias@aerifal.cx>2016-12-20 14:19:32 -0500
commit5bf7eba213cacc4c1220627c91c28deff2ffecda (patch)
treeebb6df505aa7b8457e3f11010c747e15eca6c344 /arch/i386
parent088c9674a9c81cf20e9a863df571ba6d48e9ae37 (diff)
downloadmusl-5bf7eba213cacc4c1220627c91c28deff2ffecda.tar.gz
musl-5bf7eba213cacc4c1220627c91c28deff2ffecda.tar.xz
musl-5bf7eba213cacc4c1220627c91c28deff2ffecda.zip
fix support for initialized TLS in static PIE binaries
the static-linked version of __init_tls needs to locate the TLS
initialization image via the ELF program headers, which requires
determining the base address at which the program was loaded. the
existing code attempted to do this by comparing the actual address of
the program headers (obtained via auxv) with the virtual address for
the PT_PHDR record in the program headers. however, the linker seems
to produce a PT_PHDR record only when a program interpreter (dynamic
linker) is used. thus the computation failed and used the default base
address of 0, leading to a crash when trying to access the TLS image
at the wrong address.

the dynamic linker entry point and static-PIE rcrt1.o startup code
compute the base address instead by taking the difference between the
run-time address of _DYNAMIC and the virtual address in the PT_DYNAMIC
record. this patch copies the approach they use, but with a weak
symbolic reference to _DYNAMIC instead of obtaining the address from
the crt_arch.h asm. this works because relocations have already been
performed at the time __init_tls is called.
Diffstat (limited to 'arch/i386')
0 files changed, 0 insertions, 0 deletions