<div dir="ltr">This caused an ASan test to fail: <a href="http://lab.llvm.org:8011/builders/sanitizer-windows/builds/27612/steps/run%20check-asan/logs/stdio">http://lab.llvm.org:8011/builders/sanitizer-windows/builds/27612/steps/run%20check-asan/logs/stdio</a><br><div><br></div><div><div>$ "C:/b/slave/sanitizer-windows/build/./bin/clang.exe" "-fsanitize=address" "-mno-omit-leaf-frame-pointer" "-fno-omit-frame-pointer" "-fno-optimize-sibling-calls" "-gline-tables-only" "-gcodeview" "-gcolumn-info" "-fms-compatibility-version=19.00.24215.1" "-O2" "C:\b\slave\sanitizer-windows\llvm\projects\compiler-rt\test\asan\TestCases\Windows\fuse-lld.cc" "-o" "C:\b\slave\sanitizer-windows\build\projects\compiler-rt\test\asan\I386WindowsConfig\TestCases\Windows\Output\fuse-lld.cc.tmp.exe" "-g" "-gcodeview" "-fuse-ld=lld" "-Wl,-debug"</div><div># command stderr:</div><div>Assertion failed: !Chunks.empty(), file C:\b\slave\sanitizer-windows\llvm\tools\lld\COFF\PDB.cpp, line 821</div></div><div><br></div><div>PTAL</div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Apr 20, 2018 at 11:03 AM Zachary Turner via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: zturner<br>
Date: Fri Apr 20 11:00:46 2018<br>
New Revision: 330457<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=330457&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=330457&view=rev</a><br>
Log:<br>
[LLD/PDB] Emit first section contribution for DBI Module Descriptor.<br>
<br>
Part of the DBI stream is a list of variable length structures<br>
describing each module that contributes to the final executable.<br>
<br>
One member of this structure is a section contribution entry that<br>
describes the first section contribution in the output file for<br>
the given module.<br>
<br>
We have been leaving this structure unpopulated until now, so with<br>
this patch it is now filled out correctly.<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D45832" rel="noreferrer" target="_blank">https://reviews.llvm.org/D45832</a><br>
<br>
Modified:<br>
lld/trunk/COFF/PDB.cpp<br>
lld/trunk/test/COFF/pdb.test<br>
<br>
Modified: lld/trunk/COFF/PDB.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/PDB.cpp?rev=330457&r1=330456&r2=330457&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/PDB.cpp?rev=330457&r1=330456&r2=330457&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/COFF/PDB.cpp (original)<br>
+++ lld/trunk/COFF/PDB.cpp Fri Apr 20 11:00:46 2018<br>
@@ -125,9 +125,6 @@ public:<br>
void addSections(ArrayRef<OutputSection *> OutputSections,<br>
ArrayRef<uint8_t> SectionTable);<br>
<br>
- void addSectionContrib(pdb::DbiModuleDescriptorBuilder &LinkerModule,<br>
- OutputSection *OS, Chunk *C);<br>
-<br>
/// Write the PDB to disk.<br>
void commit();<br>
<br>
@@ -780,6 +777,32 @@ static ArrayRef<uint8_t> relocateDebugCh<br>
".debug$S");<br>
}<br>
<br>
+static pdb::SectionContrib createSectionContrib(const Chunk *C, uint32_t Modi) {<br>
+ OutputSection *OS = C->getOutputSection();<br>
+ pdb::SectionContrib SC;<br>
+ memset(&SC, 0, sizeof(SC));<br>
+ SC.ISect = OS->SectionIndex;<br>
+ SC.Off = C->getRVA() - OS->getRVA();<br>
+ SC.Size = C->getSize();<br>
+ if (auto *SecChunk = dyn_cast<SectionChunk>(C)) {<br>
+ SC.Characteristics = SecChunk->Header->Characteristics;<br>
+ SC.Imod = SecChunk->File->ModuleDBI->getModuleIndex();<br>
+ ArrayRef<uint8_t> Contents = SecChunk->getContents();<br>
+ JamCRC CRC(0);<br>
+ ArrayRef<char> CharContents = makeArrayRef(<br>
+ reinterpret_cast<const char *>(Contents.data()), Contents.size());<br>
+ CRC.update(CharContents);<br>
+ SC.DataCrc = CRC.getCRC();<br>
+ } else {<br>
+ SC.Characteristics = OS->Header.Characteristics;<br>
+ // FIXME: When we start creating DBI for import libraries, use those here.<br>
+ SC.Imod = Modi;<br>
+ }<br>
+ SC.RelocCrc = 0; // FIXME<br>
+<br>
+ return SC;<br>
+}<br>
+<br>
void PDBLinker::addObjFile(ObjFile *File) {<br>
// Add a module descriptor for every object file. We need to put an absolute<br>
// path to the object into the PDB. If this is a plain object, we make its<br>
@@ -794,6 +817,18 @@ void PDBLinker::addObjFile(ObjFile *File<br>
File->ModuleDBI = &ExitOnErr(Builder.getDbiBuilder().addModuleInfo(Name));<br>
File->ModuleDBI->setObjFileName(Path);<br>
<br>
+ auto Chunks = File->getChunks();<br>
+ assert(!Chunks.empty());<br>
+ uint32_t Modi = File->ModuleDBI->getModuleIndex();<br>
+ for (Chunk *C : Chunks) {<br>
+ auto *SecChunk = dyn_cast<SectionChunk>(C);<br>
+ if (!SecChunk || !SecChunk->isLive())<br>
+ continue;<br>
+ pdb::SectionContrib SC = createSectionContrib(SecChunk, Modi);<br>
+ File->ModuleDBI->setFirstSectionContrib(SC);<br>
+ break;<br>
+ }<br>
+<br>
// Before we can process symbol substreams from .debug$S, we need to process<br>
// type information, file checksums, and the string table. Add type info to<br>
// the PDB first, so that we can get the map from object file type and item<br>
@@ -1110,31 +1145,6 @@ void PDBLinker::initialize(const llvm::c<br>
DbiBuilder.setBuildNumber(14, 11);<br>
}<br>
<br>
-void PDBLinker::addSectionContrib(pdb::DbiModuleDescriptorBuilder &LinkerModule,<br>
- OutputSection *OS, Chunk *C) {<br>
- pdb::SectionContrib SC;<br>
- memset(&SC, 0, sizeof(SC));<br>
- SC.ISect = OS->SectionIndex;<br>
- SC.Off = C->getRVA() - OS->getRVA();<br>
- SC.Size = C->getSize();<br>
- if (auto *SecChunk = dyn_cast<SectionChunk>(C)) {<br>
- SC.Characteristics = SecChunk->Header->Characteristics;<br>
- SC.Imod = SecChunk->File->ModuleDBI->getModuleIndex();<br>
- ArrayRef<uint8_t> Contents = SecChunk->getContents();<br>
- JamCRC CRC(0);<br>
- ArrayRef<char> CharContents = makeArrayRef(<br>
- reinterpret_cast<const char *>(Contents.data()), Contents.size());<br>
- CRC.update(CharContents);<br>
- SC.DataCrc = CRC.getCRC();<br>
- } else {<br>
- SC.Characteristics = OS->Header.Characteristics;<br>
- // FIXME: When we start creating DBI for import libraries, use those here.<br>
- SC.Imod = LinkerModule.getModuleIndex();<br>
- }<br>
- SC.RelocCrc = 0; // FIXME<br>
- Builder.getDbiBuilder().addSectionContrib(SC);<br>
-}<br>
-<br>
void PDBLinker::addSections(ArrayRef<OutputSection *> OutputSections,<br>
ArrayRef<uint8_t> SectionTable) {<br>
// It's not entirely clear what this is, but the * Linker * module uses it.<br>
@@ -1150,8 +1160,11 @@ void PDBLinker::addSections(ArrayRef<Out<br>
// Add section contributions. They must be ordered by ascending RVA.<br>
for (OutputSection *OS : OutputSections) {<br>
addLinkerModuleSectionSymbol(LinkerModule, *OS, Alloc);<br>
- for (Chunk *C : OS->getChunks())<br>
- addSectionContrib(LinkerModule, OS, C);<br>
+ for (Chunk *C : OS->getChunks()) {<br>
+ pdb::SectionContrib SC =<br>
+ createSectionContrib(C, LinkerModule.getModuleIndex());<br>
+ Builder.getDbiBuilder().addSectionContrib(SC);<br>
+ }<br>
}<br>
<br>
// Add Section Map stream.<br>
<br>
Modified: lld/trunk/test/COFF/pdb.test<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/pdb.test?rev=330457&r1=330456&r2=330457&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/pdb.test?rev=330457&r1=330456&r2=330457&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/test/COFF/pdb.test (original)<br>
+++ lld/trunk/test/COFF/pdb.test Fri Apr 20 11:00:46 2018<br>
@@ -120,14 +120,16 @@<br>
RAW: Modules<br>
RAW-NEXT: ============================================================<br>
RAW-NEXT: Mod 0000 | `{{.*}}pdb.test.tmp1.obj`:<br>
-RAW-NEXT: SC[???] | mod = 0, 0000:0000, size = 0, data crc = 0, reloc crc = 0<br>
-RAW-NEXT: none<br>
+RAW-NEXT: SC[.text] | mod = 0, 0001:0000, size = 14, data crc = 1682752513, reloc crc = 0<br>
+RAW-NEXT: IMAGE_SCN_CNT_CODE | IMAGE_SCN_ALIGN_16BYTES | IMAGE_SCN_MEM_EXECUTE |<br>
+RAW-NEXT: IMAGE_SCN_MEM_READ<br>
RAW-NEXT: Obj: `{{.*}}pdb.test.tmp1.obj`:<br>
RAW-NEXT: debug stream: 11, # files: 1, has ec info: false<br>
RAW-NEXT: pdb file ni: 0 ``, src file ni: 0 ``<br>
RAW-NEXT: Mod 0001 | `{{.*}}pdb.test.tmp2.obj`:<br>
-RAW-NEXT: SC[???] | mod = 1, 0000:0000, size = 0, data crc = 0, reloc crc = 0<br>
-RAW-NEXT: none<br>
+RAW-NEXT: SC[.text] | mod = 1, 0001:0016, size = 6, data crc = 2139436471, reloc crc = 0<br>
+RAW-NEXT: IMAGE_SCN_CNT_CODE | IMAGE_SCN_ALIGN_16BYTES | IMAGE_SCN_MEM_EXECUTE |<br>
+RAW-NEXT: IMAGE_SCN_MEM_READ<br>
RAW-NEXT: Obj: `{{.*}}pdb.test.tmp2.obj`:<br>
RAW-NEXT: debug stream: 12, # files: 1, has ec info: false<br>
RAW-NEXT: pdb file ni: 0 ``, src file ni: 0 ``<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>