hanchenye-llvm-project/lld/test/old-elf/Mips/rel-pc-hilo.test

71 lines
2.0 KiB
Plaintext

# Check handling of R_MIPS_PCHI16 / R_MIPS_PCLO16 relocations.
# RUN: yaml2obj -format=elf %s > %t.o
# RUN: lld -flavor old-gnu -target mipsel -e T0 -o %t.exe %t.o
# RUN: llvm-objdump -s -t %t.exe | FileCheck %s
# CHECK: Contents of section .text:
# CHECK-NEXT: {{[0-9A-F]+}} 01000000 02000000 03000000 00000000
# ^
# A = 0x10000 - 1 == 0xffff
# V = (T1 + 0xffff - T0) >> 16 =>
# V => 0x1000b >> 16 = 1
# ^
# A = 0x20000 - 1 == 0x1ffff
# V = (T1 + 0x1ffff - T0 - 4) >> 16 =>
# V => 0x20007 >> 16 = 2
# ^
# A = 0xffff == -1
# V = T1 - 1 - T0 - 8 = 3
# CHECK: SYMBOL TABLE:
# CHECK: {{[0-9a-f]+}} g F .text 0000000c T0
# CHECK: {{[0-9a-f]+}} g F .text 00000004 T1
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_MIPS
Flags: [EF_MIPS_CPIC, EF_MIPS_ABI_O32, EF_MIPS_ARCH_32R6]
Sections:
- Name: .text
Type: SHT_PROGBITS
Content: "0100000002000000ffff000000000000"
# ^ T0
# ^ A := 0x1 == 0x10000
# ^ A := 0x2 == 0x20000
# ^ A := 0xffff == -1
# ^ T1
AddressAlign: 16
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
- Name: .rel.text
Type: SHT_REL
Info: .text
AddressAlign: 4
Relocations:
- Offset: 0
Symbol: T1
Type: R_MIPS_PCHI16
- Offset: 4
Symbol: T1
Type: R_MIPS_PCHI16
- Offset: 8
Symbol: T1
Type: R_MIPS_PCLO16
Symbols:
Global:
- Name: T0
Section: .text
Type: STT_FUNC
Value: 0
Size: 12
- Name: T1
Section: .text
Type: STT_FUNC
Value: 12
Size: 4