Index: lld/trunk/ELF/Arch/Mips.cpp =================================================================== --- lld/trunk/ELF/Arch/Mips.cpp +++ lld/trunk/ELF/Arch/Mips.cpp @@ -101,8 +101,6 @@ case R_MIPS_HIGHEST: case R_MICROMIPS_HI16: case R_MICROMIPS_LO16: - case R_MICROMIPS_HIGHER: - case R_MICROMIPS_HIGHEST: // R_MIPS_HI16/R_MIPS_LO16 relocations against _gp_disp calculate // offset between start of function and 'gp' value which by default // equal to the start of .got section. In that case we consider these @@ -124,8 +122,6 @@ case R_MIPS_TLS_TPREL_LO16: case R_MIPS_TLS_TPREL32: case R_MIPS_TLS_TPREL64: - case R_MICROMIPS_GOT_OFST: - case R_MICROMIPS_SUB: case R_MICROMIPS_TLS_DTPREL_HI16: case R_MICROMIPS_TLS_DTPREL_LO16: case R_MICROMIPS_TLS_TPREL_HI16: @@ -155,7 +151,6 @@ case R_MIPS_GOT_DISP: case R_MIPS_TLS_GOTTPREL: case R_MICROMIPS_CALL16: - case R_MICROMIPS_GOT_DISP: case R_MICROMIPS_TLS_GOTTPREL: return R_MIPS_GOT_OFF; case R_MIPS_CALL_HI16: @@ -168,7 +163,6 @@ case R_MICROMIPS_GOT_LO16: return R_MIPS_GOT_OFF32; case R_MIPS_GOT_PAGE: - case R_MICROMIPS_GOT_PAGE: return R_MIPS_GOT_LOCAL_PAGE; case R_MIPS_TLS_GD: case R_MICROMIPS_TLS_GD: @@ -457,9 +451,6 @@ return std::make_pair(Type2, Val); if (Type2 == R_MIPS_SUB && (Type3 == R_MIPS_HI16 || Type3 == R_MIPS_LO16)) return std::make_pair(Type3, -Val); - if (Type2 == R_MICROMIPS_SUB && - (Type3 == R_MICROMIPS_HI16 || Type3 == R_MICROMIPS_LO16)) - return std::make_pair(Type3, -Val); error(getErrorLocation(Loc) + "unsupported relocations combination " + Twine(Type)); return std::make_pair(Type & 0xff, Val); @@ -538,8 +529,6 @@ case R_MIPS_TLS_TPREL_LO16: writeValue(Loc, Val, 16, 0); break; - case R_MICROMIPS_GOT_DISP: - case R_MICROMIPS_GOT_PAGE: case R_MICROMIPS_GPREL16: case R_MICROMIPS_TLS_GD: case R_MICROMIPS_TLS_LDM: @@ -548,7 +537,6 @@ break; case R_MICROMIPS_CALL16: case R_MICROMIPS_CALL_LO16: - case R_MICROMIPS_GOT_OFST: case R_MICROMIPS_LO16: case R_MICROMIPS_TLS_DTPREL_LO16: case R_MICROMIPS_TLS_GOTTPREL: @@ -580,12 +568,6 @@ case R_MIPS_HIGHEST: writeValue(Loc, Val + 0x800080008000, 16, 48); break; - case R_MICROMIPS_HIGHER: - writeShuffleValue(Loc, Val + 0x80008000, 16, 32); - break; - case R_MICROMIPS_HIGHEST: - writeShuffleValue(Loc, Val + 0x800080008000, 16, 48); - break; case R_MIPS_JALR: case R_MICROMIPS_JALR: // Ignore this optimization relocation for now @@ -653,7 +635,7 @@ template bool MIPS::usesOnlyLowPageBits(RelType Type) const { return Type == R_MIPS_LO16 || Type == R_MIPS_GOT_OFST || - Type == R_MICROMIPS_LO16 || Type == R_MICROMIPS_GOT_OFST; + Type == R_MICROMIPS_LO16; } // Return true if the symbol is a PIC function. Index: lld/trunk/ELF/Arch/MipsArchTree.cpp =================================================================== --- lld/trunk/ELF/Arch/MipsArchTree.cpp +++ lld/trunk/ELF/Arch/MipsArchTree.cpp @@ -64,12 +64,21 @@ static StringRef getFpName(bool IsFp64) { return IsFp64 ? "64" : "32"; } +static void rejectMicroMips64(const FileFlags &F) { + if (Config->Is64 && F.Flags & EF_MIPS_MICROMIPS) + error("linking microMIPS 64-bit files is unsupported: " + toString(F.File)); +} + static void checkFlags(ArrayRef Files) { uint32_t ABI = Files[0].Flags & (EF_MIPS_ABI | EF_MIPS_ABI2); bool Nan = Files[0].Flags & EF_MIPS_NAN2008; bool Fp = Files[0].Flags & EF_MIPS_FP64; + rejectMicroMips64(Files[0]); + for (const FileFlags &F : Files.slice(1)) { + rejectMicroMips64(F); + uint32_t ABI2 = F.Flags & (EF_MIPS_ABI | EF_MIPS_ABI2); if (ABI != ABI2) error("target ABI '" + getAbiName(ABI) + "' is incompatible with '" + Index: lld/trunk/test/ELF/mips-micro-got64.s =================================================================== --- lld/trunk/test/ELF/mips-micro-got64.s +++ lld/trunk/test/ELF/mips-micro-got64.s @@ -1,53 +0,0 @@ -# REQUIRES: mips -# Check microMIPS GOT relocations for N64 ABI. - -# microMIPS 64-bit is unsupported by LLVM starting from r335057. -# But such code can be generated by GCC. Mark this test as XFAIL -# while decide to drop microMIPS 64-bit support from LLD too or -# use binary inputs for the test. -# XFAIL: * - -# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux -mattr=micromips \ -# RUN: %s -o %t1.o -# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux -mattr=micromips \ -# RUN: %S/Inputs/mips-dynamic.s -o %t2.o -# RUN: ld.lld %t2.o -shared -o %t.so -# RUN: ld.lld %t1.o %t.so -o %t.exe -# RUN: llvm-readobj -mips-plt-got %t.exe | FileCheck %s - -# CHECK: Local entries [ -# CHECK-NEXT: Entry { -# CHECK-NEXT: Address: -# CHECK-NEXT: Access: -32736 -# CHECK-NEXT: Initial: 0x30000 -# CHECK-NEXT: } -# CHECK-NEXT: Entry { -# CHECK-NEXT: Address: -# CHECK-NEXT: Access: -32728 -# CHECK-NEXT: Initial: 0x40000 -# CHECK-NEXT: } -# CHECK-NEXT: ] -# CHECK-NEXT: Global entries [ -# CHECK-NEXT: Entry { -# CHECK-NEXT: Address: -# CHECK-NEXT: Access: -32720 -# CHECK-NEXT: Initial: 0x0 -# CHECK-NEXT: Value: 0x0 -# CHECK-NEXT: Type: Function -# CHECK-NEXT: Section: Undefined -# CHECK-NEXT: Name: foo0 -# CHECK-NEXT: } -# CHECK-NEXT: ] - - .text - .global __start -__start: - lui $28, %hi(%neg(%gp_rel(foo0))) - addiu $28, $28, %lo(%neg(%gp_rel(foo0))) - lw $4, %got_page(data)($28) - addiu $4, $4, %got_ofst(data) - lw $25, %call16(foo0)($28) - - .data -data: - .word 0 Index: lld/trunk/test/ELF/mips-micro64-reject.test =================================================================== --- lld/trunk/test/ELF/mips-micro64-reject.test +++ lld/trunk/test/ELF/mips-micro64-reject.test @@ -0,0 +1,23 @@ +# REQUIRES: mips +# +# Check that the linker rejects microMIPS64 input files. + +# RUN: yaml2obj %s -o %t.o +# RUN: not ld.lld %t.o -shared -o %t.so 2>&1 | FileCheck %s + +# CHECK: linking microMIPS 64-bit files is unsupported: {{.*}}mips-micro64-reject.test + +!ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2MSB + Type: ET_REL + Machine: EM_MIPS + Flags: [ EF_MIPS_MICROMIPS, EF_MIPS_ARCH_64 ] + +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Content: 00000000 + Index: lld/trunk/test/ELF/mips-micro64-relocs.s =================================================================== --- lld/trunk/test/ELF/mips-micro64-relocs.s +++ lld/trunk/test/ELF/mips-micro64-relocs.s @@ -1,28 +0,0 @@ -# REQUIRES: mips - -# microMIPS 64-bit is unsupported by LLVM starting from r335057. -# But such code can be generated by GCC. Mark this test as XFAIL -# while decide to drop microMIPS 64-bit support from LLD too or -# use binary inputs for the test. -# XFAIL: * - -# Check handling of some microMIPS relocations in 64-bit mode. - -# RUN: llvm-mc -filetype=obj -triple=mips64el-unknown-linux \ -# RUN: -mattr=micromips %s -o %t1.o -# RUN: llvm-mc -filetype=obj -triple=mips64el-unknown-linux \ -# RUN: -mattr=micromips %S/Inputs/mips-dynamic.s -o %t2.o -# RUN: ld.lld %t1.o %t2.o -o %t.exe -# RUN: llvm-objdump -d %t.exe | FileCheck %s - - .global __start -__start: - lui $7, %highest(_foo+0x300047FFF7FF8) - lui $7, %higher (_foo+0x300047FFF7FF8) - lui $gp, %hi(%neg(%gp_rel(__start))) - lui $gp, %lo(%neg(%gp_rel(__start))) - -# CHECK: 20000: a7 41 03 00 lui $7, 3 -# CHECK-NEXT: 20004: a7 41 05 00 lui $7, 5 -# CHECK-NEXT: 20008: bc 41 02 00 lui $gp, 2 -# CHECK-NEXT: 2000c: bc 41 00 80 lui $gp, 32768 Index: lld/trunk/test/ELF/mips-non-zero-gp0.s =================================================================== --- lld/trunk/test/ELF/mips-non-zero-gp0.s +++ lld/trunk/test/ELF/mips-non-zero-gp0.s @@ -8,8 +8,6 @@ # # as -mips32 -o test.o \ # && ld.bfd -m elf32btsmip -r test.o -o mips-gp0-non-zero.o -# as -mips64 -mmicromips -o test.o \ -# && ld.bfd -m elf64btsmip -r test.o -o mips-micro-gp0-non-zero.o # as -mips64 -o test.o \ # && ld.bfd -m elf64btsmip -r test.o -o mips-n64-gp0-non-zero.o @@ -44,11 +42,6 @@ # RUN: llvm-readobj -r %S/Inputs/mips-n64-gp0-non-zero.o %t-64.r \ # RUN: | FileCheck --check-prefix=ADDEND64 %s -# RUN: ld.lld -r -o %t-micro.r %S/Inputs/mips-micro-gp0-non-zero.o -# RUN: llvm-readobj -mips-options %t-micro.r | FileCheck --check-prefix=GPVAL %s -# RUN: llvm-readobj -r %S/Inputs/mips-micro-gp0-non-zero.o %t-micro.r \ -# RUN: | FileCheck --check-prefix=ADDENDMM %s - # GPVAL: GP: 0x0 # ADDEND32: Contents of section .rodata: @@ -59,8 +52,3 @@ # ADDEND64: .text 0xFFFFFFFFFFFF8011 # ADDEND64: File: {{.*}}{{/|\\}}mips-non-zero-gp0.s.tmp-64.r # ADDEND64: .text 0x0 - -# ADDENDMM: File: {{.*}}{{/|\\}}mips-micro-gp0-non-zero.o -# ADDENDMM: .text 0xFFFFFFFFFFFF8012 -# ADDENDMM: File: {{.*}}{{/|\\}}mips-non-zero-gp0.s.tmp-micro.r -# ADDENDMM: .text 0x1