[Mips] Fix addendum reading for R_MIPS_32 relocation.
llvm-svn: 203411
This commit is contained in:
parent
0f96aca940
commit
c146325b26
|
@ -68,9 +68,19 @@ private:
|
|||
auto *ref = new (this->_readerStorage)
|
||||
ELFReference<ELFT>(&ri, ri.r_offset - symbol.st_value, this->kindArch(),
|
||||
ri.getType(isMips64EL), ri.getSymbol(isMips64EL));
|
||||
int32_t addend =
|
||||
*(int16_t *)(content.data() + ri.r_offset - symbol.st_value);
|
||||
ref->setAddend(addend);
|
||||
const uint8_t *ap = content.data() + ri.r_offset - symbol.st_value;
|
||||
switch (ri.getType(isMips64EL)) {
|
||||
case R_MIPS_32:
|
||||
ref->setAddend(*(int32_t *)ap);
|
||||
break;
|
||||
case R_MIPS_26:
|
||||
ref->setAddend(*(int16_t *)ap);
|
||||
break;
|
||||
case R_MIPS_HI16:
|
||||
case R_MIPS_LO16:
|
||||
ref->setAddend(*(int16_t *)ap);
|
||||
break;
|
||||
}
|
||||
return ref;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
# Check handling R_MIPS_32 relocation.
|
||||
#
|
||||
# RUN: llvm-mc -triple=mipsel -filetype=obj -o=%t-obj %s
|
||||
# RUN: lld -flavor gnu -target mipsel -o %t-exe %t-obj
|
||||
# RUN: llvm-objdump -s %t-exe | FileCheck %s
|
||||
|
||||
# CHECK: Contents of section .data:
|
||||
# CHECK-NEXT: 422000 28014000 2c014200 (.@.,.B.
|
||||
|
||||
.global __start
|
||||
.ent __start
|
||||
__start:
|
||||
nop
|
||||
.space 0x20000
|
||||
la:
|
||||
nop
|
||||
.end __start
|
||||
|
||||
.data
|
||||
.4byte __start
|
||||
.4byte la
|
Loading…
Reference in New Issue