From 0d26edab097efc569bd54d9e89b8c1d45ba1110c Mon Sep 17 00:00:00 2001 From: Simon Atanasyan Date: Tue, 31 Mar 2015 13:04:01 +0000 Subject: [PATCH] [Mips] Do not use MIPS assembler and disassembler in the tests No functional changes. llvm-svn: 233691 --- lld/test/elf/Mips/hilo16-1.test | 107 ++++++++----- lld/test/elf/Mips/hilo16-2.test | 169 +++++++++++++------- lld/test/elf/Mips/hilo16-3.test | 95 ++++++++---- lld/test/elf/Mips/hilo16-8-micro.test | 212 ++++++++++++++++++-------- lld/test/elf/Mips/hilo16-9-micro.test | 186 +++++++++++++++------- 5 files changed, 523 insertions(+), 246 deletions(-) diff --git a/lld/test/elf/Mips/hilo16-1.test b/lld/test/elf/Mips/hilo16-1.test index c2863408c888..4043a577fa29 100644 --- a/lld/test/elf/Mips/hilo16-1.test +++ b/lld/test/elf/Mips/hilo16-1.test @@ -1,44 +1,77 @@ -# REQUIRES: mips - # Check handling multiple HI16 relocation followed by a single LO16 relocation. -# -# RUN: llvm-mc -triple=mipsel -filetype=obj -o=%t-obj %s -# RUN: lld -flavor gnu -target mipsel -e glob1 -o %t-exe %t-obj -# RUN: llvm-objdump -t -disassemble %t-exe | FileCheck %s -# CHECK: Disassembly of section .text: -# CHECK: glob1: -# CHECK-NEXT: {{[0-9a-f]+}}: 40 00 08 3c lui $8, 64 -# CHECK-NEXT: {{[0-9a-f]+}}: 40 00 08 3c lui $8, 64 -# CHECK-NEXT: {{[0-9a-f]+}}: 40 00 08 3c lui $8, 64 -# CHECK-NEXT: {{[0-9a-f]+}}: 40 00 08 3c lui $8, 64 -# CHECK-NEXT: {{[0-9a-f]+}}: 42 00 08 3c lui $8, 66 -# CHECK-NEXT: {{[0-9a-f]+}}: 3e 00 08 3c lui $8, 62 -# CHECK-NEXT: {{[0-9a-f]+}}: 40 02 08 3c lui $8, 576 -# CHECK-NEXT: {{[0-9a-f]+}}: 40 fe 08 3c lui $8, 65088 -# CHECK-NEXT: {{[0-9a-f]+}}: 55 01 08 85 lh $8, 341($8) +# 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 4000083c 4000083c 4000083c 4000083c +# CHECK-NEXT: 400120 4200083c 3e00083c 4002083c 40fe083c +# CHECK-NEXT: 400130 35010885 00000000 # CHECK: SYMBOL TABLE: -# CHECK: {{[0-9a-f]+}} g F .text 00000024 glob1 -# CHECK: {{[0-9a-f]+}} g F .text 00000004 glob2 +# CHECK: 00400110 g F .text 00000024 T0 +# CHECK: 00400134 g F .text 00000004 T1 - .global glob1 - .ent glob1 -glob1: - lui $t0,%hi(glob2+0x1) - lui $t0,%hi(glob2+(-0x1)) - lui $t0,%hi(glob2+0x1ff) - lui $t0,%hi(glob2+(-0x1ff)) - lui $t0,%hi(glob2+0x1ffff) - lui $t0,%hi(glob2+(-0x1ffff)) - lui $t0,%hi(glob2+0x1ffffff) - lui $t0,%hi(glob2+(-0x1ffffff)) +FileHeader: + Class: ELFCLASS32 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_MIPS + Flags: [EF_MIPS_CPIC, EF_MIPS_ABI_O32, EF_MIPS_ARCH_32R2] - lh $t0,%lo(glob2+(-0x1ffffff))($t0) - .end glob1 +Sections: +- Name: .text + Type: SHT_PROGBITS + Content: "0000083c0000083c0000083c0000083c0200083cfeff083c0002083c00fe083c0100088500000000" +# ^ %hi(T1+1) ^ %hi(T1+0x1ff) ^ %hi(T1+0x1ffff) ^ %hi(T1-0x1ffffff) +# ^ %hi(T1-1) ^ %hi(T1-0x1ff) ^ %hi(T1-0x1ffff) ^ %lo(T1-0x1ffffff) +# ^ %hi(T1+0x1ffffff) + AddressAlign: 16 + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] - .global glob2 - .ent glob2 -glob2: - nop - .end glob2 +- Name: .rel.text + Type: SHT_REL + Info: .text + AddressAlign: 4 + Relocations: + - Offset: 0x0 + Symbol: T1 + Type: R_MIPS_HI16 + - Offset: 0x4 + Symbol: T1 + Type: R_MIPS_HI16 + - Offset: 0x8 + Symbol: T1 + Type: R_MIPS_HI16 + - Offset: 0xC + Symbol: T1 + Type: R_MIPS_HI16 + - Offset: 0x10 + Symbol: T1 + Type: R_MIPS_HI16 + - Offset: 0x14 + Symbol: T1 + Type: R_MIPS_HI16 + - Offset: 0x18 + Symbol: T1 + Type: R_MIPS_HI16 + - Offset: 0x1C + Symbol: T1 + Type: R_MIPS_HI16 + - Offset: 0x20 + Symbol: T1 + Type: R_MIPS_LO16 + +Symbols: + Global: + - Name: T0 + Section: .text + Type: STT_FUNC + Value: 0 + Size: 36 + - Name: T1 + Section: .text + Type: STT_FUNC + Value: 36 + Size: 4 diff --git a/lld/test/elf/Mips/hilo16-2.test b/lld/test/elf/Mips/hilo16-2.test index 68cb26eec788..b826ca4f1fda 100644 --- a/lld/test/elf/Mips/hilo16-2.test +++ b/lld/test/elf/Mips/hilo16-2.test @@ -1,68 +1,131 @@ -# REQUIRES: mips - # Check handling of HI16 and LO16 relocations for regular symbol. # # R_MIPS_HI16: (AHL + S) - (short)(AHL + S) # R_MIPS_LO16: AHL + S # where AHL = (AHI << 16) + ALO -# -# RUN: llvm-mc -triple=mipsel -filetype=obj -o=%t-obj %s -# RUN: lld -flavor gnu -target mipsel -e glob1 -o %t-exe %t-obj -# RUN: llvm-objdump -t -disassemble %t-exe | FileCheck %s -# CHECK: Disassembly of section .text: -# CHECK: glob1: -# CHECK-NEXT: {{[0-9a-f]+}}: 40 00 08 3c lui $8, 64 -# CHECK-NEXT: {{[0-9a-f]+}}: 71 01 08 85 lh $8, 369($8) -# CHECK-NEXT: {{[0-9a-f]+}}: 40 00 08 3c lui $8, 64 -# CHECK-NEXT: {{[0-9a-f]+}}: 6f 01 08 85 lh $8, 367($8) -# CHECK-NEXT: {{[0-9a-f]+}}: 40 00 08 3c lui $8, 64 -# CHECK-NEXT: {{[0-9a-f]+}}: 6f 03 08 85 lh $8, 879($8) -# CHECK-NEXT: {{[0-9a-f]+}}: 40 00 08 3c lui $8, 64 -# CHECK-NEXT: {{[0-9a-f]+}}: 71 ff 08 85 lh $8, -143($8) -# CHECK-NEXT: {{[0-9a-f]+}}: 42 00 08 3c lui $8, 66 -# CHECK-NEXT: {{[0-9a-f]+}}: 6f 01 08 85 lh $8, 367($8) -# CHECK-NEXT: {{[0-9a-f]+}}: 3e 00 08 3c lui $8, 62 -# CHECK-NEXT: {{[0-9a-f]+}}: 71 01 08 85 lh $8, 369($8) -# CHECK-NEXT: {{[0-9a-f]+}}: 40 02 08 3c lui $8, 576 -# CHECK-NEXT: {{[0-9a-f]+}}: 6f 01 08 85 lh $8, 367($8) -# CHECK-NEXT: {{[0-9a-f]+}}: 40 fe 08 3c lui $8, 65088 -# CHECK-NEXT: {{[0-9a-f]+}}: 71 01 08 85 lh $8, 369($8) +# 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 4000083c 51010885 4000083c 4f010885 +# CHECK-NEXT: 400120 4000083c 4f030885 4000083c 51ff0885 +# CHECK-NEXT: 400130 4200083c 4f010885 3e00083c 51010885 +# CHECK-NEXT: 400140 4002083c 4f010885 40fe083c 51010885 +# CHECK-NEXT: 400150 00000000 # CHECK: SYMBOL TABLE: -# CHECK: {{[0-9a-f]+}} g F .text 00000040 glob1 -# CHECK: {{[0-9a-f]+}} g F .text 00000004 glob2 +# CHECK: 00400110 g F .text 00000020 T0 +# CHECK: 00400130 g F .text 00000020 T1 +# CHECK: 00400150 g F .text 00000004 T2 - .global glob1 - .ent glob1 -glob1: - lui $t0,%hi(glob2+0x1) - lh $t0,%lo(glob2+0x1)($t0) +FileHeader: + Class: ELFCLASS32 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_MIPS + Flags: [EF_MIPS_CPIC, EF_MIPS_ABI_O32, EF_MIPS_ARCH_32R2] - lui $t0,%hi(glob2+(-0x1)) - lh $t0,%lo(glob2+(-0x1))($t0) +Sections: +- Name: .text.1 + Type: SHT_PROGBITS + Content: "0000083c010008850000083cffff08850000083cff0108850000083c01fe0885" +# ^ %hi(T2+1) ^ %hi(T2-1) ^ %hi(T2+0x1ff) ^ %hi(T2-0x1ff) +# ^ %lo(T2+1) ^ %lo(T2-1) ^ %lo(T2+0x1ff) ^ %lo(T2-0x1ff) + AddressAlign: 16 + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] - lui $t0,%hi(glob2+0x1ff) - lh $t0,%lo(glob2+0x1ff)($t0) +- Name: .rel.text.1 + Type: SHT_REL + Info: .text.1 + AddressAlign: 4 + Relocations: + - Offset: 0x0 + Symbol: T2 + Type: R_MIPS_HI16 + - Offset: 0x4 + Symbol: T2 + Type: R_MIPS_LO16 + - Offset: 0x8 + Symbol: T2 + Type: R_MIPS_HI16 + - Offset: 0xC + Symbol: T2 + Type: R_MIPS_LO16 + - Offset: 0x10 + Symbol: T2 + Type: R_MIPS_HI16 + - Offset: 0x14 + Symbol: T2 + Type: R_MIPS_LO16 + - Offset: 0x18 + Symbol: T2 + Type: R_MIPS_HI16 + - Offset: 0x1C + Symbol: T2 + Type: R_MIPS_LO16 - lui $t0,%hi(glob2+(-0x1ff)) - lh $t0,%lo(glob2+(-0x1ff))($t0) +- Name: .text.2 + Type: SHT_PROGBITS + Content: "0200083cffff0885feff083c010008850002083cffff088500fe083c01000885" +# ^ %hi(T2+0x1ffff) ^ %hi(T2+0x1ffffff) +# ^ %lo(T2+0x1ffff) ^ %lo(T2+0x1ffffff) +# ^ %hi(T2-0x1ffff) ^ %hi(T2-0x1ffffff) +# ^ %lo(T2-0x1ffff) ^ %lo(T2-0x1ffffff) + AddressAlign: 16 + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] - lui $t0,%hi(glob2+0x1ffff) - lh $t0,%lo(glob2+0x1ffff)($t0) +- Name: .rel.text.2 + Type: SHT_REL + Info: .text.2 + AddressAlign: 4 + Relocations: + - Offset: 0x0 + Symbol: T2 + Type: R_MIPS_HI16 + - Offset: 0x4 + Symbol: T2 + Type: R_MIPS_LO16 + - Offset: 0x8 + Symbol: T2 + Type: R_MIPS_HI16 + - Offset: 0xC + Symbol: T2 + Type: R_MIPS_LO16 + - Offset: 0x10 + Symbol: T2 + Type: R_MIPS_HI16 + - Offset: 0x14 + Symbol: T2 + Type: R_MIPS_LO16 + - Offset: 0x18 + Symbol: T2 + Type: R_MIPS_HI16 + - Offset: 0x1C + Symbol: T2 + Type: R_MIPS_LO16 - lui $t0,%hi(glob2+(-0x1ffff)) - lh $t0,%lo(glob2+(-0x1ffff))($t0) +- Name: .text.3 + Type: SHT_PROGBITS + Content: "00000000" + AddressAlign: 16 + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] - lui $t0,%hi(glob2+0x1ffffff) # truncate - lh $t0,%lo(glob2+0x1ffffff)($t0) - - lui $t0,%hi(glob2+(-0x1ffffff)) # truncate - lh $t0,%lo(glob2+(-0x1ffffff))($t0) - .end glob1 - - .global glob2 - .ent glob2 -glob2: - nop - .end glob2 +Symbols: + Global: + - Name: T0 + Section: .text.1 + Type: STT_FUNC + Value: 0 + Size: 64 + - Name: T1 + Section: .text.2 + Type: STT_FUNC + Value: 0 + Size: 64 + - Name: T2 + Section: .text.3 + Type: STT_FUNC + Value: 0 + Size: 4 diff --git a/lld/test/elf/Mips/hilo16-3.test b/lld/test/elf/Mips/hilo16-3.test index daf4807d719a..002c474b0ea4 100644 --- a/lld/test/elf/Mips/hilo16-3.test +++ b/lld/test/elf/Mips/hilo16-3.test @@ -1,45 +1,74 @@ -# REQUIRES: mips - # Check handling of HI16 and LO16 relocations for _gp_disp. # # R_MIPS_HI16: (AHL + GP - P) - (short)(AHL + GP - P) # R_MIPS_LO16: AHL + GP - P + 4 # where AHL = (AHI << 16) + ALO -# -# RUN: llvm-mc -triple=mipsel -filetype=obj -o=%t-obj %s -# RUN: lld -flavor gnu -target mipsel -shared -o %t-so %t-obj -# RUN: llvm-objdump -t -disassemble %t-so | FileCheck %s -# CHECK: Disassembly of section .text: -# CHECK: glob1: -# CHECK-NEXT: {{[0-9a-f]+}}: 01 00 08 3c lui $8, 1 -# CHECK-NEXT: {{[0-9a-f]+}}: 01 8f 08 85 lh $8, -28927($8) -# CHECK-NEXT: {{[0-9a-f]+}}: 01 00 08 3c lui $8, 1 -# CHECK-NEXT: {{[0-9a-f]+}}: f7 8e 08 85 lh $8, -28937($8) -# CHECK-NEXT: {{[0-9a-f]+}}: 01 00 08 3c lui $8, 1 -# CHECK-NEXT: {{[0-9a-f]+}}: ef 90 08 85 lh $8, -28433($8) -# CHECK-NEXT: {{[0-9a-f]+}}: 01 00 08 3c lui $8, 1 -# CHECK-NEXT: {{[0-9a-f]+}}: e9 8c 08 85 lh $8, -29463($8) -# CHECK-NEXT: {{[0-9a-f]+}}: 03 00 08 3c lui $8, 3 -# CHECK-NEXT: {{[0-9a-f]+}}: df 8e 08 85 lh $8, -28961($8) +# RUN: yaml2obj -format=elf %s > %t.o +# RUN: lld -flavor gnu -target mipsel -shared -o %t.so %t.o +# RUN: llvm-objdump -s -t %t.so | FileCheck %s + +# CHECK: Contents of section .text: +# CHECK-NEXT: 00d0 0100083c 218f0885 0100083c 178f0885 +# CHECK-NEXT: 00e0 0100083c 0f910885 0100083c 098d0885 +# CHECK-NEXT: 00f0 0200083c ffff0885 # CHECK: SYMBOL TABLE: -# CHECK: {{[0-9a-f]+}} g F .text 00000028 glob1 -# CHECK: {{[0-9a-f]+}} g *ABS* 00000000 _gp_disp +# CHECK: 000000d0 g F .text 00000028 T0 +# CHECK: 00008ff0 g *ABS* 00000000 _gp_disp - .global glob1 -glob1: - lui $t0,%hi(_gp_disp+0x1) - lh $t0,%lo(_gp_disp+0x1)($t0) +FileHeader: + Class: ELFCLASS32 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_MIPS + Flags: [EF_MIPS_CPIC, EF_MIPS_ABI_O32, EF_MIPS_ARCH_32R2] - lui $t0,%hi(_gp_disp+(-0x1)) - lh $t0,%lo(_gp_disp+(-0x1))($t0) +Sections: +- Name: .text + Type: SHT_PROGBITS + Content: "0000083C010008850000083CFFFF08850000083CFF0108850000083C01FE08850200083CFFFF0885" +# ^ %hi(gp+1) ^ %hi(gp-1) ^ %hi(gp+0x1ff) ^ %hi(gp-0x1ff) ^ %lo(gp+0x1ffff) +# ^ %lo(gp+1) ^ %lo(gp-1) ^ %lo(gp+0x1ff) ^ %lo(gp-0x1ff) +# ^ %hi(gp+0x1ffff) + AddressAlign: 16 + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] - lui $t0,%hi(_gp_disp+0x1ff) - lh $t0,%lo(_gp_disp+0x1ff)($t0) +- Name: .rel.text + Type: SHT_REL + Info: .text + AddressAlign: 4 + Relocations: + - Offset: 0x0 + Symbol: _gp_disp + Type: R_MIPS_HI16 + - Offset: 0x4 + Symbol: _gp_disp + Type: R_MIPS_LO16 + - Offset: 0x8 + Symbol: _gp_disp + Type: R_MIPS_HI16 + - Offset: 0xC + Symbol: _gp_disp + Type: R_MIPS_LO16 + - Offset: 0x10 + Symbol: _gp_disp + Type: R_MIPS_HI16 + - Offset: 0x14 + Symbol: _gp_disp + Type: R_MIPS_LO16 + - Offset: 0x18 + Symbol: _gp_disp + Type: R_MIPS_HI16 + - Offset: 0x1C + Symbol: _gp_disp + Type: R_MIPS_LO16 - lui $t0,%hi(_gp_disp+(-0x1ff)) - lh $t0,%lo(_gp_disp+(-0x1ff))($t0) - - lui $t0,%hi(_gp_disp+0x1ffff) - lh $t0,%lo(_gp_disp+0x1ffff)($t0) +Symbols: + Global: + - Name: T0 + Section: .text + Type: STT_FUNC + Value: 0 + Size: 80 + - Name: _gp_disp diff --git a/lld/test/elf/Mips/hilo16-8-micro.test b/lld/test/elf/Mips/hilo16-8-micro.test index 3248804f8f54..02db223857a3 100644 --- a/lld/test/elf/Mips/hilo16-8-micro.test +++ b/lld/test/elf/Mips/hilo16-8-micro.test @@ -1,81 +1,159 @@ -# REQUIRES: mips - # Check calculation of AHL addendums for R_MICROMIPS_HI16 / R_MICROMIPS_LO16 # relocations for a regular symbol. -# -# RUN: llvm-mc -triple=mipsel -mattr=micromips -filetype=obj -o=%t-obj %s -# RUN: lld -flavor gnu -target mipsel -e glob1 -o %t-exe %t-obj -# RUN: llvm-objdump -t -d -mattr=micromips %t-exe | FileCheck %s -# CHECK: Disassembly of section .text: -# CHECK-NEXT: glob1: -# CHECK-NEXT: 400130: a8 41 40 00 lui $8, 64 -# CHECK-NEXT: 400134: 08 3d 6a 01 lh $8, 362($8) -# CHECK-NEXT: 400138: a8 41 41 00 lui $8, 65 -# CHECK-NEXT: 40013c: 08 3d 68 81 lh $8, -32408($8) -# CHECK-NEXT: 400140: a8 41 41 00 lui $8, 65 -# CHECK-NEXT: 400144: 08 3d e9 81 lh $8, -32279($8) -# CHECK-NEXT: 400148: a8 41 42 00 lui $8, 66 -# CHECK-NEXT: 40014c: 08 3d 69 81 lh $8, -32407($8) -# CHECK-NEXT: 400150: a8 41 40 40 lui $8, 16448 -# CHECK-NEXT: 400154: 08 3d 69 01 lh $8, 361($8) -# CHECK-NEXT: 400158: a8 41 40 80 lui $8, 32832 -# CHECK-NEXT: 40015c: 08 3d 69 01 lh $8, 361($8) -# CHECK-NEXT: 400160: a8 41 c1 80 lui $8, 32961 -# CHECK-NEXT: 400164: 08 3d e9 81 lh $8, -32279($8) +# 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: glob2: -# CHECK-NEXT: 400168: a8 41 40 00 lui $8, 64 -# CHECK-NEXT: 40016c: a8 41 40 00 lui $8, 64 -# CHECK-NEXT: 400170: a8 41 41 00 lui $8, 65 -# CHECK-NEXT: 400174: a8 41 42 00 lui $8, 66 -# CHECK-NEXT: 400178: a8 41 40 40 lui $8, 16448 -# CHECK-NEXT: 40017c: a8 41 40 80 lui $8, 32832 -# CHECK-NEXT: 400180: a8 41 c1 80 lui $8, 32961 -# CHECK-NEXT: 400184: 08 3d b1 81 lh $8, -32335($8) +# CHECK: Contents of section .text: +# CHECK-NEXT: 400110 a8414000 083d5201 a8414100 083d5081 +# CHECK-NEXT: 400120 a8414100 083dd181 a8414200 083d5181 +# CHECK-NEXT: 400130 a8414040 083d5101 a8414080 083d5101 +# CHECK-NEXT: 400140 a841c180 083dd181 00000000 00000000 +# CHECK-NEXT: 400150 a8414000 a8414000 a8414100 a8414200 +# CHECK-NEXT: 400160 a8414040 a8414080 a841c180 083d9181 # CHECK: SYMBOL TABLE: -# CHECK: 00400130 g F .text 00000038 glob1 -# CHECK: 00400168 g F .text 00000020 glob2 +# CHECK: 00400110 g F .text 00000020 T0 +# CHECK: 00400130 g F .text 00000018 T1 +# CHECK: 00400150 g F .text 00000020 T2 - .globl glob1 - .type glob1, @function - .set micromips - .ent glob1 -glob1: - lui $t0,%hi(glob2+0x00000001) - lh $t0,%lo(glob2+0x00000001)($t0) +FileHeader: + Class: ELFCLASS32 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_MIPS + Flags: [EF_MIPS_CPIC, EF_MIPS_ABI_O32, EF_MIPS_ARCH_32R2, EF_MIPS_MICROMIPS] - lui $t0,%hi(glob2+0x00007fff) - lh $t0,%lo(glob2+0x00007fff)($t0) +Sections: +- Name: .text.1 + Type: SHT_PROGBITS + Content: "A8410000083D0100A8410000083DFF7FA8410100083D8080A8410200083D0080" +# ^ %hi(T2+1) ^ %hi(T2+0x7fff) ^ %lo(T2+0x8080) +# ^ %lo(T2+1) ^ %lo(T2+0x7fff) ^ %hi(T2+0x18000) +# ^ %hi(T2+0x8080) ^ %lo(T2+0x18000) + AddressAlign: 16 + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] - lui $t0,%hi(glob2+0x00008080) - lh $t0,%lo(glob2+0x00008080)($t0) +- Name: .rel.text.1 + Type: SHT_REL + Info: .text.1 + AddressAlign: 4 + Relocations: + - Offset: 0x0 + Symbol: T2 + Type: R_MICROMIPS_HI16 + - Offset: 0x4 + Symbol: T2 + Type: R_MICROMIPS_LO16 + - Offset: 0x8 + Symbol: T2 + Type: R_MICROMIPS_HI16 + - Offset: 0xC + Symbol: T2 + Type: R_MICROMIPS_LO16 + - Offset: 0x10 + Symbol: T2 + Type: R_MICROMIPS_HI16 + - Offset: 0x14 + Symbol: T2 + Type: R_MICROMIPS_LO16 + - Offset: 0x18 + Symbol: T2 + Type: R_MICROMIPS_HI16 + - Offset: 0x1C + Symbol: T2 + Type: R_MICROMIPS_LO16 - lui $t0,%hi(glob2+0x00018000) - lh $t0,%lo(glob2+0x00018000)($t0) +- Name: .text.2 + Type: SHT_PROGBITS + Content: "A8410040083D0000A8410080083D0000A8418180083D8080" +# ^ %hi(T2+0x40000000) ^ %lo(T2+0x80000000) +# ^ %lo(T2+0x40000000) ^ %hi(T2+0x80808080) +# ^ %hi(T2+0x80000000) ^ %lo(T2+0x80808080) + AddressAlign: 16 + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] - lui $t0,%hi(glob2+0x40000000) - lh $t0,%lo(glob2+0x40000000)($t0) +- Name: .rel.text.2 + Type: SHT_REL + Info: .text.2 + AddressAlign: 4 + Relocations: + - Offset: 0x0 + Symbol: T2 + Type: R_MICROMIPS_HI16 + - Offset: 0x4 + Symbol: T2 + Type: R_MICROMIPS_LO16 + - Offset: 0x8 + Symbol: T2 + Type: R_MICROMIPS_HI16 + - Offset: 0xC + Symbol: T2 + Type: R_MICROMIPS_LO16 + - Offset: 0x10 + Symbol: T2 + Type: R_MICROMIPS_HI16 + - Offset: 0x14 + Symbol: T2 + Type: R_MICROMIPS_LO16 - lui $t0,%hi(glob2+0x80000000) - lh $t0,%lo(glob2+0x80000000)($t0) +- Name: .text.3 + Type: SHT_PROGBITS + Content: "A8410000A8410000A8410100A8410200A8410040A8410080A8418180083D8080" +# ^ %hi(T0+0x1) ^ %hi(T0+0x8080) ^ %hi(T0+0x80000000) +# ^ %hi(T0+0x7fff) ^ %hi(T0+0x40000000) ^ %lo(T0+0x80808080) +# ^ %hi(T0+0x18000) ^ %hi(T0+0x80808080) + AddressAlign: 16 + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] - lui $t0,%hi(glob2+0x80808080) - lh $t0,%lo(glob2+0x80808080)($t0) - .end glob1 +- Name: .rel.text.3 + Type: SHT_REL + Info: .text.3 + AddressAlign: 4 + Relocations: + - Offset: 0x0 + Symbol: T0 + Type: R_MICROMIPS_HI16 + - Offset: 0x4 + Symbol: T0 + Type: R_MICROMIPS_HI16 + - Offset: 0x8 + Symbol: T0 + Type: R_MICROMIPS_HI16 + - Offset: 0xC + Symbol: T0 + Type: R_MICROMIPS_HI16 + - Offset: 0x10 + Symbol: T0 + Type: R_MICROMIPS_HI16 + - Offset: 0x14 + Symbol: T0 + Type: R_MICROMIPS_HI16 + - Offset: 0x18 + Symbol: T0 + Type: R_MICROMIPS_HI16 + - Offset: 0x1C + Symbol: T0 + Type: R_MICROMIPS_LO16 - .globl glob2 - .type glob2, @function - .set micromips - .ent glob2 -glob2: - lui $t0,%hi(glob1+0x00000001) - lui $t0,%hi(glob1+0x00007fff) - lui $t0,%hi(glob1+0x00008080) - lui $t0,%hi(glob1+0x00018000) - lui $t0,%hi(glob1+0x40000000) - lui $t0,%hi(glob1+0x80000000) - lui $t0,%hi(glob1+0x80808080) - lh $t0,%lo(glob1+0x80808080)($t0) - .end glob2 +Symbols: + Global: + - Name: T0 + Section: .text.1 + Type: STT_FUNC + Value: 0 + Size: 32 + Other: [STO_MIPS_MICROMIPS] + - Name: T1 + Section: .text.2 + Type: STT_FUNC + Value: 0 + Size: 24 + Other: [STO_MIPS_MICROMIPS] + - Name: T2 + Section: .text.3 + Type: STT_FUNC + Value: 0 + Size: 32 + Other: [STO_MIPS_MICROMIPS] diff --git a/lld/test/elf/Mips/hilo16-9-micro.test b/lld/test/elf/Mips/hilo16-9-micro.test index 30ad10ce0dd4..fb2eccb20977 100644 --- a/lld/test/elf/Mips/hilo16-9-micro.test +++ b/lld/test/elf/Mips/hilo16-9-micro.test @@ -1,68 +1,142 @@ -# REQUIRES: mips - # Check calculation of AHL addendums for R_MICROMIPS_HI16 / R_MICROMIPS_LO16 # relocations for the _gp_disp symbol. # -# RUN: llvm-mc -triple=mipsel -mattr=micromips -filetype=obj -o=%t-obj %s -# RUN: lld -flavor gnu -target mipsel -shared -o %t-so %t-obj -# RUN: llvm-objdump -t -d -mattr=micromips %t-so | FileCheck %s +# RUN: yaml2obj -format=elf %s > %t.o +# RUN: lld -flavor gnu -target mipsel -shared -o %t.so %t.o +# RUN: llvm-objdump -s -t %t.so | FileCheck %s -# CHECK: Disassembly of section .text: -# CHECK-NEXT: glob1: -# CHECK-NEXT: 130: a8 41 01 00 lui $8, 1 -# CHECK-NEXT: 134: 08 3d c0 9e lh $8, -24896($8) -# CHECK-NEXT: 138: a8 41 01 00 lui $8, 1 -# CHECK-NEXT: 13c: 08 3d b6 1e lh $8, 7862($8) -# CHECK-NEXT: 140: a8 41 01 00 lui $8, 1 -# CHECK-NEXT: 144: 08 3d 2f 1f lh $8, 7983($8) -# CHECK-NEXT: 148: a8 41 02 00 lui $8, 2 -# CHECK-NEXT: 14c: 08 3d a7 1e lh $8, 7847($8) -# CHECK-NEXT: 150: a8 41 01 40 lui $8, 16385 -# CHECK-NEXT: 154: 08 3d 9f 9e lh $8, -24929($8) - -# CHECK: glob2: -# CHECK-NEXT: 158: a8 41 01 00 lui $8, 1 -# CHECK-NEXT: 15c: a8 41 01 00 lui $8, 1 -# CHECK-NEXT: 160: a8 41 02 00 lui $8, 2 -# CHECK-NEXT: 164: a8 41 03 00 lui $8, 3 -# CHECK-NEXT: 168: a8 41 01 40 lui $8, 16385 -# CHECK-NEXT: 16c: 08 3d 87 9e lh $8, -24953($8) +# CHECK: Contents of section .text: +# CHECK-NEXT: 0110 a8410100 083de08e a8410100 083dd60e +# CHECK-NEXT: 0120 a8410200 a841cf8e 00000000 00000000 +# CHECK-NEXT: 0130 083d0200 a841bf8e 083d0080 a841b88e +# CHECK-NEXT: 0140 a8410100 a8410100 a8410200 a8410300 +# CHECK-NEXT: 0150 a8410140 083d9f8e # CHECK: SYMBOL TABLE: -# CHECK: 00000130 g F .text 00000028 glob1 -# CHECK: 00000158 g F .text 00000018 glob2 -# CHECK: 00009ff0 g *ABS* 00000000 _gp_disp +# CHECK: 00000110 g F .text 00000018 T0 +# CHECK: 00000130 g F .text 00000010 T1 +# CHECK: 00000140 g F .text 00000018 T2 +# CHECK: 00008ff0 g *ABS* 00000000 _gp_disp - .globl glob1 - .type glob1, @function - .set micromips - .ent glob1 -glob1: - lui $t0,%hi(_gp_disp+0x00000001) - lh $t0,%lo(_gp_disp+0x00000001)($t0) +FileHeader: + Class: ELFCLASS32 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_MIPS + Flags: [EF_MIPS_CPIC, EF_MIPS_ABI_O32, EF_MIPS_ARCH_32R2, EF_MIPS_MICROMIPS] - lui $t0,%hi(_gp_disp+0x00007fff) - lh $t0,%lo(_gp_disp+0x00007fff)($t0) +Sections: +- Name: .text.1 + Type: SHT_PROGBITS + Content: "A8410000083D0100A8410000083DFF7FA8410100A8410000" +# ^ %hi(gp+0x1) ^ %hi(gp+0x7fff) ^ %lo(gp+0x8080) +# ^ %lo(gp+0x1) ^ %lo(gp+0x7fff) +# ^ %hi(gp+0x8080) + AddressAlign: 16 + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] - lui $t0,%hi(_gp_disp+0x00008080) - lh $t0,%lo(_gp_disp+0x00008080)($t0) +- Name: .rel.text.1 + Type: SHT_REL + Info: .text.1 + AddressAlign: 4 + Relocations: + - Offset: 0x0 + Symbol: _gp_disp + Type: R_MICROMIPS_HI16 + - Offset: 0x4 + Symbol: _gp_disp + Type: R_MICROMIPS_LO16 + - Offset: 0x8 + Symbol: _gp_disp + Type: R_MICROMIPS_HI16 + - Offset: 0xC + Symbol: _gp_disp + Type: R_MICROMIPS_LO16 + - Offset: 0x10 + Symbol: _gp_disp + Type: R_MICROMIPS_HI16 + - Offset: 0x14 + Symbol: _gp_disp + Type: R_MICROMIPS_LO16 - lui $t0,%hi(_gp_disp+0x00018000) - lh $t0,%lo(_gp_disp+0x00018000)($t0) +- Name: .text.2 + Type: SHT_PROGBITS + Content: "083D0100A8410000083DFF7FA8410100" +# ^ %hi(gp+0x18000) ^ %lo(gp+0x40000000) +# ^ %lo(gp+0x18000) +# ^ %hi(gp+0x40000000) + AddressAlign: 16 + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] - lui $t0,%hi(_gp_disp+0x40000000) - lh $t0,%lo(_gp_disp+0x40000000)($t0) - .end glob1 +- Name: .rel.text.2 + Type: SHT_REL + Info: .text.2 + AddressAlign: 4 + Relocations: + - Offset: 0x0 + Symbol: _gp_disp + Type: R_MICROMIPS_HI16 + - Offset: 0x4 + Symbol: _gp_disp + Type: R_MICROMIPS_LO16 + - Offset: 0x8 + Symbol: _gp_disp + Type: R_MICROMIPS_HI16 + - Offset: 0xC + Symbol: _gp_disp + Type: R_MICROMIPS_LO16 - .globl glob2 - .type glob2, @function - .set micromips - .ent glob2 -glob2: - lui $t0,%hi(_gp_disp+0x00000001) - lui $t0,%hi(_gp_disp+0x00007fff) - lui $t0,%hi(_gp_disp+0x00008080) - lui $t0,%hi(_gp_disp+0x00018000) - lui $t0,%hi(_gp_disp+0x40000000) - lh $t0,%lo(_gp_disp+0x40000000)($t0) - .end glob2 +- Name: .text.3 + Type: SHT_PROGBITS + Content: "A8410000A8410000A8410100A8410200A8410040083D0000" +# ^ %hi(gp+0x1) ^ %hi(gp+0x8080) ^ %lo(gp+0x40000000) +# ^ %hi(gp+0x7fff) ^ %hi(gp+0x40000000) +# ^ %hi(gp+0x18000) + AddressAlign: 16 + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + +- Name: .rel.text.3 + Type: SHT_REL + Info: .text.3 + AddressAlign: 4 + Relocations: + - Offset: 0x0 + Symbol: _gp_disp + Type: R_MICROMIPS_HI16 + - Offset: 0x4 + Symbol: _gp_disp + Type: R_MICROMIPS_HI16 + - Offset: 0x8 + Symbol: _gp_disp + Type: R_MICROMIPS_HI16 + - Offset: 0xC + Symbol: _gp_disp + Type: R_MICROMIPS_HI16 + - Offset: 0x10 + Symbol: _gp_disp + Type: R_MICROMIPS_HI16 + - Offset: 0x14 + Symbol: _gp_disp + Type: R_MICROMIPS_LO16 + +Symbols: + Global: + - Name: T0 + Section: .text.1 + Type: STT_FUNC + Value: 0 + Size: 24 + Other: [STO_MIPS_MICROMIPS] + - Name: T1 + Section: .text.2 + Type: STT_FUNC + Value: 0 + Size: 16 + Other: [STO_MIPS_MICROMIPS] + - Name: T2 + Section: .text.3 + Type: STT_FUNC + Value: 0 + Size: 24 + Other: [STO_MIPS_MICROMIPS] + - Name: _gp_disp