mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-14 03:29:57 +00:00
[coff] Remove dots in path pointing to PDB file.
Some Microsoft tools (e.g. new versions of WPA) fail when the COFF Debug Directory contains a path to the PDB that contains dots, such as D:\foo\./bar.pdb. Remove dots before writing this path. This fixes pr38126. llvm-svn: 336873
This commit is contained in:
parent
a9d84cb9d8
commit
bf9abccacd
@ -122,7 +122,7 @@ private:
|
||||
class CVDebugRecordChunk : public Chunk {
|
||||
public:
|
||||
size_t getSize() const override {
|
||||
return sizeof(codeview::DebugInfo) + Config->PDBAltPath.size() + 1;
|
||||
return sizeof(codeview::DebugInfo) + Path.size() + 1;
|
||||
}
|
||||
|
||||
void writeTo(uint8_t *B) const override {
|
||||
@ -132,11 +132,12 @@ public:
|
||||
|
||||
// variable sized field (PDB Path)
|
||||
char *P = reinterpret_cast<char *>(B + OutputSectionOff + sizeof(*BuildId));
|
||||
if (!Config->PDBAltPath.empty())
|
||||
memcpy(P, Config->PDBAltPath.data(), Config->PDBAltPath.size());
|
||||
P[Config->PDBAltPath.size()] = '\0';
|
||||
if (!Path.empty())
|
||||
memcpy(P, Path.data(), Path.size());
|
||||
P[Path.size()] = '\0';
|
||||
}
|
||||
|
||||
SmallString<128> Path;
|
||||
mutable codeview::DebugInfo *BuildId = nullptr;
|
||||
};
|
||||
|
||||
@ -509,6 +510,8 @@ 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);
|
||||
|
10
lld/test/COFF/pdb-exe-path-dots.test
Normal file
10
lld/test/COFF/pdb-exe-path-dots.test
Normal file
@ -0,0 +1,10 @@
|
||||
RUN: yaml2obj < %p/Inputs/pdb1.yaml > %t1.obj
|
||||
RUN: yaml2obj < %p/Inputs/pdb2.yaml > %t2.obj
|
||||
RUN: rm -rf %t
|
||||
RUN: mkdir %t
|
||||
RUN: mkdir %t/foo
|
||||
RUN: lld-link /debug /pdb:%t/foo/./out.pdb /out:%t/out.exe /entry:main /nodefaultlib \
|
||||
RUN: %t1.obj %t2.obj
|
||||
RUN: llvm-readobj -coff-debug-directory %t/out.exe | FileCheck %s
|
||||
|
||||
CHECK: PDBFileName: {{.*}}tmp{{/|\\}}foo{{/|\\}}out.pdb
|
Loading…
Reference in New Issue
Block a user