forked from OSchip/llvm-project
5a1000dddc
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 |
||
---|---|---|
.. | ||
Inputs | ||
debug.test | ||
defsym.test | ||
dontignorezerosize-sections.test | ||
dynlib-nointerp-section.test | ||
dynlib-search.test | ||
dynsym-weak.test | ||
extern-tls.test | ||
general-dynamic-tls.test | ||
initfini-alignment.test | ||
initfini-option.test | ||
initfini-order.test | ||
initfini.test | ||
largebss.test | ||
layoutpass-order.test | ||
multi-weak-layout.test | ||
multi-weak-override.test | ||
multi-weak-syms-order.test | ||
nmagic.test | ||
note-sections-ro_plus_rw.test | ||
note-sections.test | ||
omagic.test | ||
orderatoms-by-override.test | ||
rodata.test | ||
sectionchoice.test | ||
sectionmap.test | ||
startGroupEndGroup.test | ||
startGroupEndGroupWithDynlib.test | ||
staticlib-search.test | ||
undef.test | ||
underscore-end.test | ||
weak-override.test | ||
weak-zero-sized.test | ||
yamlinput.test |