forked from OSchip/llvm-project
[ELF2][mips] Support R_MIPS_32 relocation
llvm-svn: 250045
This commit is contained in:
parent
040b31d386
commit
3b732ac7ee
|
@ -365,6 +365,18 @@ bool MipsTargetInfo::relocNeedsPlt(uint32_t Type, const SymbolBody &S) const {
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,@object
|
||||
.size v1,4
|
||||
v1:
|
||||
.word 0
|
||||
|
||||
.globl v2
|
||||
.type v2,@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
|
Loading…
Reference in New Issue