llvm-project/lld/test/elf
Rafael Auler 5a1000dddc [lld] [ELF] Support for general dynamic TLS relocations on X86_64
Summary:
This patch adds support for the general dynamic TLS access model for X86_64 (see www.akkadia.org/drepper/tls.pdf).

To properly support TLS, the patch also changes the __tls_get_addr atom to be a shared library atom instead of a regularly defined atom (the previous lld approach). This closely models the reality of a function that will be resolved at runtime by the dynamic linker and loader itself (ld.so). I was tempted to force LLD to link against ld.so itself to resolve these symbols, but since GNU ld does not need the ld.so library to resolve this symbol, I decided to mimic its behavior and keep hardwired a definition of __tls_get_addr in the lld code.

This patch also moves some important logic that previously was only available to the MIPS lld backend to be used to all ELF backends. This logic, which now lives in the DefaultLayout class, will monitor which external (shared lib) symbols are really imported by the current module and will only populate the dynamic symbol table with used symbols, as opposed to the previous approach of dumping all shared lib symbols in the dynamic symbol table. This is important to this patch to avoid __tls_get_addr from getting injected into all dynamic symbol tables.

By solving the previous problem of always adding __tls_get_addr, now the produced symbol tables are slightly smaller. But this impacted several tests that relied on hardwired/predefined sizes of the symbol table, requiring this patch to update such tests.

Test Plan: Added a LIT test case that exercises a simple use case of TLS variable in a shared library.

Reviewers: ruiu, rafael, Bigcheese, shankarke

Reviewed By: Bigcheese, shankarke

Subscribers: emaste, shankarke, joerg, kledzik, mcrosier, llvm-commits

Projects: #lld

Differential Revision: http://reviews.llvm.org/D5505

llvm-svn: 218633
2014-09-29 22:05:26 +00:00
..
AArch64 [AArch64] Initial ELF/AArch64 Support 2014-08-13 13:16:38 +00:00
Hexagon Change llvm-nm to use -M instead of -s to work with latest llvm-nm 2014-07-09 00:25:52 +00:00
Inputs Re-commit r218259. 2014-09-22 20:48:04 +00:00
Mips [mips] Remove .end and .end from test/elf/Mips/hilo16-3.test 2014-08-13 10:04:59 +00:00
X86_64 [lld] [ELF] Support for general dynamic TLS relocations on X86_64 2014-09-29 22:05:26 +00:00
linkerscript [ELF] Return error from invalid linker script parse. 2013-10-10 16:59:53 +00:00
options Fix trailing whitespace. 2014-01-27 03:09:26 +00:00
abs-dup.objtxt Accept and handle absolute symbols with empty name. 2014-02-06 07:35:16 +00:00
abs.test Fix trailing whitespace. 2014-01-27 03:09:26 +00:00
allowduplicates.objtxt [ELF] Add -z muldefs option. 2014-04-02 03:57:37 +00:00
archive-elf-forceload.test Fix trailing whitespace. 2014-01-27 03:09:26 +00:00
archive-elf.test Add missing triples so that these tests pass on 32 bit arch. 2014-01-09 00:07:20 +00:00
branch.test Fix trailing whitespace. 2014-01-27 03:09:26 +00:00
check.test Fix trailing whitespace. 2014-01-27 03:09:26 +00:00
checkrodata.test [lld][ELF] Fix the readonly section order. 2013-09-12 15:43:13 +00:00
common.test This is my Driver refactoring patch. 2013-04-04 18:59:24 +00:00
defsym.objtxt [ELF] Support --defsym=<symbol>=<symbol>. 2014-04-16 20:58:57 +00:00
dynamic-segorder.test [lld] [ELF] Support for general dynamic TLS relocations on X86_64 2014-09-29 22:05:26 +00:00
dynamic-undef.test [lld] [ELF] Support for general dynamic TLS relocations on X86_64 2014-09-29 22:05:26 +00:00
dynamic.test [ELF] Implement .{init,fini}_array ordering. 2013-10-25 23:59:06 +00:00
eh_frame_hdr.test [ELF] Implement minimal support for .eh_frame_hdr. 2013-10-30 00:02:04 +00:00
entry.objtxt Fix trailing whitespace. 2014-01-27 03:09:26 +00:00
filenotfound.test [ELF][Driver] Produce a proper error when file is not found 2014-09-08 04:18:11 +00:00
gotpcrel.test Fix trailing whitespace. 2014-01-27 03:09:26 +00:00
group-cmd-search.test [ELF] Implement parsing `-l` prefixed items in the `GROUP` linker script command. 2014-07-15 17:17:30 +00:00
hexagon-quickdata-sort.test Fix trailing whitespace. 2014-01-27 03:09:26 +00:00
hexagon-quickdata-sortcommon.test Fix trailing whitespace. 2014-01-27 03:09:26 +00:00
ifunc.test [ELF] change LayoutBefore Reference to InGroup Reference 2014-02-03 04:01:14 +00:00
ignore-unknownoption.test [Gnu] Ignore unknown arguments, and print message. 2013-11-25 04:22:11 +00:00
init_array-order.test [ELF] Fix incorrect sorting of .init_array / .fini_array sections. 2014-05-30 05:29:46 +00:00
init_array.test This is my Driver refactoring patch. 2013-04-04 18:59:24 +00:00
librarynotfound.test [lld][InputGraph] Change the Resolver to use inputGraph 2013-10-07 02:47:09 +00:00
linker-as-ld.test If lld is renamed (or symlinked) to "ld" automatically pick the right flavor. 2014-09-11 00:52:05 +00:00
mergeatoms.test Add missing triples so that these tests pass on 32 bit arch. 2014-01-09 00:07:20 +00:00
mergeconstants.test [ELF] change LayoutBefore Reference to InGroup Reference 2014-02-03 04:01:14 +00:00
mergeglobalatoms.test [lld][LinkingContext][ELF] Allow different output file types. 2013-09-23 04:24:15 +00:00
phdr.test Linking of shared libraries for MIPS little-endian 32-bit target. 2013-12-15 12:57:28 +00:00
ppc.test Revert "r193300 - [PassManager] add ReaderWriter{Native, YAML} to the Driver" 2013-10-24 18:22:16 +00:00
quickdata.test [ELF] Fix uninitalized value. 2013-10-03 19:25:34 +00:00
reloc.test [ELF] change LayoutBefore Reference to InGroup Reference 2014-02-03 04:01:14 +00:00
responsefile.test [ELF] Support response file. 2014-03-28 19:34:34 +00:00
rodata.test This is my Driver refactoring patch. 2013-04-04 18:59:24 +00:00
rosegment.test [ELF] Implement --rosegment 2014-09-08 04:05:52 +00:00
roundtrip.test REQUIRES: debug doesn't actually do anything! 2013-12-20 22:01:26 +00:00
sections.test [ELF] Fix uninitalized value. 2013-10-03 19:25:34 +00:00
soname.test Output soname. 2013-09-14 19:53:51 +00:00
stripped-empty.test Fix handling of files without a symbol table. 2013-06-07 21:08:19 +00:00
symbols.test [ELF] Dont generate PHDR when creating dynamic libraries. 2014-02-19 23:46:13 +00:00
tls.test Fix trailing whitespace. 2014-01-27 03:09:26 +00:00
tlsAddr.test Fix trailing whitespace. 2014-01-27 03:09:26 +00:00
undef-from-dso-to-main.test Re-commit r218259. 2014-09-22 20:48:04 +00:00
undef-from-main-dso.test [lld] [ELF] Support for general dynamic TLS relocations on X86_64 2014-09-29 22:05:26 +00:00
weaksym.test A weak reference to a symbol that is only weakly referenced in 2013-09-03 12:06:33 +00:00
x86-64-dynamic-relocs.test [lld][LinkingContext][ELF] Allow different output file types. 2013-09-23 04:24:15 +00:00
x86-64-dynamic.test [ELF] Refactor x86-64 relocation pass. 2013-10-24 22:46:48 +00:00
x86.test [lld][LinkingContext][ELF] Allow different output file types. 2013-09-23 04:24:15 +00:00
x86_64-kinds.test [lld][LinkingContext][ELF] Allow different output file types. 2013-09-23 04:24:15 +00:00