| # 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 old-gnu -target mipsel -shared -o %t1.so %t-so.o |
| # RUN: yaml2obj -format=elf -docnum 2 %s > %t-o.o |
| # RUN: lld -flavor old-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 |
| # RUN: llvm-readobj -mips-plt-got %t2.so | FileCheck -check-prefix=GOT %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: 0x214 |
| # 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: ] |
| |
| # GOT: Local entries [ |
| # GOT-NEXT: ] |
| # GOT-NEXT: Global entries [ |
| # GOT-NEXT: Entry { |
| # GOT-NEXT: Address: 0x1008 |
| # GOT-NEXT: Access: -32744 |
| # GOT-NEXT: Initial: 0x214 |
| # GOT-NEXT: Value: 0x214 |
| # GOT-NEXT: Type: Function (0x2) |
| # GOT-NEXT: Section: .text (0x5) |
| # GOT-NEXT: Name: T0@ (1) |
| # GOT-NEXT: } |
| # GOT-NEXT: Entry { |
| # GOT-NEXT: Address: 0x100C |
| # GOT-NEXT: Access: -32740 |
| # GOT-NEXT: Initial: 0x0 |
| # GOT-NEXT: Value: 0x0 |
| # GOT-NEXT: Type: None (0x0) |
| # GOT-NEXT: Section: Undefined (0x0) |
| # GOT-NEXT: Name: T4@ (7) |
| # GOT-NEXT: } |
| # GOT-NEXT: Entry { |
| # GOT-NEXT: Address: 0x1010 |
| # GOT-NEXT: Access: -32736 |
| # GOT-NEXT: Initial: 0x0 |
| # GOT-NEXT: Value: 0x0 |
| # GOT-NEXT: Type: Object (0x1) |
| # GOT-NEXT: Section: Undefined (0x0) |
| # GOT-NEXT: Name: D2@ (25) |
| # GOT-NEXT: } |
| # GOT-NEXT: Entry { |
| # GOT-NEXT: Address: 0x1014 |
| # GOT-NEXT: Access: -32732 |
| # GOT-NEXT: Initial: 0x0 |
| # GOT-NEXT: Value: 0x0 |
| # GOT-NEXT: Type: Function (0x2) |
| # GOT-NEXT: Section: Undefined (0x0) |
| # GOT-NEXT: Name: T1@ (16) |
| # GOT-NEXT: } |
| # GOT-NEXT: Entry { |
| # GOT-NEXT: Address: 0x1018 |
| # GOT-NEXT: Access: -32728 |
| # GOT-NEXT: Initial: 0x0 |
| # GOT-NEXT: Value: 0x0 |
| # GOT-NEXT: Type: Function (0x2) |
| # GOT-NEXT: Section: Undefined (0x0) |
| # GOT-NEXT: Name: T2@ (19) |
| # GOT-NEXT: } |
| # GOT-NEXT: Entry { |
| # GOT-NEXT: Address: 0x101C |
| # GOT-NEXT: Access: -32724 |
| # GOT-NEXT: Initial: 0x2004 |
| # GOT-NEXT: Value: 0x2004 |
| # GOT-NEXT: Type: Object (0x1) |
| # GOT-NEXT: Section: .data (0x8) |
| # GOT-NEXT: Name: D0@ (4) |
| # GOT-NEXT: } |
| # GOT-NEXT: Entry { |
| # GOT-NEXT: Address: 0x1020 |
| # GOT-NEXT: Access: -32720 |
| # GOT-NEXT: Initial: 0x0 |
| # GOT-NEXT: Value: 0x0 |
| # GOT-NEXT: Type: Object (0x1) |
| # GOT-NEXT: Section: Undefined (0x0) |
| # GOT-NEXT: Name: D1@ (22) |
| # GOT-NEXT: } |
| # GOT-NEXT: Entry { |
| # GOT-NEXT: Address: 0x1024 |
| # GOT-NEXT: Access: -32716 |
| # GOT-NEXT: Initial: 0x0 |
| # GOT-NEXT: Value: 0x0 |
| # GOT-NEXT: Type: None (0x0) |
| # GOT-NEXT: Section: Undefined (0x0) |
| # GOT-NEXT: Name: D4@ (10) |
| # GOT-NEXT: } |
| # GOT-NEXT: Entry { |
| # GOT-NEXT: Address: 0x1028 |
| # GOT-NEXT: Access: -32712 |
| # GOT-NEXT: Initial: 0x0 |
| # GOT-NEXT: Value: 0x0 |
| # GOT-NEXT: Type: None (0x0) |
| # GOT-NEXT: Section: Undefined (0x0) |
| # GOT-NEXT: Name: U1@ (13) |
| # 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_32] |
| |
| 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, EF_MIPS_ABI_O32, EF_MIPS_ARCH_32] |
| |
| 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 |