llvm-project/lld/test/elf/Mips/rel-dynamic-07.test

277 lines
6.8 KiB
Plaintext

# Conditions:
# a) Linking a shared library.
# b) There ars multiple R_MIPS_32 relocations with various targets.
# Check:
# a) Emitting of R_MIPS_REL32 relocations.
# b) There should be no R_MIPS_REL32 relocations for the _gp_disp symbol.
#
# RUN: yaml2obj -format=elf -docnum 1 %s > %t-so.o
# RUN: lld -flavor gnu -target mipsel -shared -o %t1.so %t-so.o
# RUN: yaml2obj -format=elf -docnum 2 %s > %t-o.o
# RUN: lld -flavor gnu -target mipsel -shared --noinhibit-exec \
# RUN: -o %t2.so %t-o.o %t1.so
# RUN: llvm-readobj -dt -r -sections %t2.so | FileCheck %s
# CHECK: Sections [
# CHECK: Section {
# CHECK-NOT: Name: .plt ({{[0-9]+}})
# CHECK: Relocations [
# CHECK-NEXT: Section (4) .rel.dyn {
# CHECK-NEXT: 0x2000 R_MIPS_REL32 T0 0x0
# CHECK-NEXT: 0x2000 R_MIPS_REL32 T4 0x0
# CHECK-NEXT: 0x2000 R_MIPS_REL32 D2 0x0
# CHECK-NEXT: 0x2004 R_MIPS_REL32 T1 0x0
# CHECK-NEXT: 0x2008 R_MIPS_REL32 T2 0x0
# CHECK-NEXT: 0x2004 R_MIPS_REL32 D0 0x0
# CHECK-NEXT: 0x2008 R_MIPS_REL32 D1 0x0
# CHECK-NEXT: 0x2004 R_MIPS_REL32 D4 0x0
# CHECK-NEXT: 0x2008 R_MIPS_REL32 U1 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: T0@ (1)
# CHECK-NEXT: Value: 0x224
# CHECK-NEXT: Size: 8
# CHECK-NEXT: Binding: Global (0x1)
# CHECK-NEXT: Type: Function (0x2)
# CHECK-NEXT: Other: 0
# CHECK-NEXT: Section: .text (0x5)
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Name: T4@ (7)
# CHECK-NEXT: Value: 0x0
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Global (0x1)
# CHECK-NEXT: Type: None (0x0)
# CHECK-NEXT: Other: 0
# CHECK-NEXT: Section: Undefined (0x0)
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Name: D2@ (25)
# 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@ (16)
# 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@ (19)
# 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: D0@ (4)
# CHECK-NEXT: Value: 0x2004
# CHECK-NEXT: Size: 8
# CHECK-NEXT: Binding: Global (0x1)
# CHECK-NEXT: Type: Object (0x1)
# CHECK-NEXT: Other: 0
# CHECK-NEXT: Section: .data (0x8)
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Name: D1@ (22)
# 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: D4@ (10)
# CHECK-NEXT: Value: 0x0
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Global (0x1)
# CHECK-NEXT: Type: None (0x0)
# CHECK-NEXT: Other: 0
# CHECK-NEXT: Section: Undefined (0x0)
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Name: U1@ (13)
# CHECK-NEXT: Value: 0x0
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Global (0x1)
# CHECK-NEXT: Type: None (0x0)
# CHECK-NEXT: Other: 0
# CHECK-NEXT: Section: Undefined (0x0)
# CHECK-NEXT: }
# CHECK-NEXT: ]
# so.o
---
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_MIPS
Flags: [EF_MIPS_PIC, EF_MIPS_CPIC]
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_PIC, EF_MIPS_CPIC]
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_MIPS_HI16
- Offset: 0x00
Symbol: _gp_disp
Type: R_MIPS_LO16
- Name: .rel.data
Type: SHT_REL
Info: .data
AddressAlign: 4
Relocations:
- 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
- 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
- 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