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

238 lines
6.0 KiB
Plaintext

# 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 -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 -o %t.exe %t-o.o %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: 4001f0: 40 00 1c 3c lui $gp, 64
# PLT-NEXT: 4001f4: 00 20 99 8f lw $25, 8192($gp)
# PLT-NEXT: 4001f8: 00 20 9c 27 addiu $gp, $gp, 8192
# PLT-NEXT: 4001fc: 23 c0 1c 03 subu $24, $24, $gp
# PLT-NEXT: 400200: 21 78 e0 03 move $15, $ra
# PLT-NEXT: 400204: 82 c0 18 00 srl $24, $24, 2
# PLT-NEXT: 400208: 09 f8 20 03 jalr $25
# PLT-NEXT: 40020c: fe ff 18 27 addiu $24, $24, -2
#
# PLT-NEXT: 400210: 40 00 0f 3c lui $15, 64
# PLT-NEXT: 400214: 08 20 f9 8d lw $25, 8200($15)
# PLT-NEXT: 400218: 08 00 20 03 jr $25
# PLT-NEXT: 40021c: 08 20 f8 25 addiu $24, $15, 8200
#
# PLT-NEXT: 400220: 40 00 0f 3c lui $15, 64
# PLT-NEXT: 400224: 0c 20 f9 8d lw $25, 8204($15)
# PLT-NEXT: 400228: 08 00 20 03 jr $25
# PLT-NEXT: 40022c: 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@ (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: T1@ (7)
# PLT-SYM-NEXT: Value: 0x400220
# 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: T2@ (10)
# 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: ]
# 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: T3
Section: .text
Type: STT_FUNC
Value: 0x8
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: !FileHeader
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_MIPS
Flags: [EF_MIPS_CPIC]
Sections:
- Name: .text
Type: SHT_PROGBITS
Size: 0x08
AddressAlign: 16
Flags: [SHF_EXECINSTR, SHF_ALLOC]
- Name: .data
Type: SHT_PROGBITS
Size: 0x08
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
...