[lld] r336882 - [coff] remove_dots from /PDBPATH but not /PDBALTPATH.
Zachary Turner via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 11 20:22:39 PDT 2018
Author: zturner
Date: Wed Jul 11 20:22:39 2018
New Revision: 336882
URL: http://llvm.org/viewvc/llvm-project?rev=336882&view=rev
Log:
[coff] remove_dots from /PDBPATH but not /PDBALTPATH.
This more closely matches the behavior of link.exe, and also
simplifies the code slightly.
Modified:
lld/trunk/COFF/Driver.cpp
lld/trunk/COFF/Writer.cpp
Modified: lld/trunk/COFF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Driver.cpp?rev=336882&r1=336881&r2=336882&view=diff
==============================================================================
--- lld/trunk/COFF/Driver.cpp (original)
+++ lld/trunk/COFF/Driver.cpp Wed Jul 11 20:22:39 2018
@@ -1384,7 +1384,12 @@ void LinkerDriver::link(ArrayRef<const c
// /pdbaltpath flag was passed.
if (Config->PDBAltPath.empty()) {
Config->PDBAltPath = Config->PDBPath;
+
+ // It's important to make the path absolute and remove dots. This path
+ // will eventually be written into the PE header, and certain Microsoft
+ // tools won't work correctly if these assumptions are not held.
sys::fs::make_absolute(Config->PDBAltPath);
+ sys::path::remove_dots(Config->PDBAltPath);
}
}
Modified: lld/trunk/COFF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Writer.cpp?rev=336882&r1=336881&r2=336882&view=diff
==============================================================================
--- lld/trunk/COFF/Writer.cpp (original)
+++ lld/trunk/COFF/Writer.cpp Wed Jul 11 20:22:39 2018
@@ -122,7 +122,7 @@ private:
class CVDebugRecordChunk : public Chunk {
public:
size_t getSize() const override {
- return sizeof(codeview::DebugInfo) + Path.size() + 1;
+ return sizeof(codeview::DebugInfo) + Config->PDBAltPath.size() + 1;
}
void writeTo(uint8_t *B) const override {
@@ -132,12 +132,11 @@ public:
// variable sized field (PDB Path)
char *P = reinterpret_cast<char *>(B + OutputSectionOff + sizeof(*BuildId));
- if (!Path.empty())
- memcpy(P, Path.data(), Path.size());
- P[Path.size()] = '\0';
+ if (!Config->PDBAltPath.empty())
+ memcpy(P, Config->PDBAltPath.data(), Config->PDBAltPath.size());
+ P[Config->PDBAltPath.size()] = '\0';
}
- SmallString<128> Path;
mutable codeview::DebugInfo *BuildId = nullptr;
};
@@ -510,8 +509,6 @@ void Writer::createMiscChunks() {
// if we're ultimately not going to write CodeView data to the PDB.
auto *CVChunk = make<CVDebugRecordChunk>();
BuildId = CVChunk;
- CVChunk->Path = Config->PDBAltPath;
- llvm::sys::path::remove_dots(CVChunk->Path);
DebugRecords.push_back(CVChunk);
RdataSec->addChunk(DebugDirectory);
More information about the llvm-commits
mailing list