From 8d2cbf2e9b788a544f7e46b200a1be403effc708 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Wed, 2 Aug 2017 23:19:54 +0000 Subject: [PATCH] [PDB] Improve our PDB OMF debug directory entry In order to get dbghelp to load our pdb, we have to fill in the PointerToRawData field as well as the AddressOfRawData field. One is the file offset and the other is the RVA. llvm-svn: 309900 --- lld/COFF/Chunks.h | 2 +- lld/COFF/Writer.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lld/COFF/Chunks.h b/lld/COFF/Chunks.h index ddfb5fe..e110760 100644 --- a/lld/COFF/Chunks.h +++ b/lld/COFF/Chunks.h @@ -82,7 +82,7 @@ public: // An output section has pointers to chunks in the section, and each // chunk has a back pointer to an output section. void setOutputSection(OutputSection *O) { Out = O; } - OutputSection *getOutputSection() { return Out; } + OutputSection *getOutputSection() const { return Out; } // Windows-specific. // Collect all locations that contain absolute addresses for base relocations. diff --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp index 2cc1b35..96d31ab1 100644 --- a/lld/COFF/Writer.cpp +++ b/lld/COFF/Writer.cpp @@ -65,8 +65,9 @@ public: D->Type = COFF::IMAGE_DEBUG_TYPE_CODEVIEW; D->SizeOfData = Record->getSize(); D->AddressOfRawData = Record->getRVA(); - // TODO(compnerd) get the file offset - D->PointerToRawData = 0; + OutputSection *OS = Record->getOutputSection(); + uint64_t Offs = OS->getFileOff() + (Record->getRVA() - OS->getRVA()); + D->PointerToRawData = Offs; ++D; } -- 2.7.4