]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/ELF/mips-tls-64-pic-local-variable.s
Vendor import of lld trunk r338150:
[FreeBSD/FreeBSD.git] / test / ELF / mips-tls-64-pic-local-variable.s
1 # REQUIRES: mips
2 # MIPS TLS variables that are marked as local by a version script were previously
3 # writing values to the GOT that caused runtime crashes. This was happending when
4 # linking jemalloc_tsd.c in FreeBSD libc. Check that we do the right thing now:
5
6 # RUN: llvm-mc -filetype=obj -triple=mips64-unknown-freebsd %s -o %t.o
7 # RUN: echo "{ global: foo; local: *; };" > %t.script
8 # RUN: ld.lld --version-script %t.script -shared %t.o -o %t.so
9 # RUN: llvm-objdump --section=.got -s %t.so | FileCheck %s -check-prefix GOT
10 # RUN: llvm-readobj -r %t.so | FileCheck %s -check-prefix RELOCS
11
12 # GOT:        Contents of section .got:
13 # GOT-NEXT:   20000 00000000 00000000 80000000 00000000
14 # GOT-NEXT:   20010 00000000 00000000 00000000 00000000
15 # GOT-NEXT:   20020 ffffffff ffff8000
16
17 # RELOCS:      Section ({{.+}}) .rel.dyn {
18 # RELOCS-NEXT:  0x20018 R_MIPS_TLS_DTPMOD64/R_MIPS_NONE/R_MIPS_NONE
19 # RELOCS-NEXT: }
20
21 # Test case generated using clang -mcpu=mips4 -target mips64-unknown-freebsd12.0 -fpic -O -G0 -EB -mabi=n64 -msoft-float -std=gnu99 -S %s -o %t.s
22 # from the following source:
23 #
24 # _Thread_local int x;
25 # int foo() { return x; }
26 #
27         .text
28         .globl  foo
29         .p2align        3
30         .type   foo,@function
31         .ent    foo
32 foo:
33         lui     $1, %hi(%neg(%gp_rel(foo)))
34         daddu   $1, $1, $25
35         daddiu  $gp, $1, %lo(%neg(%gp_rel(foo)))
36         ld      $25, %call16(__tls_get_addr)($gp)
37         jalr    $25
38         daddiu  $4, $gp, %tlsgd(x)
39         .end    foo
40
41         .type   x,@object
42         .section        .tbss,"awT",@nobits
43         .globl  x
44         .p2align        2
45 x:
46         .4byte  0
47         .size   x, 4
48
49