llvm-project/lld/test/elf/X86_64
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
..
Inputs [lld] [ELF] Support for general dynamic TLS relocations on X86_64 2014-09-29 22:05:26 +00:00
debug.test [ELF] Implement minimal support for .eh_frame_hdr. 2013-10-30 00:02:04 +00:00
defsym.test [ELF] Fix typo that caused a test to fail on FreeBSD. 2014-04-17 23:38:01 +00:00
dontignorezerosize-sections.test Fix trailing whitespace. 2014-01-27 03:09:26 +00:00
dynlib-nointerp-section.test This is my Driver refactoring patch. 2013-04-04 18:59:24 +00:00
dynlib-search.test [lld][InputGraph] Change the Resolver to use inputGraph 2013-10-07 02:47:09 +00:00
dynsym-weak.test [ELF] Export strong defined symbol if it coalesces away a weak symbol 2014-09-08 09:43:38 +00:00
extern-tls.test Fix trailing whitespace. 2014-01-27 03:09:26 +00:00
general-dynamic-tls.test [lld] [ELF] Support for general dynamic TLS relocations on X86_64 2014-09-29 22:05:26 +00:00
initfini-alignment.test [lld][ELF] Support non alloc sections in the Writer. 2013-09-19 20:07:01 +00:00
initfini-option.test Fix trailing whitespace. 2014-01-27 03:09:26 +00:00
initfini-order.test [lld][ELF] Support non alloc sections in the Writer. 2013-09-19 20:07:01 +00:00
initfini.test Fix trailing whitespace. 2014-01-27 03:09:26 +00:00
largebss.test Spelling corrections. 2014-03-27 22:11:58 +00:00
layoutpass-order.test Fix trailing whitespace. 2014-01-27 03:09:26 +00:00
multi-weak-layout.test [ELF] change LayoutBefore Reference to InGroup Reference 2014-02-03 04:01:14 +00:00
multi-weak-override.test [lld][LinkingContext][ELF] Allow different output file types. 2013-09-23 04:24:15 +00:00
multi-weak-syms-order.test [lld][LinkingContext][ELF] Allow different output file types. 2013-09-23 04:24:15 +00:00
nmagic.test [lld][ELF] Support non alloc sections in the Writer. 2013-09-19 20:07:01 +00:00
note-sections-ro_plus_rw.test Revert "r193300 - [PassManager] add ReaderWriter{Native, YAML} to the Driver" 2013-10-24 18:22:16 +00:00
note-sections.test [lld][ELF] Emit note sections 2013-09-04 00:51:42 +00:00
omagic.test [lld] [ELF] Support for general dynamic TLS relocations on X86_64 2014-09-29 22:05:26 +00:00
orderatoms-by-override.test [lld][LinkingContext][ELF] Allow different output file types. 2013-09-23 04:24:15 +00:00
rodata.test Fix trailing whitespace. 2014-01-27 03:09:26 +00:00
sectionchoice.test [lld][LinkingContext][ELF] Allow different output file types. 2013-09-23 04:24:15 +00:00
sectionmap.test Fix trailing whitespace. 2014-01-27 03:09:26 +00:00
startGroupEndGroup.test Fix regression introduced in r205566. 2014-05-14 17:29:27 +00:00
startGroupEndGroupWithDynlib.test Fix trailing whitespace. 2014-01-27 03:09:26 +00:00
staticlib-search.test [Gnu] Set the type of binary that lld would generate. 2013-11-25 04:14:38 +00:00
undef.test [lld] [ELF] Support for general dynamic TLS relocations on X86_64 2014-09-29 22:05:26 +00:00
underscore-end.test [lld] [ELF] Support for general dynamic TLS relocations on X86_64 2014-09-29 22:05:26 +00:00
weak-override.test [ELF] change LayoutBefore Reference to InGroup Reference 2014-02-03 04:01:14 +00:00
weak-zero-sized.test [ELF] change LayoutBefore Reference to InGroup Reference 2014-02-03 04:01:14 +00:00
yamlinput.test [ELF] Implement minimal support for .eh_frame_hdr. 2013-10-30 00:02:04 +00:00