[PATCH] Fix dumping codeview line tables when there are multiple debug sections
Timur Iskhodzhanov
timurrrr at google.com
Wed Sep 24 10:25:10 PDT 2014
Or I can just generate my own file and commit on your behalf?
2014-09-23 18:01 GMT+04:00 Timur Iskhodzhanov <timurrrr at google.com>:
> Hi Jeff,
>
> Can you please take a look at r218303 and add similar instructions for
> reproducing the object file?
>
> --
> Thanks,
> Tim
>
> 2014-09-22 20:37 GMT+04:00 Eric Christopher <echristo at gmail.com>:
>> No objections here. Thanks!
>>
>> -eric
>>
>> On Mon, Sep 22, 2014 at 3:29 AM, Timur Iskhodzhanov <timurrrr at google.com> wrote:
>>> [Side note: are there any reasons not to use reviews.llvm.org for
>>> these patches?]
>>>
>>>
>>>
>>> 2014-09-20 0:03 GMT+04:00 Jeff Muizelaar <jmuizelaar at mozilla.com>:
>>>> Codeview line tables for functions in different sections refer to a common
>>>> STRING_TABLE_SUBSECTION for filenames. This happens
>>>> when building with -Gy or with inline functions with MSVC.
>>>>
>>>> diff --git a/test/tools/llvm-readobj/Inputs/comdat-function-linetables.obj.coff-2008-i386 b/test/tools/llvm-readobj/Inputs/comdat-function-linetables.obj.coff-2008-i386
>>>> new file mode 100644
>>>> index 0000000000000000000000000000000000000000..45416d52c3644aeb8395820268d36693e78d7431
>>>> GIT binary patch
>>>> literal 1635
>>>> zcmcIkF>ljQ5I)zWX$mTC#lX<vQAL6Z>}Du}7OJLAn}SGa)TC7 at 29elKFiPquc1p_B
>>>> zfeoaxvcbf{!Uhrx>IxeYKLQpg2qA>Zou8j^3T$xF`Q3f*-uK at 5-n*O>ht~^Fi}4u1
>>>> z5OC4VmSuPwR^Y-I8mA=T1!KPgnrT(qwPaDuJi?f(`{L4|%xa$1 at k9`g{ixr2A^@69
>>>> zDcso4_Y(1#4Dbq-1dj-5<<ES(L5v at WpTF__z_=F&cvQ&8^C*e6!)Uw at VgyEcFviB_
>>>> z=Cd=)xl-=p?Boc3GWpU-H at KLayF8PhFOD!`_=viTIt0=nQDr7|&vHG at soa7|I6o*c
>>>> zfH)k+nM6kl$GmN{9M`FO?8MS2TWorE!@gs$*I34BH0`?8g2ym52*z!b2*Ie+P-r=|
>>>> zR=L5l7~tx^C{}E at U9PjD*EVg3O=u~7C8JmDb=|0IR>uOPVS<`<A}3>N)<k#1m`G_&
>>>> zv%*w^sSBG-T|2|nRi@@kOf41A1h-{?pN?Sw2GS|SBFyMB>QPj>5sGx=&G6Ul@$H*$
>>>> zPe1HQ=%eTOe`(_!7{O0LmSic#l2)b3rf{&EjQnwSl3n)!#0lVz%bl}0i@`a6Ml&kK
>>>> z@`hzDSv8lbgcp3Af^e=-#vkO;0@`- at -iPOO1+MK-rM{phQH9VYjmjZ(=#Gi1UPAjg
>>>> zD1KE%9Ic_4K2%8&s8oev7z$kh2P3|N9_R)5gnlYAC-x^kaW0JAA|G{&_Q11j(YYu#
>>>> z4y%E65cI(6hx;M+AjBwd-0=VBUHeyg$Ai2vXFu;mkT<;>o;O)MZ?bsa9HYEBMwROY
>>>> z$?tLl(5Hkg2}_eU at MUSXndsbwy*>KF>8e%sv{Z_2FGr$nkx*G0!*91lTNrgXS)!)c
>>>> zEzx%9S5p$Tez(&&#@|bnht4faelrY+WWN=XLvtiDFuX=lX1dvO$h`UN+mqj!=@xV|
>>>> m$3o at -qD6^u=17agYTznrlHEdYeY%=XUzxeEx(3rVVf_REpWBT9
>>>>
>>>> literal 0
>>>> HcmV?d00001
>>>>
>>>> diff --git a/test/tools/llvm-readobj/codeview-linetables.test b/test/tools/llvm-readobj/codeview-linetables.test
>>>> index 4854d7a..b908a59 100644
>>>> --- a/test/tools/llvm-readobj/codeview-linetables.test
>>>> +++ b/test/tools/llvm-readobj/codeview-linetables.test
>>>> @@ -6,6 +6,8 @@ RUN: llvm-readobj -s -codeview-linetables %p/Inputs/multifile-linetables.obj.cof
>>>> RUN: | FileCheck %s -check-prefix MFILE32
>>>> RUN: llvm-readobj -s -codeview-linetables %p/Inputs/multifile-linetables.obj.coff-2012-x86_64 \
>>>> RUN: | FileCheck %s -check-prefix MFILE64
>>>> +RUN: llvm-readobj -s -codeview-linetables %p/Inputs/comdat-function-linetables.obj.coff-2008-i386 \
>>>> +RUN: | FileCheck %s -check-prefix MCOMDAT
>>>>
>>>> MFUN32: CodeViewLineTables [
>>>> MFUN32-NEXT: Magic: 0x4
>>>> @@ -280,3 +282,24 @@ MFILE64-NEXT: +0x13: 8
>>>> MFILE64-NEXT: ]
>>>> MFILE64-NEXT: ]
>>>> MFILE64-NEXT: ]
>>>> +
>>>> +MCOMDAT: FunctionLineTable [
>>>> +MCOMDAT-NEXT: FunctionName: ?f@@YAHXZ
>>>> +MCOMDAT-NEXT: CodeSize: 0xA
>>>> +MCOMDAT-NEXT: FilenameSegment [
>>>> +MCOMDAT-NEXT: Filename: c:\test.cc
>>>> +MCOMDAT-NEXT: +0x0: 2
>>>> +MCOMDAT-NEXT: +0x3: 3
>>>> +MCOMDAT-NEXT: +0x8: 4
>>>> +MCOMDAT-NEXT: ]
>>>> +MCOMDAT-NEXT: ]
>>>> +MCOMDAT: FunctionLineTable [
>>>> +MCOMDAT-NEXT: FunctionName: ?g@@YAHXZ
>>>> +MCOMDAT-NEXT: CodeSize: 0xA
>>>> +MCOMDAT-NEXT: FilenameSegment [
>>>> +MCOMDAT-NEXT: Filename: c:\test.cc
>>>> +MCOMDAT-NEXT: +0x0: 7
>>>> +MCOMDAT-NEXT: +0x3: 8
>>>> +MCOMDAT-NEXT: +0x8: 9
>>>> +MCOMDAT-NEXT: ]
>>>> +MCOMDAT-NEXT: ]
>>>> diff --git a/tools/llvm-readobj/COFFDumper.cpp b/tools/llvm-readobj/COFFDumper.cpp
>>>> index 68a403c..4940481 100644
>>>> --- a/tools/llvm-readobj/COFFDumper.cpp
>>>> +++ b/tools/llvm-readobj/COFFDumper.cpp
>>>> @@ -78,6 +78,8 @@ private:
>>>>
>>>> const llvm::object::COFFObjectFile *Obj;
>>>> RelocMapTy RelocMap;
>>>> + StringRef CVFileIndexToStringOffsetTable;
>>>> + StringRef CVStringTable;
>>>> };
>>>>
>>>> } // namespace
>>>
>>> Eric,
>>> Are you fine with adding these fields to the COFFDumper class?
>>>
>>>> @@ -440,8 +442,6 @@ void COFFDumper::printCodeViewLineTables(const SectionRef &Section) {
>>>>
>>>> SmallVector<StringRef, 10> FunctionNames;
>>>> StringMap<StringRef> FunctionLineTables;
>>>> - StringRef FileIndexToStringOffsetTable;
>>>> - StringRef StringTable;
>>>>
>>>> ListScope D(W, "CodeViewLineTables");
>>>> {
>>>> @@ -502,25 +502,25 @@ void COFFDumper::printCodeViewLineTables(const SectionRef &Section) {
>>>> break;
>>>> }
>>>> case COFF::DEBUG_STRING_TABLE_SUBSECTION:
>>>> - if (PayloadSize == 0 || StringTable.data() != nullptr ||
>>>> + if (PayloadSize == 0 || CVStringTable.data() != nullptr ||
>>>> Contents.back() != '\0') {
>>>> // Empty or duplicate or non-null-terminated subsection.
>>>> error(object_error::parse_failed);
>>>> return;
>>>> }
>>>> - StringTable = Contents;
>>>> + CVStringTable = Contents;
>>>> break;
>>>> case COFF::DEBUG_INDEX_SUBSECTION:
>>>> // Holds the translation table from file indices
>>>> // to offsets in the string table.
>>>>
>>>> if (PayloadSize == 0 ||
>>>> - FileIndexToStringOffsetTable.data() != nullptr) {
>>>> + CVFileIndexToStringOffsetTable.data() != nullptr) {
>>>> // Empty or duplicate subsection.
>>>> error(object_error::parse_failed);
>>>> return;
>>>> }
>>>> - FileIndexToStringOffsetTable = Contents;
>>>> + CVFileIndexToStringOffsetTable = Contents;
>>>> break;
>>>> }
>>>> Offset += PayloadSize;
>>>> @@ -555,7 +555,7 @@ void COFFDumper::printCodeViewLineTables(const SectionRef &Section) {
>>>>
>>>> uint32_t FilenameOffset;
>>>> {
>>>> - DataExtractor SDE(FileIndexToStringOffsetTable, true, 4);
>>>> + DataExtractor SDE(CVFileIndexToStringOffsetTable, true, 4);
>>>> uint32_t OffsetInSDE = OffsetInIndex;
>>>> if (!SDE.isValidOffset(OffsetInSDE)) {
>>>> error(object_error::parse_failed);
>>>> @@ -564,15 +564,15 @@ void COFFDumper::printCodeViewLineTables(const SectionRef &Section) {
>>>> FilenameOffset = SDE.getU32(&OffsetInSDE);
>>>> }
>>>>
>>>> - if (FilenameOffset == 0 || FilenameOffset + 1 >= StringTable.size() ||
>>>> - StringTable.data()[FilenameOffset - 1] != '\0') {
>>>> + if (FilenameOffset == 0 || FilenameOffset + 1 >= CVStringTable.size() ||
>>>> + CVStringTable.data()[FilenameOffset - 1] != '\0') {
>>>> // Each string in an F3 subsection should be preceded by a null
>>>> // character.
>>>> error(object_error::parse_failed);
>>>> return;
>>>> }
>>>>
>>>> - StringRef Filename(StringTable.data() + FilenameOffset);
>>>> + StringRef Filename(CVStringTable.data() + FilenameOffset);
>>>> ListScope S(W, "FilenameSegment");
>>>> W.printString("Filename", Filename);
>>>> for (unsigned J = 0; J != SegmentLength && DE.isValidOffset(Offset);
>>>>
>>>> W.printString("Filename", Filename);
>>>> for (unsigned J = 0; J != SegmentLength && DE.isValidOffset(Offset);
>>>>
>>>
>>> Otherwise LGTM
More information about the llvm-commits
mailing list