diff options
author | Eric Christopher <echristo@gmail.com> | 2012-12-27 01:07:07 +0000 |
---|---|---|
committer | Eric Christopher <echristo@gmail.com> | 2012-12-27 01:07:07 +0000 |
commit | 32b3768ec1ae95cb05d1f595d31761c510c43251 (patch) | |
tree | 83fe4e23d856304392ba9b04ef62b642a228065c /include/llvm/Object/RelocVisitor.h | |
parent | 5dd839430c1dbce6cd35dc44f68718a1fc69bfba (diff) |
Right now all of the relocations are 32-bit dwarf, and the relocation
information doesn't return an addend for Rel relocations. Go ahead
and use this information to fix relocation handling inside dwarfdump
for 32-bit ELF REL.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171126 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Object/RelocVisitor.h')
-rw-r--r-- | include/llvm/Object/RelocVisitor.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/include/llvm/Object/RelocVisitor.h b/include/llvm/Object/RelocVisitor.h index 9b12946c3a..2c2dd03b0d 100644 --- a/include/llvm/Object/RelocVisitor.h +++ b/include/llvm/Object/RelocVisitor.h @@ -64,6 +64,18 @@ public: HasError = true; return RelocToApply(); } + } else if (FileFormat == "ELF32-i386") { + switch (RelocType) { + case llvm::ELF::R_386_NONE: + return visitELF_386_NONE(R); + case llvm::ELF::R_386_32: + return visitELF_386_32(R, Value); + case llvm::ELF::R_386_PC32: + return visitELF_386_PC32(R, Value, SecAddr); + default: + HasError = true; + return RelocToApply(); + } } return RelocToApply(); } @@ -76,6 +88,28 @@ private: /// Operations + /// 386-ELF + RelocToApply visitELF_386_NONE(RelocationRef R) { + return RelocToApply(0, 0); + } + + // Ideally the Addend here will be the addend in the data for + // the relocation. It's not actually the case for Rel relocations. + RelocToApply visitELF_386_32(RelocationRef R, uint64_t Value) { + int64_t Addend; + R.getAdditionalInfo(Addend); + return RelocToApply(Value + Addend, 4); + } + + RelocToApply visitELF_386_PC32(RelocationRef R, uint64_t Value, + uint64_t SecAddr) { + int64_t Addend; + R.getAdditionalInfo(Addend); + uint64_t Address; + R.getAddress(Address); + return RelocToApply(Value + Addend - Address, 4); + } + /// X86-64 ELF RelocToApply visitELF_X86_64_NONE(RelocationRef R) { return RelocToApply(0, 0); |