mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-17 04:50:15 +00:00
[PDB] More changes to bring lld PDBs to parity with MSVC.
1) Don't write a /src/headerblock stream. This appears to be written conditionally by MSVC, but it's not clear what the condition is. For now, just remove it since we dont' know what it is anyway and the particular pdb we've checked in for the test doesn't have one. 2) Write a valid timestamp for the PDB file signature. This leads to non-reproducible builds, but it matches the default behavior of link, so it should be out default as well. If we need reproducibility, we should add a separate command line option for it that is off by default. 3) Write an empty FPO stream. MSVC seems to always write an FPO stream. This change makes the stream directory match up, although we still need to make the contents of the FPO stream match. llvm-svn: 307436
This commit is contained in:
parent
e3872003d0
commit
3a11fdf8ce
@ -412,7 +412,6 @@ void coff::createPDB(StringRef Path, SymbolTable *Symtab,
|
||||
// Add an Info stream.
|
||||
auto &InfoBuilder = Builder.getInfoBuilder();
|
||||
InfoBuilder.setAge(DI ? DI->PDB70.Age : 0);
|
||||
InfoBuilder.setSignature(time(nullptr));
|
||||
|
||||
llvm::SmallString<128> NativePath(Path.begin(), Path.end());
|
||||
llvm::sys::fs::make_absolute(NativePath);
|
||||
@ -422,13 +421,13 @@ void coff::createPDB(StringRef Path, SymbolTable *Symtab,
|
||||
if (DI)
|
||||
memcpy(&uuid, &DI->PDB70.Signature, sizeof(uuid));
|
||||
InfoBuilder.setGuid(uuid);
|
||||
// Should be the current time, but set 0 for reproducibilty.
|
||||
InfoBuilder.setSignature(0);
|
||||
InfoBuilder.setSignature(time(nullptr));
|
||||
InfoBuilder.setVersion(pdb::PdbRaw_ImplVer::PdbImplVC70);
|
||||
|
||||
// Add an empty DBI stream.
|
||||
pdb::DbiStreamBuilder &DbiBuilder = Builder.getDbiBuilder();
|
||||
DbiBuilder.setVersionHeader(pdb::PdbDbiV70);
|
||||
ExitOnErr(DbiBuilder.addDbgStream(pdb::DbgHeaderType::NewFPO, {}));
|
||||
|
||||
// It's not entirely clear what this is, but the * Linker * module uses it.
|
||||
uint32_t PdbFilePathNI = DbiBuilder.addECName(NativePath);
|
||||
|
@ -37,14 +37,14 @@ CHECK-NEXT: | DBI Stream | I |
|
||||
CHECK-NEXT: |------------------------------+---|
|
||||
CHECK-NEXT: | IPI Stream | I |
|
||||
CHECK-NEXT: |------------------------------+---|
|
||||
CHECK-NEXT: | New FPO Data | {{[EI]}} |
|
||||
CHECK-NEXT: |------------------------------+---|
|
||||
CHECK-NEXT: | Section Header Data | {{[EI]}} |
|
||||
CHECK-NEXT: |------------------------------+---|
|
||||
CHECK-NEXT: | Named Stream "/names" | {{[EI]}} |
|
||||
CHECK-NEXT: |------------------------------+---|
|
||||
CHECK-NEXT: | Named Stream "/LinkInfo" | {{[EI]}} |
|
||||
CHECK-NEXT: |------------------------------+---|
|
||||
CHECK-NEXT: | Named Stream "/src/heade..." | D |
|
||||
CHECK-NEXT: |------------------------------+---|
|
||||
CHECK-NEXT: | Module "{{.*}}\pdb-diff.obj" | {{[EI]}} |
|
||||
CHECK-NEXT: |------------------------------+---|
|
||||
CHECK-NEXT: | Module "* Linker *" | {{[EI]}} |
|
||||
@ -59,8 +59,6 @@ CHECK-NEXT: | Public Symbol Hash | D |
|
||||
CHECK-NEXT: |------------------------------+---|
|
||||
CHECK-NEXT: | Public Symbol Records | D |
|
||||
CHECK-NEXT: |------------------------------+---|
|
||||
CHECK-NEXT: | New FPO Data | D |
|
||||
CHECK-NEXT: |------------------------------+---|
|
||||
CHECK-NEXT: ------------------------------------
|
||||
CHECK-NEXT: | String Table |
|
||||
CHECK-NEXT: |------------------------------+---|
|
||||
@ -101,15 +99,13 @@ CHECK-NEXT: | Features (set) | I |
|
||||
CHECK-NEXT: |----------------------+---|
|
||||
CHECK-NEXT: | Feature | I |
|
||||
CHECK-NEXT: |----------------------+---|
|
||||
CHECK-NEXT: | Named Stream Size | D |
|
||||
CHECK-NEXT: | Named Stream Size |
|
||||
CHECK-NEXT: |----------------------+---|
|
||||
CHECK-NEXT: | Named Streams (map) | D |
|
||||
CHECK-NEXT: | Named Streams (map) | {{[EI]}} |
|
||||
CHECK-NEXT: |----------------------+---|
|
||||
CHECK-NEXT: | /names | I |
|
||||
CHECK-NEXT: | /names | {{[EI]}} |
|
||||
CHECK-NEXT: |----------------------+---|
|
||||
CHECK-NEXT: | /LinkInfo | E |
|
||||
CHECK-NEXT: |----------------------+---|
|
||||
CHECK-NEXT: | /src/headerblock | D |
|
||||
CHECK-NEXT: | /LinkInfo | {{[EI]}} |
|
||||
CHECK-NEXT: |----------------------+---|
|
||||
CHECK-NEXT: ----------------------------------------------
|
||||
CHECK-NEXT: | DBI Stream |
|
||||
@ -152,7 +148,7 @@ CHECK-NEXT: | DBG (Xdata) | I |
|
||||
CHECK-NEXT: |----------------------------------------+---|
|
||||
CHECK-NEXT: | DBG (Pdata) | I |
|
||||
CHECK-NEXT: |----------------------------------------+---|
|
||||
CHECK-NEXT: | DBG (NewFPO) | D |
|
||||
CHECK-NEXT: | DBG (NewFPO) | {{[EI]}} |
|
||||
CHECK-NEXT: |----------------------------------------+---|
|
||||
CHECK-NEXT: | DBG (SectionHdrOrig) | I |
|
||||
CHECK-NEXT: |----------------------------------------+---|
|
||||
|
@ -7,8 +7,8 @@
|
||||
|
||||
# CHECK: PdbStream:
|
||||
# CHECK-NEXT: Age: 0
|
||||
# CHECK-NEXT: Guid: '{00000000-0000-0000-0000-000000000000}'
|
||||
# CHECK-NEXT: Signature: 0
|
||||
# CHECK-NEXT: Guid:
|
||||
# CHECK-NEXT: Signature:
|
||||
# CHECK-NEXT: Features: [ VC140 ]
|
||||
# CHECK-NEXT: Version: VC70
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
# CHECK: PdbStream:
|
||||
# CHECK-NEXT: Age: 1
|
||||
# CHECK-NEXT: Guid:
|
||||
# CHECK-NEXT: Signature: 0
|
||||
# CHECK-NEXT: Signature:
|
||||
# CHECK-NEXT: Features: [ VC140 ]
|
||||
# CHECK-NEXT: Version: VC70
|
||||
# CHECK-NEXT: DbiStream:
|
||||
@ -186,17 +186,17 @@ RAW-NEXT: IMAGE_SCN_MEM_READ
|
||||
RAW: Section Map
|
||||
RAW-NEXT: ============================================================
|
||||
RAW-NEXT: Section 0000 | ovl = 0, group = 0, frame = 0, name = 1
|
||||
RAW-NEXT: class = 65535, offset = 0, size =
|
||||
RAW-NEXT: class = 65535, offset = 0, size =
|
||||
RAW-NEXT: flags = read | 32 bit addr | selector
|
||||
RAW-NEXT: Section 0001 | ovl = 1, group = 0, frame = 0, name = 2
|
||||
RAW-NEXT: class = 65535, offset = 0, size =
|
||||
RAW-NEXT: class = 65535, offset = 0, size =
|
||||
RAW-NEXT: flags = read | execute | 32 bit addr | selector
|
||||
RAW-NEXT: Section 0002 | ovl = 2, group = 0, frame = 0, name = 3
|
||||
RAW-NEXT: class = 65535, offset = 0, size =
|
||||
RAW-NEXT: class = 65535, offset = 0, size =
|
||||
RAW-NEXT: flags = read | 32 bit addr | selector
|
||||
RAW-NEXT: Section 0003 | ovl = 3, group = 0, frame = 0, name = 4
|
||||
RAW-NEXT: class = 65535, offset = 0, size =
|
||||
RAW-NEXT: class = 65535, offset = 0, size =
|
||||
RAW-NEXT: flags = read | 32 bit addr | selector
|
||||
RAW-NEXT: Section 0004 | ovl = 4, group = 0, frame = 0, name = 5
|
||||
RAW-NEXT: class = 65535, offset = 0, size =
|
||||
RAW-NEXT: class = 65535, offset = 0, size =
|
||||
RAW-NEXT: flags = 32 bit addr | absolute addr
|
||||
|
@ -86,7 +86,8 @@ Error NamedStreamMap::commit(BinaryStreamWriter &Writer) const {
|
||||
|
||||
for (const auto &Name : OrderedStreamNames) {
|
||||
auto Item = Mapping.find(Name);
|
||||
assert(Item != Mapping.end());
|
||||
if (Item == Mapping.end())
|
||||
continue;
|
||||
if (auto EC = Writer.writeCString(Item->getKey()))
|
||||
return EC;
|
||||
}
|
||||
@ -108,7 +109,8 @@ uint32_t NamedStreamMap::finalize() {
|
||||
|
||||
for (const auto &Name : OrderedStreamNames) {
|
||||
auto Item = Mapping.find(Name);
|
||||
assert(Item != Mapping.end());
|
||||
if (Item == Mapping.end())
|
||||
continue;
|
||||
FinalizedHashTable.set(FinalizedInfo->StringDataBytes, Item->getValue());
|
||||
FinalizedInfo->StringDataBytes += Item->getKeyLength() + 1;
|
||||
}
|
||||
|
@ -96,8 +96,6 @@ Expected<msf::MSFLayout> PDBFileBuilder::finalizeMsfLayout() {
|
||||
return std::move(EC);
|
||||
if (auto EC = addNamedStream("/LinkInfo", 0))
|
||||
return std::move(EC);
|
||||
if (auto EC = addNamedStream("/src/headerblock", 0))
|
||||
return std::move(EC);
|
||||
|
||||
if (Info) {
|
||||
if (auto EC = Info->finalizeMsfLayout())
|
||||
|
Loading…
Reference in New Issue
Block a user