[PATCH] D64930: [ELF][AArch64] Allow PT_LOAD to have overlapping p_offset ranges
Ryan Prichard via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 30 15:02:28 PDT 2019
rprichard added a comment.
In D64930#1606359 <https://reviews.llvm.org/D64930#1606359>, @peter.smith wrote:
> I had a quick look at the PR to see if I could make it fail (with D64930 <https://reviews.llvm.org/D64930> applied) with glibc without hacking the binary with the trim-pt-tls program with this change. I wasn't able to do so although that doesn't mean it is impossible. Having said that I agree that it would be safer to be conservative in our demands on the capabilities of dynamic loaders.
Here's an demonstration of the problem on glibc. (I applied D64903 <https://reviews.llvm.org/D64903>, D64906 <https://reviews.llvm.org/D64906>, and D64930 <https://reviews.llvm.org/D64930>.) https://gist.github.com/rprichard/e5ad0cfa10f6b75925ded3709117500f
In the shared object, declare these variables:
__thread char tlsvar1[1] = { 1 };
__thread char tlsvar2[0x100] __attribute__((aligned(0x100)));
$ ./build.sh && readelf -lW libtls.so
...
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
...
TLS 0x000780 0x0000000000020780 0x0000000000020780 0x000001 0x000180 R 0x100
Output on Ubuntu 16.04 AArch64:
&tlsvar1 = 0x1a63c700
&tlsvar2 = 0x1a63c780
> As I understand it ld.bfd and ld.gold both set the alignment of the first TLS section to the alignment of PT_TLS (max of any TLS section progbits or nobits).
That appears to be correct. ld.bfd increases the first TLS section alignment to the maximum in `_bfd_elf_tls_setup`. ld.gold leaves the sh_addralign field itself alone but still aligns the p_vaddr of the output TLS segment in `Output_segment::set_section_list_addresses`:
// Give the first TLS section the alignment of the
// entire TLS segment. Otherwise the TLS segment as a
// whole may be misaligned.
https://git.linaro.org/toolchain/binutils-gdb.git/commit/?id=96a2b4e4bf67a7430e7ddd06a1d0730a49e6b07e
Repository:
rLLD LLVM Linker
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D64930/new/
https://reviews.llvm.org/D64930
More information about the llvm-commits
mailing list