[lld] r336873 - [coff] Remove dots in path pointing to PDB file.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 11 18:35:23 PDT 2018


But PDBAltPath is intended to be the path that ends up in the output file
(either the exact value of /pdbaltpath or something derived from /pdbpath).
PDBPath is closer to what the user passed as /pdbpath. Also this code
appears to removing dots from paths specified via /pdbaltpath; I checked
and it looks like link.exe does not do that.

Peter

On Wed, Jul 11, 2018 at 6:27 PM, Zachary Turner <zturner at google.com> wrote:

> I considered that, but decided against it because sometimes you want the
> exact original thing typed in (for example when displaying error messages
> or other feedback to the user).  I don't mind changing it though.
>
> On Wed, Jul 11, 2018 at 6:24 PM Peter Collingbourne <peter at pcc.me.uk>
> wrote:
>
>> Should the remove_dots happen when we assign to PDBAltPath in Driver.cpp?
>> That would save needing to have another copy of the path
>> in CVDebugRecordChunk.
>>
>> Peter
>>
>> On Wed, Jul 11, 2018 at 5:44 PM, Zachary Turner via llvm-commits <
>> llvm-commits at lists.llvm.org> wrote:
>>
>>> Author: zturner
>>> Date: Wed Jul 11 17:44:15 2018
>>> New Revision: 336873
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=336873&view=rev
>>> Log:
>>> [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.
>>>
>>> Added:
>>>     lld/trunk/test/COFF/pdb-exe-path-dots.test
>>> Modified:
>>>     lld/trunk/COFF/Writer.cpp
>>>
>>> Modified: lld/trunk/COFF/Writer.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Writer.
>>> cpp?rev=336873&r1=336872&r2=336873&view=diff
>>> ============================================================
>>> ==================
>>> --- lld/trunk/COFF/Writer.cpp (original)
>>> +++ lld/trunk/COFF/Writer.cpp Wed Jul 11 17:44:15 2018
>>> @@ -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);
>>>
>>> Added: lld/trunk/test/COFF/pdb-exe-path-dots.test
>>> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/
>>> pdb-exe-path-dots.test?rev=336873&view=auto
>>> ============================================================
>>> ==================
>>> --- lld/trunk/test/COFF/pdb-exe-path-dots.test (added)
>>> +++ lld/trunk/test/COFF/pdb-exe-path-dots.test Wed Jul 11 17:44:15 2018
>>> @@ -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
>>> \ No newline at end of file
>>>
>>>
>>> _______________________________________________
>>> llvm-commits mailing list
>>> llvm-commits at lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>>
>>
>>
>>
>> --
>> --
>> Peter
>>
>


-- 
-- 
Peter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180711/649ca21b/attachment.html>


More information about the llvm-commits mailing list