case R_MIPS_HI16:
return {4, 0xffff, 0, false, gpDispCheck<16>};
case R_MIPS_LO16:
+ case R_MIPS_HIGHER:
+ case R_MIPS_HIGHEST:
return {4, 0xffff, 0, false, dummyCheck};
case R_MIPS_16:
case R_MIPS_PCHI16:
return ((value + 0x8000) >> 16) & 0xffff;
}
+static int64_t getHigher16(int64_t value) {
+ return ((value + 0x80008000ull) >> 32) & 0xffff;
+}
+
+static int64_t getHighest16(int64_t value) {
+ return ((value + 0x800080008000ull) >> 48) & 0xffff;
+}
+
static int64_t maskLow16(int64_t value) {
return (value + 0x8000) & ~0xffff;
}
case R_MICROMIPS_GOT_HI16:
case R_MICROMIPS_CALL_HI16:
return getHi16(tgtAddr - gpAddr);
+ case R_MIPS_HIGHER:
+ return getHigher16(tgtAddr + addend);
+ case R_MIPS_HIGHEST:
+ return getHighest16(tgtAddr + addend);
case R_MIPS_EH:
case R_MIPS_GOT16:
case R_MIPS_CALL16:
--- /dev/null
+# Check handling R_MIPS_HIGHER / R_MIPS_HIGHEST relocations.
+
+# RUN: yaml2obj -format=elf %s > %t.o
+# RUN: lld -flavor gnu -target mips64el -e T0 -o %t.exe %t.o
+# RUN: llvm-nm %t.exe | FileCheck -check-prefix=SYM %s
+# RUN: llvm-objdump -s %t.exe | FileCheck -check-prefix=RAW %s
+
+# SYM: 00000001200001a0 T T0
+# SYM: 00000001200001a8 T T1
+
+# RAW: Contents of section .text:
+# RAW-NEXT: 1200001a0 02800000 00000000 01400000 00000000
+
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_MIPS
+ Flags: [EF_MIPS_PIC, EF_MIPS_CPIC, EF_MIPS_ARCH_64]
+
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ AddressAlign: 16
+ Size: 16
+
+ - Name: .rela.text
+ Type: SHT_RELA
+ Flags: [ SHF_INFO_LINK ]
+ Link: .symtab
+ AddressAlign: 8
+ Info: .text
+ Relocations:
+ - Offset: 0
+ Symbol: T1
+ Type: R_MIPS_HIGHER
+ Addend: 0x0000800100000000
+ - Offset: 8
+ Symbol: T1
+ Type: R_MIPS_HIGHEST
+ Addend: 0x4001000000000000
+
+Symbols:
+ Global:
+ - Name: T0
+ Type: STT_FUNC
+ Section: .text
+ Value: 0
+ Size: 8
+ - Name: T1
+ Type: STT_FUNC
+ Section: .text
+ Value: 8
+ Size: 8