[lld] r250045 - [ELF2][mips] Support R_MIPS_32 relocation
Simon Atanasyan via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 12 08:10:02 PDT 2015
Author: atanasyan
Date: Mon Oct 12 10:10:02 2015
New Revision: 250045
URL: http://llvm.org/viewvc/llvm-project?rev=250045&view=rev
Log:
[ELF2][mips] Support R_MIPS_32 relocation
Added:
lld/trunk/test/elf2/mips-relocs.s
Modified:
lld/trunk/ELF/Target.cpp
Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=250045&r1=250044&r2=250045&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Mon Oct 12 10:10:02 2015
@@ -365,6 +365,18 @@ bool MipsTargetInfo::relocNeedsPlt(uint3
}
void MipsTargetInfo::relocateOne(uint8_t *Buf, const void *RelP, uint32_t Type,
- uint64_t BaseAddr, uint64_t SymVA) const {}
+ uint64_t BaseAddr, uint64_t SymVA) const {
+ typedef ELFFile<ELF32LE>::Elf_Rel Elf_Rel;
+ auto &Rel = *reinterpret_cast<const Elf_Rel *>(RelP);
+
+ switch (Type) {
+ case R_MIPS_32:
+ add32le(Buf + Rel.r_offset, SymVA);
+ break;
+ default:
+ error(Twine("unrecognized reloc ") + Twine(Type));
+ break;
+ }
+}
}
}
Added: lld/trunk/test/elf2/mips-relocs.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/mips-relocs.s?rev=250045&view=auto
==============================================================================
--- lld/trunk/test/elf2/mips-relocs.s (added)
+++ lld/trunk/test/elf2/mips-relocs.s Mon Oct 12 10:10:02 2015
@@ -0,0 +1,31 @@
+# Check R_MIPS_32 relocation calculation.
+# RUN: llvm-mc -filetype=obj -triple=mipsel-unknown-linux %s -o %t.o
+# RUN: ld.lld2 %t.o -o %t.exe
+# RUN: llvm-objdump -s -t %t.exe | FileCheck %s
+
+# REQUIRES: mips
+
+ .globl __start
+__start:
+ nop
+
+ .data
+ .type v1, at object
+ .size v1,4
+v1:
+ .word 0
+
+ .globl v2
+ .type v2, at object
+ .size v2,8
+v2:
+ .word v2+4 # R_MIPS_32 target v2 addend 4
+ .word v1 # R_MIPS_32 target v1 addend 0
+
+# CHECK: Contents of section .data:
+# CHECK-NEXT: 420000 00000000 08004200 00004200
+# ^-- v2+4 ^-- v1
+
+# CHECK: SYMBOL TABLE:
+# CHECK: 00420000 l .data 00000004 v1
+# CHECK: 00420004 g .data 00000008 v2
More information about the llvm-commits
mailing list