3 # MIPS TLS variables that are marked as local by a version script were
4 # previously writing values to the GOT that caused runtime crashes. This
5 # was happending when linking jemalloc_tsd.c in FreeBSD libc. Check that
6 # we do the right thing now:
8 # RUN: llvm-mc -filetype=obj -triple=mips64-unknown-freebsd %s -o %t.o
9 # RUN: echo "{ global: foo; local: *; };" > %t.script
10 # RUN: echo "SECTIONS { \
11 # RUN: . = 0x10000; .text : { *(.text) } \
12 # RUN: . = 0x20000; .got : { *(.got) } \
13 # RUN: }" > %t.script1
14 # RUN: ld.lld --version-script %t.script -script %t.script1 -shared %t.o -o %t.so
15 # RUN: llvm-objdump --section=.got -s %t.so | FileCheck %s --check-prefix GOT
16 # RUN: llvm-readobj -r %t.so | FileCheck %s -check-prefix RELOCS
18 # GOT: Contents of section .got:
19 # GOT-NEXT: 20000 00000000 00000000 80000000 00000000
20 # GOT-NEXT: 20010 00000000 00000000 00000000 00000000
21 # GOT-NEXT: 20020 ffffffff ffff8000
23 # RELOCS: Section ({{.+}}) .rel.dyn {
24 # RELOCS-NEXT: 0x20018 R_MIPS_TLS_DTPMOD64/R_MIPS_NONE/R_MIPS_NONE
27 # Test case generated using:
28 # clang -mcpu=mips4 -target mips64-unknown-freebsd12.0 \
29 # -fpic -O -G0 -EB -mabi=n64 -msoft-float -std=gnu99 -S %s -o %t.s
30 # from the following source:
32 # _Thread_local int x;
33 # int foo() { return x; }
41 lui $
1, %hi
(%neg(%gp_rel
(foo
)))
43 daddiu $gp
, $
1, %lo
(%neg(%gp_rel
(foo
)))
44 ld $
25, %call16
(__tls_get_addr
)($gp
)
46 daddiu $
4, $gp
, %tlsgd
(x
)
50 .section .tbss,"awT",@nobits