summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp b/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
index 0abf9dbf9c8..820a920f2b7 100644
--- a/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
+++ b/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
@@ -43,6 +43,7 @@
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/FileOutputBuffer.h"
+#include "llvm/Support/Format.h"
using llvm::support::ulittle16_t;
using llvm::support::ulittle32_t;
@@ -330,6 +331,17 @@ public:
}
}
+ /// Print atom VAs. Used only for debugging.
+ void printAtomAddresses(uint64_t baseAddr) {
+ for (const auto *layout : _atomLayouts) {
+ const DefinedAtom *atom = cast<DefinedAtom>(layout->_atom);
+ uint64_t addr = layout->_virtualAddr;
+ llvm::dbgs() << llvm::format("0x%08llx: ", addr + baseAddr)
+ << (atom->name().empty() ? "(anonymous)" : atom->name())
+ << "\n";
+ }
+ }
+
/// List all the relocation sites that need to be fixed up if image base is
/// relocated. Such relocation types are DIR32 and DIR32NB on i386. REL32 does
/// not be (and should not be) fixed up because it's PC-relative.
@@ -822,6 +834,7 @@ public:
for (const auto &chunk : _chunks)
chunk->write(buffer->getBufferStart());
applyAllRelocations(buffer->getBufferStart());
+ DEBUG(printAllAtomAddresses());
return buffer->commit();
}
@@ -837,6 +850,13 @@ private:
_PECOFFLinkingContext.getBaseAddress());
}
+ /// Print atom VAs. Used only for debugging.
+ void printAllAtomAddresses() {
+ for (auto &cp : _chunks)
+ if (AtomChunk *chunk = dyn_cast<AtomChunk>(&*cp))
+ chunk->printAtomAddresses(_PECOFFLinkingContext.getBaseAddress());
+ }
+
void addChunk(Chunk *chunk) {
_chunks.push_back(std::unique_ptr<Chunk>(chunk));
}
OpenPOWER on IntegriCloud