[lld] r173911 - [ELF] Use TargetRelocationHandler to apply relocations.

Michael J. Spencer bigcheesegs at gmail.com
Tue Jan 29 23:46:31 PST 2013


Author: mspencer
Date: Wed Jan 30 01:46:31 2013
New Revision: 173911

URL: http://llvm.org/viewvc/llvm-project?rev=173911&view=rev
Log:
[ELF] Use TargetRelocationHandler to apply relocations.

Modified:
    lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h

Modified: lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h?rev=173911&r1=173910&r2=173911&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h Wed Jan 30 01:46:31 2013
@@ -370,19 +370,11 @@ void Section<ELFT>::write(ELFWriter *wri
       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);
   }
 }
 





More information about the llvm-commits mailing list