[lld] r240259 - [Mips] Support R_MIPS_HIGHER / R_MIPS_HIGHEST relocations handling
Simon Atanasyan
simon at atanasyan.com
Mon Jun 22 02:25:58 PDT 2015
Author: atanasyan
Date: Mon Jun 22 04:25:57 2015
New Revision: 240259
URL: http://llvm.org/viewvc/llvm-project?rev=240259&view=rev
Log:
[Mips] Support R_MIPS_HIGHER / R_MIPS_HIGHEST relocations handling
Added:
lld/trunk/test/elf/Mips/rel-high-01.test
Modified:
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp?rev=240259&r1=240258&r2=240259&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp Mon Jun 22 04:25:57 2015
@@ -100,6 +100,8 @@ static MipsRelocationParams getRelocatio
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:
@@ -195,6 +197,14 @@ static int64_t getHi16(int64_t value) {
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;
}
@@ -382,6 +392,10 @@ static ErrorOr<int64_t> calculateRelocat
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:
Added: lld/trunk/test/elf/Mips/rel-high-01.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/Mips/rel-high-01.test?rev=240259&view=auto
==============================================================================
--- lld/trunk/test/elf/Mips/rel-high-01.test (added)
+++ lld/trunk/test/elf/Mips/rel-high-01.test Mon Jun 22 04:25:57 2015
@@ -0,0 +1,55 @@
+# 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
More information about the llvm-commits
mailing list