summaryrefslogtreecommitdiffstats
path: root/lld/COFF
diff options
context:
space:
mode:
Diffstat (limited to 'lld/COFF')
-rw-r--r--lld/COFF/Driver.cpp5
-rw-r--r--lld/COFF/Writer.cpp11
2 files changed, 9 insertions, 7 deletions
diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp
index b6019ffec95..cba89a83cd7 100644
--- a/lld/COFF/Driver.cpp
+++ b/lld/COFF/Driver.cpp
@@ -1384,7 +1384,12 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
// /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);
}
}
diff --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp
index adb15c85686..e9b21df478a 100644
--- a/lld/COFF/Writer.cpp
+++ b/lld/COFF/Writer.cpp
@@ -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);
OpenPOWER on IntegriCloud