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

130 lines
3.1 KiB
Plaintext

# 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 -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: 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)
# 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]
Symbols:
Global:
- Name: T1
Section: .text
Type: STT_FUNC
Value: 0x0
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: 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
...