2018-06-06 21:56:51 +08:00
|
|
|
// REQUIRES: x86
|
2016-05-05 04:06:49 +08:00
|
|
|
// RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %s -o %t.o
|
|
|
|
// RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %p/Inputs/tls-opt-iele-i686-nopic.s -o %tso.o
|
2019-08-01 17:25:34 +08:00
|
|
|
// RUN: ld.lld -shared -soname=t.so %tso.o -o %tso
|
2019-08-20 16:43:47 +08:00
|
|
|
// RUN: ld.lld -shared %t.o %tso -o %t1
|
2019-05-01 13:49:01 +08:00
|
|
|
// RUN: llvm-readobj -S -r -d %t1 | FileCheck --check-prefix=GOTRELSHARED %s
|
2019-08-01 17:25:34 +08:00
|
|
|
// RUN: llvm-objdump -d --no-show-raw-insn %t1 | FileCheck --check-prefix=DISASMSHARED %s
|
2016-05-05 04:06:49 +08:00
|
|
|
|
|
|
|
// GOTRELSHARED: Section {
|
|
|
|
// GOTRELSHARED: Name: .got
|
|
|
|
// GOTRELSHARED-NEXT: Type: SHT_PROGBITS
|
|
|
|
// GOTRELSHARED-NEXT: Flags [
|
|
|
|
// GOTRELSHARED-NEXT: SHF_ALLOC
|
|
|
|
// GOTRELSHARED-NEXT: SHF_WRITE
|
|
|
|
// GOTRELSHARED-NEXT: ]
|
2019-08-20 16:43:47 +08:00
|
|
|
// GOTRELSHARED-NEXT: Address: 0x3388
|
|
|
|
// GOTRELSHARED-NEXT: Offset: 0x388
|
2016-05-05 04:06:49 +08:00
|
|
|
// GOTRELSHARED-NEXT: Size: 16
|
|
|
|
// GOTRELSHARED-NEXT: Link: 0
|
|
|
|
// GOTRELSHARED-NEXT: Info: 0
|
|
|
|
// GOTRELSHARED-NEXT: AddressAlignment: 4
|
|
|
|
// GOTRELSHARED-NEXT: EntrySize: 0
|
|
|
|
// GOTRELSHARED-NEXT: }
|
2020-03-04 11:49:14 +08:00
|
|
|
// GOTRELSHARED: 0x6FFFFFFA RELCOUNT 8
|
2016-05-05 04:06:49 +08:00
|
|
|
// GOTRELSHARED: Relocations [
|
|
|
|
// GOTRELSHARED-NEXT: Section ({{.*}}) .rel.dyn {
|
2020-12-10 21:12:26 +08:00
|
|
|
// GOTRELSHARED-NEXT: 0x22DA R_386_RELATIVE -
|
|
|
|
// GOTRELSHARED-NEXT: 0x22E2 R_386_RELATIVE -
|
|
|
|
// GOTRELSHARED-NEXT: 0x22EB R_386_RELATIVE -
|
|
|
|
// GOTRELSHARED-NEXT: 0x22F4 R_386_RELATIVE -
|
|
|
|
// GOTRELSHARED-NEXT: 0x22FC R_386_RELATIVE -
|
|
|
|
// GOTRELSHARED-NEXT: 0x2305 R_386_RELATIVE -
|
|
|
|
// GOTRELSHARED-NEXT: 0x230E R_386_RELATIVE -
|
|
|
|
// GOTRELSHARED-NEXT: 0x2317 R_386_RELATIVE -
|
|
|
|
// GOTRELSHARED-NEXT: 0x3390 R_386_TLS_TPOFF tlsshared0
|
|
|
|
// GOTRELSHARED-NEXT: 0x3394 R_386_TLS_TPOFF tlsshared1
|
|
|
|
// GOTRELSHARED-NEXT: 0x3388 R_386_TLS_TPOFF tlslocal0
|
|
|
|
// GOTRELSHARED-NEXT: 0x338C R_386_TLS_TPOFF tlslocal1
|
2016-05-05 04:06:49 +08:00
|
|
|
// GOTRELSHARED-NEXT: }
|
|
|
|
// GOTRELSHARED-NEXT: ]
|
|
|
|
|
2016-05-05 04:25:19 +08:00
|
|
|
// DISASMSHARED: Disassembly of section test:
|
2019-05-01 18:40:48 +08:00
|
|
|
// DISASMSHARED-EMPTY:
|
2020-03-06 06:18:38 +08:00
|
|
|
// DISASMSHARED-NEXT: <_start>:
|
2019-08-20 16:43:47 +08:00
|
|
|
// (.got)[0] = 0x3388 = 13192
|
|
|
|
// (.got)[1] = 13196
|
|
|
|
// (.got)[2] = 13200
|
|
|
|
// (.got)[3] = 13204
|
|
|
|
// DISASMSHARED-NEXT: 22d8: movl 13192, %ecx
|
|
|
|
// DISASMSHARED-NEXT: 22de: movl %gs:(%ecx), %eax
|
|
|
|
// DISASMSHARED-NEXT: 22e1: movl 13192, %eax
|
|
|
|
// DISASMSHARED-NEXT: 22e6: movl %gs:(%eax), %eax
|
|
|
|
// DISASMSHARED-NEXT: 22e9: addl 13192, %ecx
|
|
|
|
// DISASMSHARED-NEXT: 22ef: movl %gs:(%ecx), %eax
|
|
|
|
// DISASMSHARED-NEXT: 22f2: movl 13196, %ecx
|
|
|
|
// DISASMSHARED-NEXT: 22f8: movl %gs:(%ecx), %eax
|
|
|
|
// DISASMSHARED-NEXT: 22fb: movl 13196, %eax
|
|
|
|
// DISASMSHARED-NEXT: 2300: movl %gs:(%eax), %eax
|
|
|
|
// DISASMSHARED-NEXT: 2303: addl 13196, %ecx
|
|
|
|
// DISASMSHARED-NEXT: 2309: movl %gs:(%ecx), %eax
|
|
|
|
// DISASMSHARED-NEXT: 230c: movl 13200, %ecx
|
|
|
|
// DISASMSHARED-NEXT: 2312: movl %gs:(%ecx), %eax
|
|
|
|
// DISASMSHARED-NEXT: 2315: addl 13204, %ecx
|
|
|
|
// DISASMSHARED-NEXT: 231b: movl %gs:(%ecx), %eax
|
2016-05-05 04:06:49 +08:00
|
|
|
|
|
|
|
.type tlslocal0,@object
|
|
|
|
.section .tbss,"awT",@nobits
|
|
|
|
.globl tlslocal0
|
|
|
|
.align 4
|
|
|
|
tlslocal0:
|
|
|
|
.long 0
|
|
|
|
.size tlslocal0, 4
|
|
|
|
|
|
|
|
.type tlslocal1,@object
|
|
|
|
.section .tbss,"awT",@nobits
|
|
|
|
.globl tlslocal1
|
|
|
|
.align 4
|
|
|
|
tlslocal1:
|
|
|
|
.long 0
|
|
|
|
.size tlslocal1, 4
|
|
|
|
|
|
|
|
.section .text
|
|
|
|
.globl ___tls_get_addr
|
|
|
|
.type ___tls_get_addr,@function
|
|
|
|
___tls_get_addr:
|
|
|
|
|
2016-05-05 04:25:19 +08:00
|
|
|
.section test, "axw"
|
2016-05-05 04:06:49 +08:00
|
|
|
.globl _start
|
|
|
|
_start:
|
|
|
|
movl tlslocal0@indntpoff,%ecx
|
|
|
|
movl %gs:(%ecx),%eax
|
|
|
|
|
|
|
|
movl tlslocal0@indntpoff,%eax
|
|
|
|
movl %gs:(%eax),%eax
|
|
|
|
|
|
|
|
addl tlslocal0@indntpoff,%ecx
|
|
|
|
movl %gs:(%ecx),%eax
|
|
|
|
|
|
|
|
movl tlslocal1@indntpoff,%ecx
|
|
|
|
movl %gs:(%ecx),%eax
|
|
|
|
|
|
|
|
movl tlslocal1@indntpoff,%eax
|
|
|
|
movl %gs:(%eax),%eax
|
|
|
|
|
|
|
|
addl tlslocal1@indntpoff,%ecx
|
|
|
|
movl %gs:(%ecx),%eax
|
|
|
|
|
|
|
|
movl tlsshared0@indntpoff,%ecx
|
|
|
|
movl %gs:(%ecx),%eax
|
|
|
|
|
|
|
|
addl tlsshared1@indntpoff,%ecx
|
|
|
|
movl %gs:(%ecx),%eax
|