1# REQUIRES: mips 2 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: 7 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 17 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 22 23# RELOCS: Section ({{.+}}) .rel.dyn { 24# RELOCS-NEXT: 0x20018 R_MIPS_TLS_DTPMOD64/R_MIPS_NONE/R_MIPS_NONE 25# RELOCS-NEXT: } 26 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: 31# 32# _Thread_local int x; 33# int foo() { return x; } 34# 35 .text 36 .globl foo 37 .p2align 3 38 .type foo,@function 39 .ent foo 40foo: 41 lui $1, %hi(%neg(%gp_rel(foo))) 42 daddu $1, $1, $25 43 daddiu $gp, $1, %lo(%neg(%gp_rel(foo))) 44 ld $25, %call16(__tls_get_addr)($gp) 45 jalr $25 46 daddiu $4, $gp, %tlsgd(x) 47 .end foo 48 49 .type x,@object 50 .section .tbss,"awT",@nobits 51 .globl x 52 .p2align 2 53x: 54 .4byte 0 55 .size x, 4 56