[lld] r240267 - [Mips] Support R_MICROMIPS_LITERAL relocation handling
Simon Atanasyan
simon at atanasyan.com
Mon Jun 22 02:26:57 PDT 2015
Author: atanasyan
Date: Mon Jun 22 04:26:57 2015
New Revision: 240267
URL: http://llvm.org/viewvc/llvm-project?rev=240267&view=rev
Log:
[Mips] Support R_MICROMIPS_LITERAL relocation handling
Added:
lld/trunk/test/elf/Mips/rel-lit-micro.test
Modified:
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.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=240267&r1=240266&r2=240267&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp Mon Jun 22 04:26:57 2015
@@ -129,6 +129,7 @@ static MipsRelocationParams getRelocatio
case R_MIPS_TLS_TPREL_LO16:
return {4, 0xffff, 0, false, dummyCheck};
case R_MICROMIPS_GPREL16:
+ case R_MICROMIPS_LITERAL:
return {4, 0xffff, 0, true, signedCheck<16>};
case R_MICROMIPS_GPREL7_S2:
return {4, 0x7f, 2, false, signedCheck<9>};
@@ -459,6 +460,7 @@ static ErrorOr<int64_t> calculateRelocat
case R_MIPS_LITERAL:
case R_MICROMIPS_GPREL16:
case R_MICROMIPS_GPREL7_S2:
+ case R_MICROMIPS_LITERAL:
return tgtAddr + addend - gpAddr;
case R_MIPS_JALR:
case R_MICROMIPS_JALR:
@@ -636,6 +638,7 @@ Reference::Addend readMipsRelocAddend(Re
case R_MICROMIPS_GPREL16:
case R_MIPS_PCLO16:
case R_MIPS_LITERAL:
+ case R_MICROMIPS_LITERAL:
return llvm::SignExtend32<16>(res);
case R_MICROMIPS_GPREL7_S2:
return llvm::SignExtend32<9>(res);
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp?rev=240267&r1=240266&r2=240267&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp Mon Jun 22 04:26:57 2015
@@ -579,6 +579,7 @@ void RelocationPass<ELFT>::handleReferen
case R_MICROMIPS_GPREL16:
case R_MICROMIPS_GPREL7_S2:
case R_MIPS_LITERAL:
+ case R_MICROMIPS_LITERAL:
if (isLocal(ref.target()))
ref.setAddend(ref.addend() + atom.file().getGP0());
break;
@@ -626,6 +627,7 @@ static bool isConstrainSym(const MipsELF
case R_MICROMIPS_GPREL16:
case R_MICROMIPS_GPREL7_S2:
case R_MIPS_LITERAL:
+ case R_MICROMIPS_LITERAL:
return false;
default:
return true;
Added: lld/trunk/test/elf/Mips/rel-lit-micro.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/Mips/rel-lit-micro.test?rev=240267&view=auto
==============================================================================
--- lld/trunk/test/elf/Mips/rel-lit-micro.test (added)
+++ lld/trunk/test/elf/Mips/rel-lit-micro.test Mon Jun 22 04:26:57 2015
@@ -0,0 +1,59 @@
+# Check handling of R_MICROMIPS_LITERAL relocation.
+
+# 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: 400130 00000f10
+# ^ 0x402000 + 0x7fff - 0x408ff0 = 0x100f
+
+# CHECK: 00402000 g .data 00000004 D0
+# CHECK: 00408ff0 g *ABS* 00000000 _gp_disp
+
+---
+FileHeader:
+ Class: ELFCLASS32
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_MIPS
+ Flags: [EF_MIPS_PIC, EF_MIPS_CPIC, EF_MIPS_ABI_O32,
+ EF_MIPS_ARCH_32, EF_MIPS_MICROMIPS]
+
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ AddressAlign: 16
+ Content: "0000ff7f"
+
+ - Name: .rel.text
+ Type: SHT_REL
+ Link: .symtab
+ AddressAlign: 4
+ Info: .text
+ Relocations:
+ - Offset: 0
+ Symbol: D0
+ Type: R_MICROMIPS_LITERAL
+
+ - Name: .data
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_WRITE ]
+ AddressAlign: 16
+ Size: 4
+
+Symbols:
+ Global:
+ - Name: T0
+ Type: STT_FUNC
+ Section: .text
+ Value: 0
+ Size: 4
+ Other: [STO_MIPS_MICROMIPS]
+ - Name: D0
+ Type: STT_OBJECT
+ Section: .data
+ Value: 0
+ Size: 4
+...
More information about the llvm-commits
mailing list