diff options
Diffstat (limited to 'test/elf/Mips/rel-pc-hilo.test')
-rw-r--r-- | test/elf/Mips/rel-pc-hilo.test | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/test/elf/Mips/rel-pc-hilo.test b/test/elf/Mips/rel-pc-hilo.test new file mode 100644 index 0000000000000..89cd2b121797a --- /dev/null +++ b/test/elf/Mips/rel-pc-hilo.test @@ -0,0 +1,70 @@ +# Check handling of R_MIPS_PCHI16 / R_MIPS_PCLO16 relocations. + +# RUN: yaml2obj -format=elf %s > %t.o +# RUN: lld -flavor 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: 400110 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: 00400110 g F .text 0000000c T0 +# CHECK: 0040011c 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 |