forked from OSchip/llvm-project
130 lines
4.2 KiB
Plaintext
130 lines
4.2 KiB
Plaintext
# This test exercises a simple general dynamic TLS access model in X86_64.
|
|
#
|
|
# It is composed of two parts: a program and a shared library. The shared
|
|
# library uses TLS, but the program does not.
|
|
#
|
|
# The shared library should import __tls_get_addr, since it uses the general
|
|
# dynamic TLS access mode (see www.akkadia.org/drepper/tls.pdf). Notice that
|
|
# once we support TLS strength reduction, this test should be updated, since
|
|
# this can be converted into a local dynamic TLS model.
|
|
|
|
# Prepare inputs
|
|
#RUN: yaml2obj -format=elf %p/Inputs/generaltls-so.o.yaml -o=%t.o.so
|
|
#RUN: lld -flavor gnu -target x86_64 -shared %t.o.so -o %T/libgeneraltls.so
|
|
#RUN: yaml2obj -format=elf %s -o=%t.o
|
|
|
|
# Link - (we supply --defsym=__tls_get_addr to avoid the need to link with
|
|
# system libraries)
|
|
#RUN: lld -flavor gnu -target x86_64 -e main %t.o -L%T -lgeneraltls -o %t1 \
|
|
#RUN: --defsym=__tls_get_addr=0
|
|
|
|
# Check
|
|
#RUN: llvm-readobj -dyn-symbols %t1 | FileCheck -check-prefix CHECKPROG %s
|
|
#RUN: llvm-readobj -relocations -dyn-symbols %T/libgeneraltls.so | FileCheck \
|
|
#RUN: -check-prefix CHECKDSO %s
|
|
|
|
# Test case generated with the following code:
|
|
#
|
|
# DSO: (file %p/Inputs/generaltls-so.o.yaml)
|
|
#
|
|
# __thread int mynumber=33;
|
|
#
|
|
# int getnumber() {
|
|
# return mynumber;
|
|
# }
|
|
#
|
|
# Program: (this file). Note: The printf() relocation was removed to simplify
|
|
# this test and allow us to test this without libc.
|
|
#
|
|
# #include <stdio.h>
|
|
# int getnumber();
|
|
#
|
|
# int main() {
|
|
# printf("getnumber() = %d\n", getnumber());
|
|
# return 0;
|
|
# }
|
|
#
|
|
---
|
|
FileHeader:
|
|
Class: ELFCLASS64
|
|
Data: ELFDATA2LSB
|
|
OSABI: ELFOSABI_GNU
|
|
Type: ET_REL
|
|
Machine: EM_X86_64
|
|
Sections:
|
|
- Name: .text
|
|
Type: SHT_PROGBITS
|
|
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
|
|
AddressAlign: 0x0000000000000010
|
|
Content: 554889E54883EC10C745FC00000000B000E80000000048BF000000000000000089C6B000E80000000031F68945F889F04883C4105DC3
|
|
- Name: .rela.text
|
|
Type: SHT_RELA
|
|
Link: .symtab
|
|
AddressAlign: 0x0000000000000008
|
|
Info: .text
|
|
Relocations:
|
|
- Offset: 0x0000000000000012
|
|
Symbol: getnumber
|
|
Type: R_X86_64_PC32
|
|
Addend: -4
|
|
- Offset: 0x0000000000000018
|
|
Symbol: .rodata.str1.1
|
|
Type: R_X86_64_64
|
|
Addend: 0
|
|
- Name: .data
|
|
Type: SHT_PROGBITS
|
|
Flags: [ SHF_WRITE, SHF_ALLOC ]
|
|
AddressAlign: 0x0000000000000004
|
|
Content: ''
|
|
- Name: .bss
|
|
Type: SHT_NOBITS
|
|
Flags: [ SHF_WRITE, SHF_ALLOC ]
|
|
AddressAlign: 0x0000000000000004
|
|
Content: ''
|
|
- Name: .rodata.str1.1
|
|
Type: SHT_PROGBITS
|
|
Flags: [ SHF_ALLOC, SHF_MERGE, SHF_STRINGS ]
|
|
AddressAlign: 0x0000000000000001
|
|
Content: 6765746E756D6265722829203D2025640A00
|
|
Symbols:
|
|
Local:
|
|
- Name: .text
|
|
Type: STT_SECTION
|
|
Section: .text
|
|
- Name: .data
|
|
Type: STT_SECTION
|
|
Section: .data
|
|
- Name: .bss
|
|
Type: STT_SECTION
|
|
Section: .bss
|
|
- Name: .rodata.str1.1
|
|
Type: STT_SECTION
|
|
Section: .rodata.str1.1
|
|
Global:
|
|
- Name: main
|
|
Type: STT_FUNC
|
|
Section: .text
|
|
Size: 0x0000000000000036
|
|
- Name: getnumber
|
|
|
|
# Program should import the function defined in the shared library
|
|
#CHECKPROG: getnumber@
|
|
# Program should not import __tls_get_addr, since it does not directly use TLS
|
|
#CHECKPROG-NOT: __tls_get_addr@
|
|
|
|
# Check for the presence of X86_64 TLS relocations in the shared library
|
|
#CHECKDSO: R_X86_64_DTPMOD64
|
|
#CHECKDSO: R_X86_64_DTPOFF64
|
|
#CHECKDSO: R_X86_64_JUMP_SLOT
|
|
|
|
# The shared library should import __tls_get_addr, since it uses the general
|
|
# dynamic TLS access mode.
|
|
#CHECKDSO: Name: __tls_get_addr@
|
|
#CHECKDSO-NEXT: Value: 0x0
|
|
#CHECKDSO-NEXT: Size: 0
|
|
#CHECKDSO-NEXT: Binding: Global
|
|
#CHECKDSO-NEXT: Type: None
|
|
#CHECKDSO-NEXT: Other: 0
|
|
#CHECKDSO-NEXT: Section: Undefined
|
|
|