[lld] r203411 - [Mips] Fix addendum reading for R_MIPS_32 relocation.
Simon Atanasyan
simon at atanasyan.com
Sun Mar 9 06:19:54 PDT 2014
Author: atanasyan
Date: Sun Mar 9 08:19:54 2014
New Revision: 203411
URL: http://llvm.org/viewvc/llvm-project?rev=203411&view=rev
Log:
[Mips] Fix addendum reading for R_MIPS_32 relocation.
Added:
lld/trunk/test/elf/Mips/mips32.test
Modified:
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h?rev=203411&r1=203410&r2=203411&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h Sun Mar 9 08:19:54 2014
@@ -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;
}
};
Added: lld/trunk/test/elf/Mips/mips32.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/Mips/mips32.test?rev=203411&view=auto
==============================================================================
--- lld/trunk/test/elf/Mips/mips32.test (added)
+++ lld/trunk/test/elf/Mips/mips32.test Sun Mar 9 08:19:54 2014
@@ -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 (. at .,.B.
+
+ .global __start
+ .ent __start
+__start:
+ nop
+ .space 0x20000
+la:
+ nop
+ .end __start
+
+ .data
+ .4byte __start
+ .4byte la
More information about the llvm-commits
mailing list