| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,194 @@ | ||
| # REQUIRES: mips | ||
|
|
||
| # Conditions: | ||
| # a) Linking a non-shared executable file. | ||
| # b) Relocations' targets are symbols defined in the shared object. | ||
| # Check: | ||
| # a) Emitting R_MIPS_REL32, R_MIPS_COPY, R_MIPS_JUMP_SLOT relocations. | ||
| # b) PLT entries creation. | ||
| # c) STO_MIPS_PLT flag in the dynamic symbol table for symbols require | ||
| # a pointer equality. | ||
| # | ||
| # RUN: yaml2obj -format=elf %S/Inputs/pic-obj.yaml > %t-so-obj | ||
| # RUN: lld -flavor gnu -target mipsel -shared -o %t-so %t-so-obj | ||
| # RUN: yaml2obj -format=elf %s > %t-obj | ||
| # RUN: lld -flavor gnu -target mipsel -e T0 -o %t1-exe %t-obj %t-so | ||
| # RUN: llvm-objdump -disassemble %t1-exe | FileCheck -check-prefix=PLT %s | ||
| # RUN: llvm-readobj -dt -r %t1-exe | FileCheck -check-prefix=PLT-SYM %s | ||
|
|
||
| # PLT: Disassembly of section .plt: | ||
| # PLT-NEXT: .plt: | ||
| # PLT-NEXT: 400210: 40 00 1c 3c lui $gp, 64 | ||
| # PLT-NEXT: 400214: 00 20 99 8f lw $25, 8192($gp) | ||
| # PLT-NEXT: 400218: 00 20 9c 27 addiu $gp, $gp, 8192 | ||
| # PLT-NEXT: 40021c: 23 c0 1c 03 subu $24, $24, $gp | ||
| # PLT-NEXT: 400220: 21 78 e0 03 move $15, $ra | ||
| # PLT-NEXT: 400224: 82 c0 18 00 srl $24, $24, 2 | ||
| # PLT-NEXT: 400228: 09 f8 20 03 jalr $25 | ||
| # PLT-NEXT: 40022c: fe ff 18 27 addiu $24, $24, -2 | ||
| # | ||
| # PLT-NEXT: 400230: 40 00 0f 3c lui $15, 64 | ||
| # PLT-NEXT: 400234: 08 20 f9 8d lw $25, 8200($15) | ||
| # PLT-NEXT: 400238: 08 00 20 03 jr $25 | ||
| # PLT-NEXT: 40023c: 08 20 f8 25 addiu $24, $15, 8200 | ||
| # | ||
| # PLT-NEXT: 400240: 40 00 0f 3c lui $15, 64 | ||
| # PLT-NEXT: 400244: 0c 20 f9 8d lw $25, 8204($15) | ||
| # PLT-NEXT: 400248: 08 00 20 03 jr $25 | ||
| # PLT-NEXT: 40024c: 0c 20 f8 25 addiu $24, $15, 8204 | ||
|
|
||
| # PLT-SYM: Relocations [ | ||
| # PLT-SYM-NEXT: Section (5) .rel.dyn { | ||
| # PLT-SYM-NEXT: 0x402014 R_MIPS_REL32 T2 0x0 | ||
| # PLT-SYM-NEXT: 0x402014 R_MIPS_REL32 D2 0x0 | ||
| # PLT-SYM-NEXT: 0x402018 R_MIPS_COPY D1 0x0 | ||
| # PLT-SYM-NEXT: } | ||
| # PLT-SYM-NEXT: Section (6) .rel.plt { | ||
| # PLT-SYM-NEXT: 0x402008 R_MIPS_JUMP_SLOT T3 0x0 | ||
| # PLT-SYM-NEXT: 0x40200C R_MIPS_JUMP_SLOT T1 0x0 | ||
| # PLT-SYM-NEXT: } | ||
| # PLT-SYM-NEXT: ] | ||
|
|
||
| # PLT-SYM: DynamicSymbols [ | ||
| # PLT-SYM-NEXT: Symbol { | ||
| # PLT-SYM-NEXT: Name: @ (0) | ||
| # PLT-SYM-NEXT: Value: 0x0 | ||
| # PLT-SYM-NEXT: Size: 0 | ||
| # PLT-SYM-NEXT: Binding: Local (0x0) | ||
| # PLT-SYM-NEXT: Type: None (0x0) | ||
| # PLT-SYM-NEXT: Other: 0 | ||
| # PLT-SYM-NEXT: Section: Undefined (0x0) | ||
| # PLT-SYM-NEXT: } | ||
| # PLT-SYM-NEXT: Symbol { | ||
| # PLT-SYM-NEXT: Name: D1@ (1) | ||
| # PLT-SYM-NEXT: Value: 0x402018 | ||
| # PLT-SYM-NEXT: Size: 4 | ||
| # PLT-SYM-NEXT: Binding: Global (0x1) | ||
| # PLT-SYM-NEXT: Type: Object (0x1) | ||
| # PLT-SYM-NEXT: Other: 0 | ||
| # PLT-SYM-NEXT: Section: .bss (0xD) | ||
| # PLT-SYM-NEXT: } | ||
| # PLT-SYM-NEXT: Symbol { | ||
| # PLT-SYM-NEXT: Name: T3@ (7) | ||
| # PLT-SYM-NEXT: Value: 0x0 | ||
| # PLT-SYM-NEXT: Size: 0 | ||
| # PLT-SYM-NEXT: Binding: Global (0x1) | ||
| # PLT-SYM-NEXT: Type: Function (0x2) | ||
| # PLT-SYM-NEXT: Other: 0 | ||
| # PLT-SYM-NEXT: Section: Undefined (0x0) | ||
| # PLT-SYM-NEXT: } | ||
| # PLT-SYM-NEXT: Symbol { | ||
| # PLT-SYM-NEXT: Name: T1@ (10) | ||
| # PLT-SYM-NEXT: Value: 0x400240 | ||
| # PLT-SYM-NEXT: Size: 0 | ||
| # PLT-SYM-NEXT: Binding: Global (0x1) | ||
| # PLT-SYM-NEXT: Type: Function (0x2) | ||
| # PLT-SYM-NEXT: Other: 8 | ||
| # PLT-SYM-NEXT: Section: Undefined (0x0) | ||
| # PLT-SYM-NEXT: } | ||
| # PLT-SYM-NEXT: Symbol { | ||
| # PLT-SYM-NEXT: Name: D1@ (1) | ||
| # PLT-SYM-NEXT: Value: 0x0 | ||
| # PLT-SYM-NEXT: Size: 4 | ||
| # PLT-SYM-NEXT: Binding: Global (0x1) | ||
| # PLT-SYM-NEXT: Type: Object (0x1) | ||
| # PLT-SYM-NEXT: Other: 0 | ||
| # PLT-SYM-NEXT: Section: Undefined (0x0) | ||
| # PLT-SYM-NEXT: } | ||
| # PLT-SYM-NEXT: Symbol { | ||
| # PLT-SYM-NEXT: Name: T2@ (4) | ||
| # PLT-SYM-NEXT: Value: 0x0 | ||
| # PLT-SYM-NEXT: Size: 0 | ||
| # PLT-SYM-NEXT: Binding: Global (0x1) | ||
| # PLT-SYM-NEXT: Type: Function (0x2) | ||
| # PLT-SYM-NEXT: Other: 0 | ||
| # PLT-SYM-NEXT: Section: Undefined (0x0) | ||
| # PLT-SYM-NEXT: } | ||
| # PLT-SYM-NEXT: Symbol { | ||
| # PLT-SYM-NEXT: Name: D2@ (13) | ||
| # PLT-SYM-NEXT: Value: 0x0 | ||
| # PLT-SYM-NEXT: Size: 4 | ||
| # PLT-SYM-NEXT: Binding: Global (0x1) | ||
| # PLT-SYM-NEXT: Type: Object (0x1) | ||
| # PLT-SYM-NEXT: Other: 0 | ||
| # PLT-SYM-NEXT: Section: Undefined (0x0) | ||
| # PLT-SYM-NEXT: } | ||
| # PLT-SYM-NEXT: ] | ||
|
|
||
| !ELF | ||
| FileHeader: !FileHeader | ||
| Class: ELFCLASS32 | ||
| Data: ELFDATA2LSB | ||
| Type: ET_REL | ||
| Machine: EM_MIPS | ||
| Flags: [EF_MIPS_CPIC] | ||
|
|
||
| Sections: | ||
| - Name: .text | ||
| Type: SHT_PROGBITS | ||
| Content: "0000000000000000" | ||
| AddressAlign: 16 | ||
| Flags: [SHF_EXECINSTR, SHF_ALLOC] | ||
|
|
||
| - Name: .data | ||
| Type: SHT_PROGBITS | ||
| Content: "0000000000000000" | ||
| AddressAlign: 16 | ||
| Flags: [SHF_WRITE, SHF_ALLOC] | ||
|
|
||
| - Name: .rel.text | ||
| Type: SHT_REL | ||
| Info: .text | ||
| AddressAlign: 4 | ||
| Relocations: | ||
| - Offset: 0x04 | ||
| Symbol: T3 | ||
| Type: R_MIPS_26 | ||
|
|
||
| - Name: .rel.data | ||
| Type: SHT_REL | ||
| Info: .data | ||
| AddressAlign: 4 | ||
| Relocations: | ||
| - Offset: 0x00 | ||
| Symbol: T1 | ||
| Type: R_MIPS_HI16 | ||
| - Offset: 0x00 | ||
| Symbol: T1 | ||
| Type: R_MIPS_LO16 | ||
| - Offset: 0x04 | ||
| Symbol: T2 | ||
| Type: R_MIPS_32 | ||
|
|
||
| - Offset: 0x04 | ||
| Symbol: D1 | ||
| Type: R_MIPS_HI16 | ||
| - Offset: 0x04 | ||
| Symbol: D1 | ||
| Type: R_MIPS_LO16 | ||
| - Offset: 0x04 | ||
| Symbol: D2 | ||
| Type: R_MIPS_32 | ||
|
|
||
| Symbols: | ||
| Global: | ||
| - Name: T0 | ||
| Section: .text | ||
| Type: STT_FUNC | ||
| Value: 0x0 | ||
| Size: 8 | ||
| - Name: T1 | ||
| Type: STT_FUNC | ||
| - Name: T2 | ||
| Type: STT_FUNC | ||
| - Name: T3 | ||
| Type: STT_FUNC | ||
| - Name: D0 | ||
| Section: .data | ||
| Type: STT_OBJECT | ||
| Value: 0x0 | ||
| Size: 8 | ||
| - Name: D1 | ||
| Type: STT_OBJECT | ||
| - Name: D2 | ||
| Type: STT_OBJECT |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| # Conditions: | ||
| # a) Linking a shared library. | ||
| # b) Relocations' targets are undefined symbols. | ||
| # Check: | ||
| # a) Emitting R_MIPS_REL32 relocations for both undefined symbols. | ||
| # b) There should be no PLT entries. | ||
| # | ||
| # RUN: yaml2obj -format=elf %s > %t-obj | ||
| # RUN: lld -flavor gnu -target mipsel -shared --noinhibit-exec -o %t1-so %t-obj | ||
| # RUN: llvm-readobj -dt -r -s %t1-so | FileCheck -check-prefix=PLT-SYM %s | ||
|
|
||
| # PLT-SYM: Sections [ | ||
| # PLT-SYM: Section { | ||
| # PLT-SYM-NOT: Name: .plt ({{[0-9]+}}) | ||
| # | ||
| # PLT-SYM: Relocations [ | ||
| # PLT-SYM-NEXT: Section (4) .rel.dyn { | ||
| # PLT-SYM-NEXT: 0x2000 R_MIPS_REL32 T1 0x0 | ||
| # PLT-SYM-NEXT: 0x140 R_MIPS_REL32 T1 0x0 | ||
| # PLT-SYM-NEXT: } | ||
| # PLT-SYM-NEXT: ] | ||
| # | ||
| # PLT-SYM: Name: T1@ (7) | ||
| # PLT-SYM-NEXT: Value: 0x0 | ||
| # PLT-SYM-NEXT: Size: 0 | ||
| # PLT-SYM-NEXT: Binding: Global (0x1) | ||
| # PLT-SYM-NEXT: Type: None (0x0) | ||
| # PLT-SYM-NEXT: Other: 0 | ||
| # PLT-SYM-NEXT: Section: Undefined (0x0) | ||
|
|
||
| !ELF | ||
| FileHeader: !FileHeader | ||
| Class: ELFCLASS32 | ||
| Data: ELFDATA2LSB | ||
| Type: ET_REL | ||
| Machine: EM_MIPS | ||
| Flags: [EF_MIPS_PIC, EF_MIPS_CPIC] | ||
|
|
||
| Sections: | ||
| - Name: .text | ||
| Type: SHT_PROGBITS | ||
| Content: "0000000000000000" | ||
| AddressAlign: 16 | ||
| Flags: [SHF_EXECINSTR, SHF_ALLOC] | ||
|
|
||
| - Name: .data | ||
| Type: SHT_PROGBITS | ||
| Content: "0000000000000000" | ||
| AddressAlign: 16 | ||
| Flags: [SHF_WRITE, SHF_ALLOC] | ||
|
|
||
| - Name: .rel.text | ||
| Type: SHT_REL | ||
| Info: .text | ||
| AddressAlign: 4 | ||
| Relocations: | ||
| - Offset: 0x00 | ||
| Symbol: T1 | ||
| Type: R_MIPS_32 | ||
|
|
||
| - Name: .rel.data | ||
| Type: SHT_REL | ||
| Info: .data | ||
| AddressAlign: 4 | ||
| Relocations: | ||
| - Offset: 0x00 | ||
| Symbol: T1 | ||
| Type: R_MIPS_32 | ||
|
|
||
| Symbols: | ||
| Global: | ||
| - Name: T0 | ||
| Section: .text | ||
| Type: STT_FUNC | ||
| Value: 0x0 | ||
| Size: 4 | ||
| - Name: T1 | ||
| - Name: D0 | ||
| Section: .data | ||
| Type: STT_OBJECT | ||
| Value: 0x0 | ||
| Size: 8 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| # REQUIRES: mips | ||
|
|
||
| # Conditions: | ||
| # a) Linking a non-shared executable file. | ||
| # b) Relocations' target is a symbol defined in the shared object. | ||
| # c) The target symbol is referenced by both branch (R_MIPS_26) | ||
| # and regular (R_MIPS_32) relocations. | ||
| # Check: | ||
| # a) There should be no R_MIPS_REL32 relocation. | ||
| # b) Linker creates a single PLT entry. | ||
| # c) STO_MIPS_PLT flag in the dynamic symbol table for symbols require | ||
| # a pointer equality. | ||
| # | ||
| # RUN: yaml2obj -format=elf %S/Inputs/pic-obj.yaml > %t-so-obj | ||
| # RUN: lld -flavor gnu -target mipsel -shared -o %t-so %t-so-obj | ||
| # RUN: yaml2obj -format=elf %s > %t-obj | ||
| # RUN: lld -flavor gnu -target mipsel -e T0 -o %t-exe %t-obj %t-so | ||
| # RUN: llvm-objdump -disassemble %t-exe | FileCheck -check-prefix=PLT %s | ||
| # RUN: llvm-readobj -dt -r %t-exe | FileCheck -check-prefix=PLT-SYM %s | ||
|
|
||
| # PLT: Disassembly of section .plt: | ||
| # PLT-NEXT: .plt: | ||
| # PLT-NEXT: 400170: 40 00 1c 3c lui $gp, 64 | ||
| # PLT-NEXT: 400174: 00 20 99 8f lw $25, 8192($gp) | ||
| # PLT-NEXT: 400178: 00 20 9c 27 addiu $gp, $gp, 8192 | ||
| # PLT-NEXT: 40017c: 23 c0 1c 03 subu $24, $24, $gp | ||
| # PLT-NEXT: 400180: 21 78 e0 03 move $15, $ra | ||
| # PLT-NEXT: 400184: 82 c0 18 00 srl $24, $24, 2 | ||
| # PLT-NEXT: 400188: 09 f8 20 03 jalr $25 | ||
| # PLT-NEXT: 40018c: fe ff 18 27 addiu $24, $24, -2 | ||
| # | ||
| # PLT-NEXT: 400190: 40 00 0f 3c lui $15, 64 | ||
| # PLT-NEXT: 400194: 08 20 f9 8d lw $25, 8200($15) | ||
| # PLT-NEXT: 400198: 08 00 20 03 jr $25 | ||
| # PLT-NEXT: 40019c: 08 20 f8 25 addiu $24, $15, 8200 | ||
| # | ||
| # PLT-SYM: Relocations [ | ||
| # PLT-SYM-NEXT: Section (5) .rel.plt { | ||
| # PLT-SYM-NEXT: 0x402008 R_MIPS_JUMP_SLOT T1 0x0 | ||
| # PLT-SYM-NEXT: } | ||
| # PLT-SYM-NEXT: ] | ||
|
|
||
| # PLT-SYM: Name: T1@ (1) | ||
| # PLT-SYM-NEXT: Value: 0x400190 | ||
| # PLT-SYM-NEXT: Size: 0 | ||
| # PLT-SYM-NEXT: Binding: Global (0x1) | ||
| # PLT-SYM-NEXT: Type: Function (0x2) | ||
| # PLT-SYM-NEXT: Other: 8 | ||
| # PLT-SYM-NEXT: Section: Undefined (0x0) | ||
|
|
||
| !ELF | ||
| FileHeader: !FileHeader | ||
| Class: ELFCLASS32 | ||
| Data: ELFDATA2LSB | ||
| Type: ET_REL | ||
| Machine: EM_MIPS | ||
| Flags: [EF_MIPS_CPIC] | ||
|
|
||
| Sections: | ||
| - Name: .text | ||
| Type: SHT_PROGBITS | ||
| Content: "0000000000000000" | ||
| AddressAlign: 16 | ||
| Flags: [SHF_EXECINSTR, SHF_ALLOC] | ||
|
|
||
| - Name: .data | ||
| Type: SHT_PROGBITS | ||
| Content: "0000000000000000" | ||
| AddressAlign: 16 | ||
| Flags: [SHF_WRITE, SHF_ALLOC] | ||
|
|
||
| - Name: .rel.text | ||
| Type: SHT_REL | ||
| Info: .text | ||
| AddressAlign: 4 | ||
| Relocations: | ||
| - Offset: 0x04 | ||
| Symbol: T1 | ||
| Type: R_MIPS_26 | ||
|
|
||
| - Name: .rel.data | ||
| Type: SHT_REL | ||
| Info: .data | ||
| AddressAlign: 4 | ||
| Relocations: | ||
| - Offset: 0x04 | ||
| Symbol: T1 | ||
| Type: R_MIPS_32 | ||
|
|
||
| Symbols: | ||
| Global: | ||
| - Name: T0 | ||
| Section: .text | ||
| Type: STT_FUNC | ||
| Value: 0x0 | ||
| Size: 8 | ||
| - Name: T1 | ||
| Type: STT_FUNC | ||
| - Name: D0 | ||
| Section: .data | ||
| Type: STT_OBJECT | ||
| Value: 0x0 | ||
| Size: 8 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,170 @@ | ||
| # Conditions: | ||
| # a) Linking a non-shared executable file. | ||
| # b) Relocations' targets are symbols defined in the shared object. | ||
| # c) Relocations modify a writable section. | ||
| # d) The first symbol is referenced by R_MIPS32 relocation only | ||
| # e) The second symbol is referenced by R_MIPS_32 and R_MIPS26 relocations. | ||
| # f) The third symbol is referenced by R_MIPS26 and R_MIPS_32 relocations. | ||
| # Check: | ||
| # a) There should be the only R_MIPS_REL32 relocation. | ||
| # b) Linker creates a couple of PLT entry for both symbols referenced | ||
| # by the R_MIPS_26 branch relocation. | ||
| # c) STO_MIPS_PLT flag in the dynamic symbol table for symbols require | ||
| # a pointer equality. | ||
| # | ||
| # RUN: yaml2obj -format=elf %S/Inputs/pic-obj.yaml > %t-so-obj | ||
| # RUN: lld -flavor gnu -target mipsel -shared -o %t-so %t-so-obj | ||
| # RUN: yaml2obj -format=elf %s > %t-obj | ||
| # RUN: lld -flavor gnu -target mipsel -e T0 -o %t1-exe %t-obj %t-so | ||
| # RUN: llvm-readobj -dt -r -s %t1-exe | FileCheck -check-prefix=PLT %s | ||
|
|
||
| # PLT: Section { | ||
| # PLT: Index: 5 | ||
| # PLT-NEXT: Name: .rel.dyn (31) | ||
| # PLT-NEXT: Type: SHT_REL (0x9) | ||
| # PLT-NEXT: Flags [ (0x2) | ||
| # PLT-NEXT: SHF_ALLOC (0x2) | ||
| # PLT-NEXT: ] | ||
| # PLT-NEXT: Address: 0x40109C | ||
| # PLT-NEXT: Offset: 0x109C | ||
| # PLT-NEXT: Size: 8 | ||
| # PLT-NEXT: Link: 3 | ||
| # PLT-NEXT: Info: 0 | ||
| # PLT-NEXT: AddressAlignment: 4 | ||
| # PLT-NEXT: EntrySize: 8 | ||
| # PLT-NEXT: } | ||
| # PLT-NEXT: Section { | ||
| # PLT-NEXT: Index: 6 | ||
| # PLT-NEXT: Name: .rel.plt (40) | ||
| # PLT-NEXT: Type: SHT_REL (0x9) | ||
| # PLT-NEXT: Flags [ (0x2) | ||
| # PLT-NEXT: SHF_ALLOC (0x2) | ||
| # PLT-NEXT: ] | ||
| # PLT-NEXT: Address: 0x4010A4 | ||
| # PLT-NEXT: Offset: 0x10A4 | ||
| # PLT-NEXT: Size: 16 | ||
| # PLT-NEXT: Link: 3 | ||
| # PLT-NEXT: Info: 0 | ||
| # PLT-NEXT: AddressAlignment: 4 | ||
| # PLT-NEXT: EntrySize: 8 | ||
| # PLT-NEXT: } | ||
| # PLT-NEXT: Section { | ||
| # PLT-NEXT: Index: 7 | ||
| # PLT-NEXT: Name: .plt (49) | ||
| # PLT-NEXT: Type: SHT_PROGBITS (0x1) | ||
| # PLT-NEXT: Flags [ (0x6) | ||
| # PLT-NEXT: SHF_ALLOC (0x2) | ||
| # PLT-NEXT: SHF_EXECINSTR (0x4) | ||
| # PLT-NEXT: ] | ||
| # PLT-NEXT: Address: 0x4010C0 | ||
| # PLT-NEXT: Offset: 0x10C0 | ||
| # PLT-NEXT: Size: 64 | ||
| # PLT-NEXT: Link: 0 | ||
| # PLT-NEXT: Info: 0 | ||
| # PLT-NEXT: AddressAlignment: 16 | ||
| # PLT-NEXT: EntrySize: 0 | ||
| # PLT-NEXT: } | ||
|
|
||
| # PLT: Relocations [ | ||
| # PLT-NEXT: Section (5) .rel.dyn { | ||
| # PLT-NEXT: 0x400120 R_MIPS_REL32 T1 0x0 | ||
| # PLT-NEXT: } | ||
| # PLT-NEXT: Section (6) .rel.plt { | ||
| # PLT-NEXT: 0x403008 R_MIPS_JUMP_SLOT T2 0x0 | ||
| # PLT-NEXT: 0x40300C R_MIPS_JUMP_SLOT T3 0x0 | ||
| # PLT-NEXT: } | ||
| # PLT-NEXT: ] | ||
|
|
||
| # PLT: DynamicSymbols [ | ||
| # PLT-NEXT: Symbol { | ||
| # PLT-NEXT: Name: @ (0) | ||
| # PLT-NEXT: Value: 0x0 | ||
| # PLT-NEXT: Size: 0 | ||
| # PLT-NEXT: Binding: Local (0x0) | ||
| # PLT-NEXT: Type: None (0x0) | ||
| # PLT-NEXT: Other: 0 | ||
| # PLT-NEXT: Section: Undefined (0x0) | ||
| # PLT-NEXT: } | ||
| # PLT-NEXT: Symbol { | ||
| # PLT-NEXT: Name: T2@ (1) | ||
| # PLT-NEXT: Value: 0x4010E0 | ||
| # PLT-NEXT: Size: 0 | ||
| # PLT-NEXT: Binding: Global (0x1) | ||
| # PLT-NEXT: Type: Function (0x2) | ||
| # PLT-NEXT: Other: 8 | ||
| # PLT-NEXT: Section: Undefined (0x0) | ||
| # PLT-NEXT: } | ||
| # PLT-NEXT: Symbol { | ||
| # PLT-NEXT: Name: T3@ (4) | ||
| # PLT-NEXT: Value: 0x4010F0 | ||
| # PLT-NEXT: Size: 0 | ||
| # PLT-NEXT: Binding: Global (0x1) | ||
| # PLT-NEXT: Type: Function (0x2) | ||
| # PLT-NEXT: Other: 8 | ||
| # PLT-NEXT: Section: Undefined (0x0) | ||
| # PLT-NEXT: } | ||
| # PLT-NEXT: Symbol { | ||
| # PLT-NEXT: Name: T1@ (7) | ||
| # PLT-NEXT: Value: 0x0 | ||
| # PLT-NEXT: Size: 0 | ||
| # PLT-NEXT: Binding: Global (0x1) | ||
| # PLT-NEXT: Type: Function (0x2) | ||
| # PLT-NEXT: Other: 0 | ||
| # PLT-NEXT: Section: Undefined (0x0) | ||
| # PLT-NEXT: } | ||
| # PLT-NEXT: ] | ||
|
|
||
| !ELF | ||
| FileHeader: !FileHeader | ||
| Class: ELFCLASS32 | ||
| Data: ELFDATA2LSB | ||
| Type: ET_REL | ||
| Machine: EM_MIPS | ||
| Flags: [EF_MIPS_CPIC] | ||
|
|
||
| Sections: | ||
| - Name: .text | ||
| Type: SHT_PROGBITS | ||
| Content: "0000000000000000" | ||
| AddressAlign: 16 | ||
| Flags: [SHF_WRITE, SHF_EXECINSTR, SHF_ALLOC] | ||
|
|
||
| - Name: .rel.text | ||
| Type: SHT_REL | ||
| Info: .text | ||
| AddressAlign: 4 | ||
| Relocations: | ||
| # There is no branch relocation for T1. | ||
| - Offset: 0x00 | ||
| Symbol: T1 | ||
| Type: R_MIPS_32 | ||
| # The R_MIPS_32 relocation for T2 might produce R_MIPS_REL32 ... | ||
| - Offset: 0x00 | ||
| Symbol: T2 | ||
| Type: R_MIPS_32 | ||
| # ... but R_MIPS_26 creates PLT entry and makes R_MIPS_REL32 redundant. | ||
| - Offset: 0x04 | ||
| Symbol: T2 | ||
| Type: R_MIPS_26 | ||
| # Create PLT entry for T3 symbol. | ||
| - Offset: 0x00 | ||
| Symbol: T3 | ||
| Type: R_MIPS_26 | ||
| # Take in account existing PLT entry and do not create R_MIPS_REL32. | ||
| - Offset: 0x04 | ||
| Symbol: T3 | ||
| Type: R_MIPS_32 | ||
|
|
||
| Symbols: | ||
| Global: | ||
| - Name: T0 | ||
| Section: .text | ||
| Type: STT_FUNC | ||
| Value: 0x0 | ||
| Size: 8 | ||
| - Name: T1 | ||
| Type: STT_FUNC | ||
| - Name: T2 | ||
| Type: STT_FUNC | ||
| - Name: T3 | ||
| Type: STT_FUNC |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,152 @@ | ||
| # Conditions: | ||
| # a) Linking a non-shared executable file. | ||
| # b) Relocations' targets are symbols defined in the shared object. | ||
| # c) Relocations modify a read-only section. | ||
| # d) The first symbol is referenced by R_MIPS32 relocation only | ||
| # e) The second symbol is referenced by R_MIPS_32 and R_MIPS26 relocations. | ||
| # f) The third symbol is referenced by R_MIPS26 and R_MIPS_32 relocations. | ||
| # Check: | ||
| # a) There should be no R_MIPS_REL32 relocations. | ||
| # b) Linker creates PLT entries for all three relocations. | ||
| # c) STO_MIPS_PLT flag in the dynamic symbol table for symbols require | ||
| # a pointer equality. | ||
| # | ||
| # RUN: yaml2obj -format=elf %S/Inputs/pic-obj.yaml > %t-so-obj | ||
| # RUN: lld -flavor gnu -target mipsel -shared -o %t-so %t-so-obj | ||
| # RUN: yaml2obj -format=elf %s > %t-obj | ||
| # RUN: lld -flavor gnu -target mipsel -e T0 -o %t1-exe %t-obj %t-so | ||
| # RUN: llvm-readobj -dt -r -s %t1-exe | FileCheck -check-prefix=PLT %s | ||
|
|
||
| # PLT: Section { | ||
| # PLT: Index: 5 | ||
| # PLT-NEXT: Name: .rel.plt (31) | ||
| # PLT-NEXT: Type: SHT_REL (0x9) | ||
| # PLT-NEXT: Flags [ (0x2) | ||
| # PLT-NEXT: SHF_ALLOC (0x2) | ||
| # PLT-NEXT: ] | ||
| # PLT-NEXT: Address: 0x40019C | ||
| # PLT-NEXT: Offset: 0x19C | ||
| # PLT-NEXT: Size: 24 | ||
| # PLT-NEXT: Link: 3 | ||
| # PLT-NEXT: Info: 0 | ||
| # PLT-NEXT: AddressAlignment: 4 | ||
| # PLT-NEXT: EntrySize: 8 | ||
| # PLT-NEXT: } | ||
| # PLT-NEXT: Section { | ||
| # PLT-NEXT: Index: 6 | ||
| # PLT-NEXT: Name: .plt (40) | ||
| # PLT-NEXT: Type: SHT_PROGBITS (0x1) | ||
| # PLT-NEXT: Flags [ (0x6) | ||
| # PLT-NEXT: SHF_ALLOC (0x2) | ||
| # PLT-NEXT: SHF_EXECINSTR (0x4) | ||
| # PLT-NEXT: ] | ||
| # PLT-NEXT: Address: 0x4001C0 | ||
| # PLT-NEXT: Offset: 0x1C0 | ||
| # PLT-NEXT: Size: 80 | ||
| # PLT-NEXT: Link: 0 | ||
| # PLT-NEXT: Info: 0 | ||
| # PLT-NEXT: AddressAlignment: 16 | ||
| # PLT-NEXT: EntrySize: 0 | ||
| # PLT-NEXT: } | ||
|
|
||
| # PLT: Relocations [ | ||
| # PLT-NEXT: Section (5) .rel.plt { | ||
| # PLT-NEXT: 0x402008 R_MIPS_JUMP_SLOT T1 0x0 | ||
| # PLT-NEXT: 0x40200C R_MIPS_JUMP_SLOT T2 0x0 | ||
| # PLT-NEXT: 0x402010 R_MIPS_JUMP_SLOT T3 0x0 | ||
| # PLT-NEXT: } | ||
| # PLT-NEXT: ] | ||
|
|
||
| # PLT: DynamicSymbols [ | ||
| # PLT-NEXT: Symbol { | ||
| # PLT-NEXT: Name: @ (0) | ||
| # PLT-NEXT: Value: 0x0 | ||
| # PLT-NEXT: Size: 0 | ||
| # PLT-NEXT: Binding: Local (0x0) | ||
| # PLT-NEXT: Type: None (0x0) | ||
| # PLT-NEXT: Other: 0 | ||
| # PLT-NEXT: Section: Undefined (0x0) | ||
| # PLT-NEXT: } | ||
| # PLT-NEXT: Symbol { | ||
| # PLT-NEXT: Name: T2@ (1) | ||
| # PLT-NEXT: Value: 0x4001F0 | ||
| # PLT-NEXT: Size: 0 | ||
| # PLT-NEXT: Binding: Global (0x1) | ||
| # PLT-NEXT: Type: Function (0x2) | ||
| # PLT-NEXT: Other: 8 | ||
| # PLT-NEXT: Section: Undefined (0x0) | ||
| # PLT-NEXT: } | ||
| # PLT-NEXT: Symbol { | ||
| # PLT-NEXT: Name: T3@ (4) | ||
| # PLT-NEXT: Value: 0x400200 | ||
| # PLT-NEXT: Size: 0 | ||
| # PLT-NEXT: Binding: Global (0x1) | ||
| # PLT-NEXT: Type: Function (0x2) | ||
| # PLT-NEXT: Other: 8 | ||
| # PLT-NEXT: Section: Undefined (0x0) | ||
| # PLT-NEXT: } | ||
| # PLT-NEXT: Symbol { | ||
| # PLT-NEXT: Name: T1@ (7) | ||
| # PLT-NEXT: Value: 0x4001E0 | ||
| # PLT-NEXT: Size: 0 | ||
| # PLT-NEXT: Binding: Global (0x1) | ||
| # PLT-NEXT: Type: Function (0x2) | ||
| # PLT-NEXT: Other: 8 | ||
| # PLT-NEXT: Section: Undefined (0x0) | ||
| # PLT-NEXT: } | ||
| # PLT-NEXT: ] | ||
|
|
||
| !ELF | ||
| FileHeader: !FileHeader | ||
| Class: ELFCLASS32 | ||
| Data: ELFDATA2LSB | ||
| Type: ET_REL | ||
| Machine: EM_MIPS | ||
| Flags: [EF_MIPS_CPIC] | ||
|
|
||
| Sections: | ||
| - Name: .text | ||
| Type: SHT_PROGBITS | ||
| Content: "0000000000000000" | ||
| AddressAlign: 16 | ||
| Flags: [SHF_EXECINSTR, SHF_ALLOC] | ||
|
|
||
| - Name: .rel.text | ||
| Type: SHT_REL | ||
| Info: .text | ||
| AddressAlign: 4 | ||
| Relocations: | ||
| # There is no branch relocation for T1. | ||
| - Offset: 0x00 | ||
| Symbol: T1 | ||
| Type: R_MIPS_32 | ||
| # The R_MIPS_32 relocation for T2 might produce R_MIPS_REL32 ... | ||
| - Offset: 0x00 | ||
| Symbol: T2 | ||
| Type: R_MIPS_32 | ||
| # ... but R_MIPS_26 creates PLT entry and makes R_MIPS_REL32 redundant. | ||
| - Offset: 0x04 | ||
| Symbol: T2 | ||
| Type: R_MIPS_26 | ||
| # Create PLT entry for T3 symbol. | ||
| - Offset: 0x00 | ||
| Symbol: T3 | ||
| Type: R_MIPS_26 | ||
| # Take in account existing PLT entry and do not create R_MIPS_REL32. | ||
| - Offset: 0x04 | ||
| Symbol: T3 | ||
| Type: R_MIPS_32 | ||
|
|
||
| Symbols: | ||
| Global: | ||
| - Name: T0 | ||
| Section: .text | ||
| Type: STT_FUNC | ||
| Value: 0x0 | ||
| Size: 8 | ||
| - Name: T1 | ||
| Type: STT_FUNC | ||
| - Name: T2 | ||
| Type: STT_FUNC | ||
| - Name: T3 | ||
| Type: STT_FUNC |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| # Conditions: | ||
| # a) Linking a shared library. | ||
| # b) The first relocation modifies a regular .text section. | ||
| # c) The second relocation modifies a .pdr section without SHF_ALLOC flag. | ||
| # Check: | ||
| # a) There should be no PLT entries. | ||
| # b) Linker creates a single R_MIPS_REL32 relocation. | ||
| # | ||
| # RUN: yaml2obj -format=elf %s > %t-obj | ||
| # RUN: lld -flavor gnu -target mipsel -shared -o %t1-so %t-obj | ||
| # RUN: llvm-readobj -dt -r -s %t1-so | FileCheck -check-prefix=PLT1 %s | ||
|
|
||
| # PLT1-SYM: Sections [ | ||
| # PLT1-SYM: Section { | ||
| # PLT1-SYM-NOT: Name: .plt ({{[0-9]+}}) | ||
|
|
||
| # PLT1: Relocations [ | ||
| # PLT1-NEXT: Section (4) .rel.dyn { | ||
| # PLT1-NEXT: 0x100 R_MIPS_REL32 T0 0x0 | ||
| # PLT1-NEXT: } | ||
| # PLT1-NEXT: ] | ||
|
|
||
| # PLT1: DynamicSymbols [ | ||
| # PLT1-NEXT: Symbol { | ||
| # PLT1-NEXT: Name: @ (0) | ||
| # PLT1-NEXT: Value: 0x0 | ||
| # PLT1-NEXT: Size: 0 | ||
| # PLT1-NEXT: Binding: Local (0x0) | ||
| # PLT1-NEXT: Type: None (0x0) | ||
| # PLT1-NEXT: Other: 0 | ||
| # PLT1-NEXT: Section: Undefined (0x0) | ||
| # PLT1-NEXT: } | ||
| # PLT1-NEXT: Symbol { | ||
| # PLT1-NEXT: Name: T1@ (4) | ||
| # PLT1-NEXT: Value: 0x104 | ||
| # PLT1-NEXT: Size: 4 | ||
| # PLT1-NEXT: Binding: Global (0x1) | ||
| # PLT1-NEXT: Type: Function (0x2) | ||
| # PLT1-NEXT: Other: 0 | ||
| # PLT1-NEXT: Section: .text (0x5) | ||
| # PLT1-NEXT: } | ||
| # PLT1-NEXT: Symbol { | ||
| # PLT1-NEXT: Name: T0@ (1) | ||
| # PLT1-NEXT: Value: 0x100 | ||
| # PLT1-NEXT: Size: 4 | ||
| # PLT1-NEXT: Binding: Global (0x1) | ||
| # PLT1-NEXT: Type: Function (0x2) | ||
| # PLT1-NEXT: Other: 0 | ||
| # PLT1-NEXT: Section: .text (0x5) | ||
| # PLT1-NEXT: } | ||
| # PLT1-NEXT: ] | ||
|
|
||
| !ELF | ||
| FileHeader: !FileHeader | ||
| Class: ELFCLASS32 | ||
| Data: ELFDATA2LSB | ||
| Type: ET_REL | ||
| Machine: EM_MIPS | ||
| Flags: [EF_MIPS_PIC, EF_MIPS_CPIC] | ||
|
|
||
| Sections: | ||
| - Name: .text | ||
| Type: SHT_PROGBITS | ||
| Content: "0000000000000000" | ||
| AddressAlign: 16 | ||
| Flags: [SHF_EXECINSTR, SHF_ALLOC] | ||
|
|
||
| - Name: .rel.text | ||
| Type: SHT_REL | ||
| Info: .text | ||
| AddressAlign: 4 | ||
| Relocations: | ||
| - Offset: 0x00 | ||
| Symbol: T0 | ||
| Type: R_MIPS_32 | ||
|
|
||
| - Name: .pdr | ||
| Type: SHT_PROGBITS | ||
| Content: "0000000000000000" | ||
| AddressAlign: 16 | ||
| Flags: [] | ||
|
|
||
| - Name: .rel.pdr | ||
| Type: SHT_REL | ||
| Info: .pdr | ||
| AddressAlign: 4 | ||
| Relocations: | ||
| - Offset: 0x00 | ||
| Symbol: T1 | ||
| Type: R_MIPS_32 | ||
|
|
||
| Symbols: | ||
| Global: | ||
| - Name: T0 | ||
| Section: .text | ||
| Type: STT_FUNC | ||
| Value: 0x0 | ||
| Size: 4 | ||
| - Name: T1 | ||
| Section: .text | ||
| Type: STT_FUNC | ||
| Value: 0x4 | ||
| Size: 4 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,230 @@ | ||
| # 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 %S/Inputs/pic-obj.yaml > %t-so-obj | ||
| # RUN: lld -flavor gnu -target mipsel -shared -o %t-so %t-so-obj | ||
| # RUN: yaml2obj -format=elf %s > %t-obj | ||
| # RUN: lld -flavor gnu -target mipsel -shared --noinhibit-exec \ | ||
| # RUN: -o %t1-so %t-obj %t-so | ||
| # RUN: llvm-readobj -dt -r -sections %t1-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: ] | ||
|
|
||
| !ELF | ||
| FileHeader: !FileHeader | ||
| Class: ELFCLASS32 | ||
| Data: ELFDATA2LSB | ||
| Type: ET_REL | ||
| Machine: EM_MIPS | ||
| Flags: [EF_MIPS_PIC, EF_MIPS_CPIC] | ||
|
|
||
| Sections: | ||
| - Name: .text | ||
| Type: SHT_PROGBITS | ||
| Content: "000000000000000000000000" | ||
| AddressAlign: 16 | ||
| Flags: [SHF_EXECINSTR, SHF_ALLOC] | ||
|
|
||
| - Name: .data | ||
| Type: SHT_PROGBITS | ||
| Content: "000000000000000000000000" | ||
| 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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,186 @@ | ||
| # Conditions: | ||
| # a) Linking a non-shared executable file. | ||
| # b) There ars multiple R_MIPS_32/R_MIPS_HI16/R_MIPS_LO16 relocations | ||
| # with various targets. | ||
| # Check: | ||
| # a) Emitting of R_MIPS_REL32 relocations. | ||
| # | ||
| # RUN: yaml2obj -format=elf %S/Inputs/pic-obj.yaml > %t-so-obj | ||
| # RUN: lld -flavor gnu -target mipsel -shared -o %t-so %t-so-obj | ||
| # RUN: yaml2obj -format=elf %s > %t-obj | ||
| # RUN: lld -flavor gnu -target mipsel -e T0 --noinhibit-exec \ | ||
| # RUN: -o %t1-exe %t-obj %t-so | ||
| # RUN: llvm-readobj -dt -r -sections %t1-exe | FileCheck %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@ (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: T2@ (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: 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: ] | ||
|
|
||
| !ELF | ||
| FileHeader: !FileHeader | ||
| Class: ELFCLASS32 | ||
| Data: ELFDATA2LSB | ||
| Type: ET_REL | ||
| Machine: EM_MIPS | ||
| Flags: [EF_MIPS_CPIC] | ||
|
|
||
| Sections: | ||
| - Name: .text | ||
| Type: SHT_PROGBITS | ||
| Content: "000000000000000000000000" | ||
| AddressAlign: 16 | ||
| Flags: [SHF_EXECINSTR, SHF_ALLOC] | ||
|
|
||
| - Name: .data | ||
| Type: SHT_PROGBITS | ||
| Content: "000000000000000000000000" | ||
| 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 # 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 | ||
| - 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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| # Conditions: | ||
| # a) Linking a non-shared executable file. | ||
| # b) Relocations' targets are undefined symbols. | ||
| # Check: | ||
| # a) There should be no dynamic relocations. | ||
| # b) There should be no PLT entries. | ||
| # | ||
| # RUN: yaml2obj -format=elf %s > %t-obj | ||
| # RUN: lld -flavor gnu -target mipsel --noinhibit-exec -e T0 -o %t2-exe %t-obj | ||
| # RUN: llvm-readobj -dt -r -s %t2-exe | FileCheck -check-prefix=PLT-SYM %s | ||
|
|
||
| # PLT-SYM: Sections [ | ||
| # PLT-SYM: Section { | ||
| # PLT-SYM-NOT: Name: .plt ({{[0-9]+}}) | ||
|
|
||
| # PLT-SYM: Relocations [ | ||
| # PLT-SYM-NEXT: ] | ||
|
|
||
| # PLT-SYM: DynamicSymbols [ | ||
| # PLT-SYM-NEXT: Symbol { | ||
| # PLT-SYM-NEXT: Name: @ (0) | ||
| # PLT-SYM-NEXT: Value: 0x0 | ||
| # PLT-SYM-NEXT: Size: 0 | ||
| # PLT-SYM-NEXT: Binding: Local (0x0) | ||
| # PLT-SYM-NEXT: Type: None (0x0) | ||
| # PLT-SYM-NEXT: Other: 0 | ||
| # PLT-SYM-NEXT: Section: Undefined (0x0) | ||
| # PLT-SYM-NEXT: } | ||
| # PLT-SYM-NEXT: ] | ||
|
|
||
| !ELF | ||
| FileHeader: !FileHeader | ||
| Class: ELFCLASS32 | ||
| Data: ELFDATA2LSB | ||
| Type: ET_REL | ||
| Machine: EM_MIPS | ||
| Flags: [EF_MIPS_CPIC] | ||
|
|
||
| Sections: | ||
| - Name: .text | ||
| Type: SHT_PROGBITS | ||
| Content: "0000000000000000" | ||
| AddressAlign: 16 | ||
| Flags: [SHF_EXECINSTR, SHF_ALLOC] | ||
|
|
||
| - Name: .data | ||
| Type: SHT_PROGBITS | ||
| Content: "0000000000000000" | ||
| AddressAlign: 16 | ||
| Flags: [SHF_WRITE, SHF_ALLOC] | ||
|
|
||
| - Name: .rel.text | ||
| Type: SHT_REL | ||
| Info: .text | ||
| AddressAlign: 4 | ||
| Relocations: | ||
| - Offset: 0x04 | ||
| Symbol: T3 | ||
| Type: R_MIPS_26 | ||
|
|
||
| - Name: .rel.data | ||
| Type: SHT_REL | ||
| Info: .data | ||
| AddressAlign: 4 | ||
| Relocations: | ||
| - Offset: 0x00 | ||
| Symbol: T1 | ||
| Type: R_MIPS_HI16 | ||
| - Offset: 0x00 | ||
| Symbol: T1 | ||
| Type: R_MIPS_LO16 | ||
| - Offset: 0x04 | ||
| Symbol: T2 | ||
| Type: R_MIPS_32 | ||
|
|
||
| - Offset: 0x04 | ||
| Symbol: D1 | ||
| Type: R_MIPS_HI16 | ||
| - Offset: 0x04 | ||
| Symbol: D1 | ||
| Type: R_MIPS_LO16 | ||
| - Offset: 0x04 | ||
| Symbol: D2 | ||
| Type: R_MIPS_32 | ||
|
|
||
| Symbols: | ||
| Global: | ||
| - Name: T0 | ||
| Section: .text | ||
| Type: STT_FUNC | ||
| Value: 0x0 | ||
| Size: 8 | ||
| - Name: T1 | ||
| Type: STT_FUNC | ||
| - Name: T2 | ||
| Type: STT_FUNC | ||
| - Name: T3 | ||
| Type: STT_FUNC | ||
| - Name: D0 | ||
| Section: .data | ||
| Type: STT_OBJECT | ||
| Value: 0x0 | ||
| Size: 8 | ||
| - Name: D1 | ||
| Type: STT_OBJECT | ||
| - Name: D2 | ||
| Type: STT_OBJECT |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| # Conditions: | ||
| # a) Linking a non-shared executable file. | ||
| # b) Relocations' targets are symbols defined in the other object. | ||
| # Check: | ||
| # a) There should be no dynamic relocations. | ||
| # b) There should be no PLT entries. | ||
| # | ||
| # RUN: yaml2obj -format=elf %s > %t-obj1 | ||
| # RUN: yaml2obj -format=elf %S/Inputs/pic-obj.yaml > %t-obj2 | ||
| # RUN: lld -flavor gnu -target mipsel -e T0 -o %t3-exe %t-obj1 %t-obj2 | ||
| # RUN: llvm-readobj -dt -r -s %t3-exe | FileCheck -check-prefix=PLT-SYM %s | ||
|
|
||
| # PLT-SYM: Sections [ | ||
| # PLT-SYM: Section { | ||
| # PLT-SYM-NOT: Name: .plt ({{[0-9]+}}) | ||
|
|
||
| # PLT-SYM: Relocations [ | ||
| # PLT-SYM-NEXT: ] | ||
|
|
||
| # PLT-SYM: DynamicSymbols [ | ||
| # PLT-SYM-NEXT: Symbol { | ||
| # PLT-SYM-NEXT: Name: @ (0) | ||
| # PLT-SYM-NEXT: Value: 0x0 | ||
| # PLT-SYM-NEXT: Size: 0 | ||
| # PLT-SYM-NEXT: Binding: Local (0x0) | ||
| # PLT-SYM-NEXT: Type: None (0x0) | ||
| # PLT-SYM-NEXT: Other: 0 | ||
| # PLT-SYM-NEXT: Section: Undefined (0x0) | ||
| # PLT-SYM-NEXT: } | ||
| # PLT-SYM-NEXT: ] | ||
|
|
||
| !ELF | ||
| FileHeader: !FileHeader | ||
| Class: ELFCLASS32 | ||
| Data: ELFDATA2LSB | ||
| Type: ET_REL | ||
| Machine: EM_MIPS | ||
| Flags: [EF_MIPS_CPIC] | ||
|
|
||
| Sections: | ||
| - Name: .text | ||
| Type: SHT_PROGBITS | ||
| Content: "0000000000000000" | ||
| AddressAlign: 16 | ||
| Flags: [SHF_EXECINSTR, SHF_ALLOC] | ||
|
|
||
| - Name: .data | ||
| Type: SHT_PROGBITS | ||
| Content: "0000000000000000" | ||
| AddressAlign: 16 | ||
| Flags: [SHF_WRITE, SHF_ALLOC] | ||
|
|
||
| - Name: .rel.text | ||
| Type: SHT_REL | ||
| Info: .text | ||
| AddressAlign: 4 | ||
| Relocations: | ||
| - Offset: 0x04 | ||
| Symbol: T3 | ||
| Type: R_MIPS_26 | ||
|
|
||
| - Name: .rel.data | ||
| Type: SHT_REL | ||
| Info: .data | ||
| AddressAlign: 4 | ||
| Relocations: | ||
| - Offset: 0x00 | ||
| Symbol: T1 | ||
| Type: R_MIPS_HI16 | ||
| - Offset: 0x00 | ||
| Symbol: T1 | ||
| Type: R_MIPS_LO16 | ||
| - Offset: 0x04 | ||
| Symbol: T2 | ||
| Type: R_MIPS_32 | ||
|
|
||
| - Offset: 0x04 | ||
| Symbol: D1 | ||
| Type: R_MIPS_HI16 | ||
| - Offset: 0x04 | ||
| Symbol: D1 | ||
| Type: R_MIPS_LO16 | ||
| - Offset: 0x04 | ||
| Symbol: D2 | ||
| Type: R_MIPS_32 | ||
|
|
||
| Symbols: | ||
| Global: | ||
| - Name: T0 | ||
| Section: .text | ||
| Type: STT_FUNC | ||
| Value: 0x0 | ||
| Size: 8 | ||
| - Name: T1 | ||
| Type: STT_FUNC | ||
| - Name: T2 | ||
| Type: STT_FUNC | ||
| - Name: T3 | ||
| Type: STT_FUNC | ||
| - Name: D0 | ||
| Section: .data | ||
| Type: STT_OBJECT | ||
| Value: 0x0 | ||
| Size: 8 | ||
| - Name: D1 | ||
| Type: STT_OBJECT | ||
| - Name: D2 | ||
| Type: STT_OBJECT |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| # Conditions: | ||
| # a) Linking a shared library. | ||
| # b) Relocations' targets are symbols defined in the other shared object. | ||
| # Check: | ||
| # a) Emitting R_MIPS_REL32 relocations for both symbols. | ||
| # b) There should be no PLT entries. | ||
| # | ||
| # RUN: yaml2obj -format=elf %S/Inputs/pic-obj.yaml > %t-so-obj | ||
| # RUN: lld -flavor gnu -target mipsel -shared -o %t-so %t-so-obj | ||
| # RUN: yaml2obj -format=elf %s > %t-obj | ||
| # RUN: lld -flavor gnu -target mipsel -shared -o %t2-so %t-obj %t-so | ||
| # RUN: llvm-readobj -dt -r -s %t2-so | FileCheck -check-prefix=PLT-SYM %s | ||
|
|
||
| # PLT-SYM: Sections [ | ||
| # PLT-SYM: Section { | ||
| # PLT-SYM-NOT: Name: .plt ({{[0-9]+}}) | ||
| # | ||
| # PLT-SYM: Relocations [ | ||
| # PLT-SYM-NEXT: Section (4) .rel.dyn { | ||
| # PLT-SYM-NEXT: 0x2000 R_MIPS_REL32 T1 0x0 | ||
| # PLT-SYM-NEXT: 0x160 R_MIPS_REL32 T1 0x0 | ||
| # PLT-SYM-NEXT: } | ||
| # PLT-SYM-NEXT: ] | ||
| # | ||
| # PLT-SYM: Name: T1@ (7) | ||
| # PLT-SYM-NEXT: Value: 0x0 | ||
| # PLT-SYM-NEXT: Size: 0 | ||
| # PLT-SYM-NEXT: Binding: Global (0x1) | ||
| # PLT-SYM-NEXT: Type: Function (0x2) | ||
| # PLT-SYM-NEXT: Other: 0 | ||
| # PLT-SYM-NEXT: Section: Undefined (0x0) | ||
|
|
||
| !ELF | ||
| FileHeader: !FileHeader | ||
| Class: ELFCLASS32 | ||
| Data: ELFDATA2LSB | ||
| Type: ET_REL | ||
| Machine: EM_MIPS | ||
| Flags: [EF_MIPS_PIC, EF_MIPS_CPIC] | ||
|
|
||
| Sections: | ||
| - Name: .text | ||
| Type: SHT_PROGBITS | ||
| Content: "0000000000000000" | ||
| AddressAlign: 16 | ||
| Flags: [SHF_EXECINSTR, SHF_ALLOC] | ||
|
|
||
| - Name: .data | ||
| Type: SHT_PROGBITS | ||
| Content: "0000000000000000" | ||
| AddressAlign: 16 | ||
| Flags: [SHF_WRITE, SHF_ALLOC] | ||
|
|
||
| - Name: .rel.text | ||
| Type: SHT_REL | ||
| Info: .text | ||
| AddressAlign: 4 | ||
| Relocations: | ||
| - Offset: 0x00 | ||
| Symbol: T1 | ||
| Type: R_MIPS_32 | ||
|
|
||
| - Name: .rel.data | ||
| Type: SHT_REL | ||
| Info: .data | ||
| AddressAlign: 4 | ||
| Relocations: | ||
| - Offset: 0x00 | ||
| Symbol: T1 | ||
| Type: R_MIPS_32 | ||
|
|
||
| Symbols: | ||
| Global: | ||
| - Name: T0 | ||
| Section: .text | ||
| Type: STT_FUNC | ||
| Value: 0x0 | ||
| Size: 4 | ||
| - Name: T1 | ||
| - Name: D0 | ||
| Section: .data | ||
| Type: STT_OBJECT | ||
| Value: 0x0 | ||
| Size: 8 |