llvm-project/lld/test/elf/Mips/rel-dynamic-08-micro.test

279 lines
6.8 KiB
Plaintext

# Conditions:
# a) Linking a non-shared executable file.
# b) There ars multiple R_MIPS_32/R_MICROMIPS_HI16/R_MICROMIPS_LO16
# relocations with various targets.
# Check:
# a) Emitting of R_MIPS_REL32 relocations.
#
# RUN: yaml2obj -format=elf -docnum 1 %s > %t-so.o
# RUN: lld -flavor gnu -target mipsel -shared -o %t.so %t-so.o
# RUN: yaml2obj -format=elf -docnum 2 %s > %t-o.o
# RUN: lld -flavor gnu -target mipsel -e T0 --noinhibit-exec \
# RUN: -o %t.exe %t-o.o %t.so
# RUN: llvm-readobj -dt -r -sections %t.exe | FileCheck %s
# RUN: llvm-readobj -mips-plt-got %t.exe | FileCheck -check-prefix=GOT %s
# CHECK: Sections [
# CHECK: Section {
# CHECK-NOT: Name: .plt ({{[0-9]+}})
# CHECK: Relocations [
# CHECK-NEXT: Section (5) .rel.dyn {
# CHECK-NEXT: 0x402000 R_MIPS_REL32 D2 0x0
# CHECK-NEXT: 0x402004 R_MIPS_REL32 T1 0x0
# CHECK-NEXT: 0x402008 R_MIPS_REL32 T2 0x0
# CHECK-NEXT: 0x402008 R_MIPS_REL32 D1 0x0
# CHECK-NEXT: }
# CHECK-NEXT: ]
# CHECK: DynamicSymbols [
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Name: @ (0)
# CHECK-NEXT: Value: 0x0
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Local (0x0)
# CHECK-NEXT: Type: None (0x0)
# CHECK-NEXT: Other: 0
# CHECK-NEXT: Section: Undefined (0x0)
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Name: D2@ (10)
# CHECK-NEXT: Value: 0x0
# CHECK-NEXT: Size: 4
# CHECK-NEXT: Binding: Global (0x1)
# CHECK-NEXT: Type: Object (0x1)
# CHECK-NEXT: Other: 0
# CHECK-NEXT: Section: Undefined (0x0)
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Name: T1@ (1)
# CHECK-NEXT: Value: 0x0
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Global (0x1)
# CHECK-NEXT: Type: Function (0x2)
# CHECK-NEXT: Other: 0
# CHECK-NEXT: Section: Undefined (0x0)
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Name: T2@ (4)
# CHECK-NEXT: Value: 0x0
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Global (0x1)
# CHECK-NEXT: Type: Function (0x2)
# CHECK-NEXT: Other: 0
# CHECK-NEXT: Section: Undefined (0x0)
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Name: D1@ (7)
# CHECK-NEXT: Value: 0x0
# CHECK-NEXT: Size: 4
# CHECK-NEXT: Binding: Global (0x1)
# CHECK-NEXT: Type: Object (0x1)
# CHECK-NEXT: Other: 0
# CHECK-NEXT: Section: Undefined (0x0)
# CHECK-NEXT: }
# CHECK-NEXT: ]
# GOT: Local entries [
# GOT-NEXT: ]
# GOT-NEXT: Global entries [
# GOT-NEXT: Entry {
# GOT-NEXT: Address: 0x401008
# GOT-NEXT: Access: -32744
# GOT-NEXT: Initial: 0x0
# GOT-NEXT: Value: 0x0
# GOT-NEXT: Type: Object (0x1)
# GOT-NEXT: Section: Undefined (0x0)
# GOT-NEXT: Name: D2@ (10)
# GOT-NEXT: }
# GOT-NEXT: Entry {
# GOT-NEXT: Address: 0x40100C
# GOT-NEXT: Access: -32740
# GOT-NEXT: Initial: 0x0
# GOT-NEXT: Value: 0x0
# GOT-NEXT: Type: Function (0x2)
# GOT-NEXT: Section: Undefined (0x0)
# GOT-NEXT: Name: T1@ (1)
# GOT-NEXT: }
# GOT-NEXT: Entry {
# GOT-NEXT: Address: 0x401010
# GOT-NEXT: Access: -32736
# GOT-NEXT: Initial: 0x0
# GOT-NEXT: Value: 0x0
# GOT-NEXT: Type: Function (0x2)
# GOT-NEXT: Section: Undefined (0x0)
# GOT-NEXT: Name: T2@ (4)
# GOT-NEXT: }
# GOT-NEXT: Entry {
# GOT-NEXT: Address: 0x401014
# GOT-NEXT: Access: -32732
# GOT-NEXT: Initial: 0x0
# GOT-NEXT: Value: 0x0
# GOT-NEXT: Type: Object (0x1)
# GOT-NEXT: Section: Undefined (0x0)
# GOT-NEXT: Name: D1@ (7)
# GOT-NEXT: }
# GOT-NEXT: ]
# so.o
---
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_MIPS
Flags: [ EF_MIPS_PIC, EF_MIPS_CPIC, EF_MIPS_ABI_O32, EF_MIPS_ARCH_32R2 ]
Sections:
- Name: .text
Type: SHT_PROGBITS
Size: 0x0C
AddressAlign: 16
Flags: [SHF_EXECINSTR, SHF_ALLOC]
- Name: .data
Type: SHT_PROGBITS
Size: 0x08
AddressAlign: 16
Flags: [SHF_WRITE, SHF_ALLOC]
Symbols:
Global:
- Name: T1
Section: .text
Type: STT_FUNC
Value: 0x0
Size: 4
- Name: T2
Section: .text
Type: STT_FUNC
Value: 0x4
Size: 4
- Name: D1
Section: .data
Type: STT_OBJECT
Value: 0x0
Size: 4
- Name: D2
Section: .data
Type: STT_OBJECT
Value: 0x4
Size: 4
# o.o
---
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_MIPS
Flags: [ EF_MIPS_CPIC, EF_MIPS_ABI_O32,
EF_MIPS_ARCH_32R2, EF_MIPS_MICROMIPS ]
Sections:
- Name: .text
Type: SHT_PROGBITS
Size: 0x0C
AddressAlign: 16
Flags: [SHF_EXECINSTR, SHF_ALLOC]
- Name: .data
Type: SHT_PROGBITS
Size: 0x0C
AddressAlign: 16
Flags: [SHF_WRITE, SHF_ALLOC]
- Name: .rel.text
Type: SHT_REL
Info: .text
AddressAlign: 4
Relocations:
- Offset: 0x00
Symbol: _gp_disp
Type: R_MICROMIPS_HI16
- Offset: 0x00
Symbol: _gp_disp
Type: R_MICROMIPS_LO16
- Name: .rel.data
Type: SHT_REL
Info: .data
AddressAlign: 4
Relocations:
- Offset: 0x00 # LT0 is a locally defined function
Symbol: LT0
Type: R_MIPS_32
- Offset: 0x00 # LD0 is a locally defined data object
Symbol: LD0
Type: R_MIPS_32
- Offset: 0x00 # T0 is a defined function
Symbol: T0
Type: R_MIPS_32
- Offset: 0x04 # T1 is a function from shared lib
Symbol: T1
Type: R_MIPS_32
- Offset: 0x08 # T2 has unknown type and defined in shared lib
Symbol: T2
Type: R_MIPS_32
- Offset: 0x00 # T4 is an undefined function
Symbol: T4
Type: R_MIPS_32
- Offset: 0x04 # D0 is a defined data object
Symbol: D0
Type: R_MIPS_32
- Offset: 0x08 # D1 is a data object from shared lib
Symbol: D1
Type: R_MIPS_32
- Offset: 0x00 # D2 has unknown type and defined in shared lib
Symbol: D2
Type: R_MIPS_32
- Offset: 0x04 # D4 is an undefined data object
Symbol: D4
Type: R_MIPS_32
- Offset: 0x08 # U1 is undefined and has unknown type
Symbol: U1
Type: R_MIPS_32
Symbols:
Local:
- Name: LT0
Section: .text
Type: STT_FUNC
Value: 0x0
Size: 4
Other: [ STO_MIPS_MICROMIPS ]
- Name: LD0
Section: .data
Type: STT_OBJECT
Value: 0x0
Size: 4
Global:
- Name: _gp_disp
Type: STT_OBJECT
- Name: T0
Section: .text
Type: STT_FUNC
Value: 0x4
Size: 8
Other: [ STO_MIPS_MICROMIPS ]
- Name: T1
Type: STT_FUNC
- Name: T2
- Name: T4
Type: STT_FUNC
- Name: D0
Section: .data
Type: STT_OBJECT
Value: 0x4
Size: 8
- Name: D1
Type: STT_OBJECT
- Name: D2
- Name: D4
Type: STT_OBJECT
- Name: U1
...