# Conditions: # a) Linking a shared library. # b) There ars multiple R_MIPS_64 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 mips64el -shared -o %t1.so %t-so.o # RUN: yaml2obj -format=elf -docnum 2 %s > %t-o.o # RUN: lld -flavor gnu -target mips64el -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/R_MIPS_64/R_MIPS_NONE T0 0x0 # CHECK-NEXT: 0x2000 R_MIPS_REL32/R_MIPS_64/R_MIPS_NONE T4 0x0 # CHECK-NEXT: 0x2000 R_MIPS_REL32/R_MIPS_64/R_MIPS_NONE D2 0x0 # CHECK-NEXT: 0x2004 R_MIPS_REL32/R_MIPS_64/R_MIPS_NONE T1 0x0 # CHECK-NEXT: 0x2008 R_MIPS_REL32/R_MIPS_64/R_MIPS_NONE T2 0x0 # CHECK-NEXT: 0x2004 R_MIPS_REL32/R_MIPS_64/R_MIPS_NONE D0 0x0 # CHECK-NEXT: 0x2008 R_MIPS_REL32/R_MIPS_64/R_MIPS_NONE D1 0x0 # CHECK-NEXT: 0x2004 R_MIPS_REL32/R_MIPS_64/R_MIPS_NONE D4 0x0 # CHECK-NEXT: 0x2008 R_MIPS_REL32/R_MIPS_64/R_MIPS_NONE 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: 0x324 # 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: 0x1010 # GOT-NEXT: Access: -32736 # GOT-NEXT: Initial: 0x324 # GOT-NEXT: Value: 0x324 # GOT-NEXT: Type: Function (0x2) # GOT-NEXT: Section: .text (0x5) # GOT-NEXT: Name: T0@ (1) # GOT-NEXT: } # GOT-NEXT: Entry { # GOT-NEXT: Address: 0x1018 # GOT-NEXT: Access: -32728 # 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: 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: D2@ (25) # GOT-NEXT: } # GOT-NEXT: Entry { # GOT-NEXT: Address: 0x1028 # GOT-NEXT: Access: -32712 # 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: 0x1030 # GOT-NEXT: Access: -32704 # 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: 0x1038 # GOT-NEXT: Access: -32696 # 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: 0x1040 # GOT-NEXT: Access: -32688 # 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: 0x1048 # GOT-NEXT: Access: -32680 # 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: 0x1050 # GOT-NEXT: Access: -32672 # 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: ELFCLASS64 Data: ELFDATA2LSB Type: ET_REL Machine: EM_MIPS Flags: [EF_MIPS_NOREORDER, EF_MIPS_PIC, EF_MIPS_CPIC, EF_MIPS_ARCH_64] 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: ELFCLASS64 Data: ELFDATA2LSB Type: ET_REL Machine: EM_MIPS Flags: [EF_MIPS_NOREORDER, EF_MIPS_PIC, EF_MIPS_CPIC, EF_MIPS_ARCH_64] 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.data Type: SHT_RELA Info: .data AddressAlign: 4 Relocations: - Offset: 0x00 # T0 is a defined function Symbol: T0 Type: R_MIPS_64 - Offset: 0x04 # T1 is a function from shared lib Symbol: T1 Type: R_MIPS_64 - Offset: 0x08 # T2 has unknown type and defined in shared lib Symbol: T2 Type: R_MIPS_64 - Offset: 0x00 # T4 is an undefined function Symbol: T4 Type: R_MIPS_64 - Offset: 0x04 # D0 is a defined data object Symbol: D0 Type: R_MIPS_64 - Offset: 0x08 # D1 is a data object from shared lib Symbol: D1 Type: R_MIPS_64 - Offset: 0x00 # D2 has unknown type and defined in shared lib Symbol: D2 Type: R_MIPS_64 - Offset: 0x04 # D4 is an undefined data object Symbol: D4 Type: R_MIPS_64 - Offset: 0x08 # U1 is undefined and has unknown type Symbol: U1 Type: R_MIPS_64 Symbols: Local: - Name: LT0 Section: .text Type: STT_FUNC Value: 0 Size: 4 - Name: LD0 Section: .data Type: STT_OBJECT Value: 0 Size: 4 Global: - 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 ...