[PATCH] [lld][ELF] Use TargetRelocationHandler to apply relocations.

Michael Spencer bigcheesegs at gmail.com
Tue Jan 29 17:54:44 PST 2013


Hi shankarke, khemant,

Note that this patch breaks all ELF targets except x86-64 because they don't have a TargetRelocationHandler yet. This would be fixed before committing.

http://llvm-reviews.chandlerc.com/D349

Files:
  lib/ReaderWriter/ELF/SectionChunks.h

Index: lib/ReaderWriter/ELF/SectionChunks.h
===================================================================
--- lib/ReaderWriter/ELF/SectionChunks.h
+++ lib/ReaderWriter/ELF/SectionChunks.h
@@ -358,19 +358,11 @@
       continue;
     uint8_t *atomContent = chunkBuffer + ai->_fileOffset;
     std::copy_n(content.data(), contentSize, atomContent);
-    for (const auto ref : *definedAtom) {
-      uint32_t offset = ref->offsetInAtom();
-      uint64_t targetAddress = 0;
-      assert(ref->target() != nullptr && "Found the target to be NULL");
-      targetAddress = writer->addressOfAtom(ref->target());
-      uint64_t fixupAddress = writer->addressOfAtom(ai->_atom) + offset;
-      // apply the relocation
-      writer->kindHandler()->applyFixup(ref->kind(),
-                                        ref->addend(),
-                                        &atomContent[offset],
-                                        fixupAddress,
-                                        targetAddress);
-    }
+    const TargetRelocationHandler<ELFT> &relHandler =
+        this->_targetInfo.template getTargetHandler<ELFT>()
+        .getRelocationHandler();
+    for (const auto ref : *definedAtom)
+      relHandler.applyRelocation(*writer, buffer, *ai, *ref);
   }
 }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D349.1.patch
Type: text/x-patch
Size: 1272 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130129/36dbcad6/attachment.bin>


More information about the llvm-commits mailing list