llvm-project/lld/test/elf/Mips/tls-3.test

181 lines
5.3 KiB
Plaintext

# Check handling of R_MIPS_TLS_GOTTPREL and R_MIPS_TLS_GD relocations
# and generation of corresponding dynamic relocations R_MIPS_TLS_TPREL32,
# R_MIPS_TLS_DTPMOD32 and R_MIPS_TLS_DTPREL32 in case of executable linking.
# Create a shared library with thread symbol D1.
# RUN: yaml2obj -format=elf -docnum 1 -o %t-so.o %s
# RUN: lld -flavor gnu -target mipsel -shared -o %t.so %t-so.o
# Create executable file linked using two object files and the shared library.
# The object files defines thread symbols D0 and D2.
# RUN: yaml2obj -format=elf -docnum 2 -o %t-o1.o %s
# RUN: yaml2obj -format=elf -docnum 3 -o %t-o2.o %s
# RUN: lld -flavor gnu -target mipsel -e T0 -o %t.exe %t-o1.o %t-o2.o %t.so
# Check dynamic relocations and GOT in the executable file.
# RUN: llvm-readobj -r %t.exe | FileCheck -check-prefix=REL %s
# RUN: llvm-readobj -dynamic-table %t.exe | FileCheck -check-prefix=DYN %s
# RUN: llvm-readobj -dt %t.exe | FileCheck -check-prefix=SYM %s
# RUN: llvm-objdump -s %t.exe | FileCheck -check-prefix=GOT %s
# REL: Section (5) .rel.dyn {
# REL-NEXT: 0x402008 R_MIPS_TLS_TPREL32 D1 0x0
# REL-NEXT: 0x40200C R_MIPS_TLS_TPREL32 D2 0x0
# REL-NEXT: }
# DYN: 0x7000000A MIPS_LOCAL_GOTNO 2
# DYN: 0x70000013 MIPS_GOTSYM 0x3
# SYM: Name: D2@ (1)
# SYM: Name: D1@ (4)
# GOT: Contents of section .got:
# GOT-NEXT: 402000 00000000 00000080 00000000 00000000 ................
# so.o
---
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
OSABI: ELFOSABI_GNU
Type: ET_REL
Machine: EM_MIPS
Flags: [ EF_MIPS_NOREORDER, EF_MIPS_PIC, EF_MIPS_CPIC,
EF_MIPS_ABI_O32, EF_MIPS_ARCH_32R2 ]
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
AddressAlign: 0x04
Size: 0x04
- Name: .rel.text
Type: SHT_REL
Link: .symtab
Info: .text
AddressAlign: 0x04
Relocations:
- Offset: 0x00
Symbol: D1
Type: R_MIPS_TLS_GD
- Name: .tdata
Type: SHT_PROGBITS
Flags: [ SHF_WRITE, SHF_ALLOC, SHF_TLS ]
AddressAlign: 0x04
Size: 0x04
Symbols:
Global:
- Name: T1
Type: STT_FUNC
Section: .text
Size: 0x04
- Name: D1
Type: STT_TLS
Section: .tdata
Size: 0x04
# o1.o
---
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
OSABI: ELFOSABI_GNU
Type: ET_REL
Machine: EM_MIPS
Flags: [ EF_MIPS_NOREORDER, EF_MIPS_CPIC,
EF_MIPS_ABI_O32, EF_MIPS_ARCH_32R2 ]
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
AddressAlign: 0x04
Size: 0x08
- Name: .rel.text
Type: SHT_REL
Link: .symtab
Info: .text
AddressAlign: 0x04
Relocations:
- Offset: 0x00
Symbol: D2
Type: R_MIPS_TLS_TPREL_HI16
- Offset: 0x04
Symbol: D2
Type: R_MIPS_TLS_TPREL_LO16
- Name: .tdata
Type: SHT_PROGBITS
Flags: [ SHF_WRITE, SHF_ALLOC, SHF_TLS ]
AddressAlign: 0x04
Size: 0x04
Symbols:
Global:
- Name: T2
Type: STT_FUNC
Section: .text
Size: 0x08
- Name: D2
Type: STT_TLS
Section: .tdata
Size: 0x04
# o2.o
---
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
OSABI: ELFOSABI_GNU
Type: ET_REL
Machine: EM_MIPS
Flags: [ EF_MIPS_NOREORDER, EF_MIPS_CPIC,
EF_MIPS_ABI_O32, EF_MIPS_ARCH_32R2 ]
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
AddressAlign: 0x04
Size: 0x10
- Name: .rel.text
Type: SHT_REL
Link: .symtab
Info: .text
AddressAlign: 0x04
Relocations:
- Offset: 0x00
Symbol: D1
Type: R_MIPS_TLS_GOTTPREL
Addend: 0
- Offset: 0x04
Symbol: D0
Type: R_MIPS_TLS_TPREL_HI16
Addend: 0
- Offset: 0x08
Symbol: D0
Type: R_MIPS_TLS_TPREL_LO16
Addend: 0
- Offset: 0x0C
Symbol: D2
Type: R_MIPS_TLS_GOTTPREL
Addend: 0
- Name: .tdata
Type: SHT_PROGBITS
Flags: [ SHF_WRITE, SHF_ALLOC, SHF_TLS ]
AddressAlign: 0x04
Size: 0x04
Symbols:
Global:
- Name: D0
Type: STT_TLS
Section: .tdata
Size: 0x04
- Name: T0
Type: STT_FUNC
Section: .text
Size: 0x10
- Name: D1
Type: STT_TLS
- Name: D2
Type: STT_TLS
...