[lld] r206023 - [Mips] Factor out MIPS relocation addend reading to the separate
Simon Atanasyan
simon at atanasyan.com
Fri Apr 11 00:25:35 PDT 2014
Author: atanasyan
Date: Fri Apr 11 02:25:35 2014
New Revision: 206023
URL: http://llvm.org/viewvc/llvm-project?rev=206023&view=rev
Log:
[Mips] Factor out MIPS relocation addend reading to the separate
function.
No functional changes.
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=206023&r1=206022&r2=206023&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h Fri Apr 11 02:25:35 2014
@@ -105,22 +105,26 @@ private:
auto *ref = new (this->_readerStorage)
ELFReference<ELFT>(&ri, ri.r_offset - symbol.st_value, this->kindArch(),
ri.getType(isMips64EL), ri.getSymbol(isMips64EL));
+ ref->setAddend(readAddend(symbol, ri, content));
+ return ref;
+ }
+
+ Reference::Addend readAddend(const Elf_Sym &symbol, const Elf_Rel &ri,
+ ArrayRef<uint8_t> content) const {
const uint8_t *ap = content.data() + ri.r_offset - symbol.st_value;
- switch (ri.getType(isMips64EL)) {
+ switch (ri.getType(this->_objFile->isMips64EL())) {
case llvm::ELF::R_MIPS_32:
case llvm::ELF::R_MIPS_PC32:
- ref->setAddend(*(int32_t *)ap);
- break;
+ return *(int32_t *)ap;
case llvm::ELF::R_MIPS_26:
- ref->setAddend(*(int32_t *)ap & 0x3ffffff);
- break;
+ return *(int32_t *)ap & 0x3ffffff;
case llvm::ELF::R_MIPS_HI16:
case llvm::ELF::R_MIPS_LO16:
case llvm::ELF::R_MIPS_GOT16:
- ref->setAddend(*(int16_t *)ap);
- break;
+ return *(int16_t *)ap;
+ default:
+ return 0;
}
- return ref;
}
};
More information about the llvm-commits
mailing list