llvm-project/lld/test/elf/X86_64
Adhemerval Zanella b19f5cfee6 [ELF/x86_64] Fix initial-exec TLS access
Current approach for initial-exec in ELF/x86_64 is to create a GOT entry
and change the relocation to R_X86_64_PC32 to be handled as a GOT offfset.
However there are two issues with this approach: 1. the R_X86_64_PC32 is
not really required since the GOT relocation will be handle dynamically and
2. the TLS symbols are not being exported externally and then correct
realocation are not being applied.

This patch fixes the R_X86_64_GOTTPOFF handling by just emitting a
R_X86_64_TPOFF64 dynamically one; it also sets R_X86_64_TPOFF64 to be
handled by runtime one.  For second part, the patches uses a similar
strategy used for aarch64, by reimplementing buildDynamicSymbolTable
from X86_64ExecutableWriter and adding the TLS symbols in the dynamic
symbol table.

Some tests had to be adjusted due the now missing R_X86_64_PC32 relocation.
With this test the simple testcase:

* t1.c:

__thread int t0;
__thread int t1;
__thread int t2;
__thread int t3;

* t0.c:

extern __thread int t0;
extern __thread int t1;
extern __thread int t2;
extern __thread int t3;

__thread int t4;
__thread int t5;
__thread int t6;
__thread int t7;

int main ()
{
  t0 = 1;
  t1 = 2;
  t2 = 3;
  t3 = 4;

  t4 = 5;
  t5 = 6;
  t6 = 7;
  t7 = 8;

  printf ("%i %i %i %i\n", t0, t1, t2, t3);
  printf ("%i %i %i %i\n", t4, t5, t6, t7);

  return 0;
}

Shows correct output for x86_64.

llvm-svn: 239908
2015-06-17 14:00:12 +00:00
..
ExampleTarget Add Example Sub Target. 2015-02-26 00:48:10 +00:00
Inputs [ELF] Implement demangle. 2014-10-20 05:04:53 +00:00
alignoffset.test [ELF] Fix creation of segments. 2014-11-30 04:01:14 +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
demangle.test XFAIL elf/demangle.test on Windows. 2014-11-07 01:30:49 +00:00
dontignorezerosize-sections.test Fix trailing whitespace. 2014-01-27 03:09:26 +00:00
dynamicvars.test [ELF] Check linker created dynamic variables 2014-11-13 03:25:34 +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 [ELF/x86_64] Fix initial-exec TLS access 2015-06-17 14:00:12 +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
imagebase.test [Gnu] Support --image-base option 2014-11-10 14:55:21 +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
maxpagesize.test [ELF] Fix conditions for max-page-size. 2014-11-13 04:03:46 +00:00
mergesimilarstrings.test [ELF] Fix References being ignored. 2015-02-21 04:42:43 +00:00
multi-weak-layout.test YAML: Do not use 2^x notation to represent alignments. 2015-03-25 22:06:04 +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
noalignsegments.test [ELF] Support --no-align-segments. 2014-11-08 03:44:49 +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 [ELF] Mark linker defined symbols as .hidden when needed. 2015-05-01 00:07:11 +00:00
outputsegments.test Fix spelling. 2015-01-23 23:39:33 +00:00
reloc_r_x86_64_16.test [ELF][X86_64] R_X86_64_16 relocation support 2015-02-22 23:32:34 +00:00
reloc_r_x86_64_pc16.test [ELF] Implement R_X86_64_PC16 relocation. 2015-03-03 07:38:20 +00:00
reloc_r_x86_64_pc64.test [ELF][X86_64] Handle R_X86_64_PC64 relocation 2015-02-25 05:56:05 +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 YAML: Do not use 2^x notation to represent alignments. 2015-03-25 22:06:04 +00:00
weaksym.test [ELF] Fix inclusion of weak symbols in the dynamic symbol table 2014-10-08 22:38:10 +00:00
yamlinput.test [ELF] .dynamic should have SHT_DYNAMIC flag 2014-11-10 14:54:53 +00:00