[llvm-dev] llvm-objdump: failed to parse debug information

447 views
Skip to first unread message

Jerome Forissier via llvm-dev

unread,
Apr 28, 2020, 11:57:54 AM4/28/20
to llvm...@lists.llvm.org
Hi,

In a 32-bit ARM build, I am seeing the following warning (edited for
simplicity, I can provide full logs if necessary):

> llvm-objdump -l -d -x file.elf
> llvm-objdump: warning: 'file.elf': failed to parse debug information for file.elf


All object files and static libraries seem to have debug info (i.e.,
llvm-objdump does not complain when run on each file individually and
the disassembly output shows file/line information).

In order to identify where the ELF file is lacking debug info, I added
some debug traces to llvm-objdump and it seems the following symbol is
the culprit: __ThumbV7PILongThunk_<my_func>

Is this expected behavior? How to fix it?

LLVM version is llvmorg-11-init-12683-g54b3f91d205 but AFAICT anything
above 10.0 behaves the same.

Thanks,
--
Jerome
_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

David Blaikie via llvm-dev

unread,
Apr 28, 2020, 12:04:30 PM4/28/20
to Jerome Forissier, llvm...@lists.llvm.org
What does llvm-dwarfdump tell you?

Adrian Prantl via llvm-dev

unread,
Apr 28, 2020, 12:14:55 PM4/28/20
to David Blaikie, llvm...@lists.llvm.org, Jerome Forissier

> On Apr 28, 2020, at 9:03 AM, David Blaikie <dbla...@gmail.com> wrote:
>
> What does llvm-dwarfdump tell you?
>

(particularly `--verify`)

-- adrian

Peter Smith via llvm-dev

unread,
Apr 28, 2020, 12:19:39 PM4/28/20
to llvm...@lists.llvm.org, Jerome Forissier
> Hi,
>
> In a 32-bit ARM build, I am seeing the following warning (edited for
> simplicity, I can provide full logs if necessary):
>
> > llvm-objdump -l -d -x file.elf
> > llvm-objdump: warning: 'file.elf': failed to parse debug information for file.elf
>
>
> All object files and static libraries seem to have debug info (i.e.,
> llvm-objdump does not complain when run on each file individually and
> the disassembly output shows file/line information).
>
> In order to identify where the ELF file is lacking debug info, I added
> some debug traces to llvm-objdump and it seems the following symbol is
> the culprit: __ThumbV7PILongThunk_<my_func>
>
> Is this expected behavior? How to fix it?

It is expected that __ThumbV7PILongThunk_<my_func> has no debug information. A thunk is a linker generated code-sequence to extend the range of a branch. Usually we would want a debugger to step over these bits of code as they are largely there to bridge between functions the user wrote and are not interesting in their own right. There is also the practical consideration that there is no source code for these code-sequences; and as they are called between procedures they are limited in what state they can modify. For example a Thunk in Arm is only permitted to change the inter-procedural scratch register r12.

I would be surprised if missing debug information for a thunk would cause llvm-objdump to give an error message.


> Thanks,
> --
>Jerome

________________________________________
From: llvm-dev <llvm-dev...@lists.llvm.org> on behalf of Jerome Forissier via llvm-dev <llvm...@lists.llvm.org>
Sent: 28 April 2020 15:23
To: llvm...@lists.llvm.org
Subject: [llvm-dev] llvm-objdump: failed to parse debug information

Jerome Forissier via llvm-dev

unread,
Apr 28, 2020, 12:31:50 PM4/28/20
to Adrian Prantl, David Blaikie, llvm...@lists.llvm.org
On 4/28/20 6:14 PM, Adrian Prantl wrote:
>
>
>> On Apr 28, 2020, at 9:03 AM, David Blaikie <dbla...@gmail.com> wrote:
>>
>> What does llvm-dwarfdump tell you?
>>
>
> (particularly `--verify`)

Hmmm... Quite a few errors actually, see here:

https://pastebin.com/9TBqyMM4

--
Jerome

David Blaikie via llvm-dev

unread,
Apr 28, 2020, 12:35:10 PM4/28/20
to Jerome Forissier, llvm...@lists.llvm.org
Hmm, those look like function's that've been optimized out & that's the expected DWARF for them - but the verify stuff was implemented by Apple folks focussing on the MachO debug info distribution model that doesn't have that quirk. Would be good to fix the verifier to not hiccup on that sort of expected linked ELFine DWARF. (Adrian, etc?)

Robinson, Paul via llvm-dev

unread,
Apr 28, 2020, 1:51:01 PM4/28/20
to David Blaikie, Jerome Forissier, llvm...@lists.llvm.org

Agreed.  However, these don’t look like reasons for llvm-objdump to choke.

--paulr

Jerome Forissier via llvm-dev

unread,
Apr 28, 2020, 2:14:49 PM4/28/20
to Peter Smith, llvm...@lists.llvm.org

On 4/28/20 6:19 PM, Peter Smith wrote:
>> Hi,
>>
>> In a 32-bit ARM build, I am seeing the following warning (edited for
>> simplicity, I can provide full logs if necessary):
>>
>>> llvm-objdump -l -d -x file.elf
>>> llvm-objdump: warning: 'file.elf': failed to parse debug information for file.elf
>>
>>
>> All object files and static libraries seem to have debug info (i.e.,
>> llvm-objdump does not complain when run on each file individually and
>> the disassembly output shows file/line information).
>>
>> In order to identify where the ELF file is lacking debug info, I added
>> some debug traces to llvm-objdump and it seems the following symbol is
>> the culprit: __ThumbV7PILongThunk_<my_func>
>>
>> Is this expected behavior? How to fix it?
>
> It is expected that __ThumbV7PILongThunk_<my_func> has no debug information. A thunk is a linker generated code-sequence to extend the range of a branch. Usually we would want a debugger to step over these bits of code as they are largely there to bridge between functions the user wrote and are not interesting in their own right. There is also the practical consideration that there is no source code for these code-sequences; and as they are called between procedures they are limited in what state they can modify. For example a Thunk in Arm is only permitted to change the inter-procedural scratch register r12.
>
> I would be surprised if missing debug information for a thunk would cause llvm-objdump to give an error message.

The reason I mentioned the thunk is because I added debug traces like so:

====
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index 92c130be113..ae1c02d49e8 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -638,7 +638,9 @@ void SourcePrinter::printSourceLine(raw_ostream &OS,
if (LineInfo.FileName == DILineInfo::BadString) {
if (!WarnedNoDebugInfo) {
std::string Warning =
- "failed to parse debug information for " + ObjectFilename.str();
+ "failed to parse debug information for " + ObjectFilename.str() +
+ " Address " + to_string(Address.Address) + " SectionIndex " +
+ to_string(Address.SectionIndex);
if (!ErrorMessage.empty())
Warning += ": " + ErrorMessage;
reportWarning(Warning, ObjectFilename);
====

Which gives:

$ llvm-objdump -l ldelf.elf >/dev/null
llvm-objdump: warning: 'ldelf.elf': failed to parse debug information for ldelf.elf Address 19404 SectionIndex 1

And readelf reports (note that 0x4bcc == 19404):

$ arm-linux-gnueabihf-readelf -a ldelf.elf | grep -E '(] \.text|<.*Thunk)'
[ 1] .text PROGBITS 00000000 001000 004bd8 00 AX 0 0 4
0x4bcc <__ThumbV7PILongThunk_utee_log>: 0x1 [cantunwind]

--
Jerome

Fangrui Song via llvm-dev

unread,
Apr 28, 2020, 2:20:52 PM4/28/20
to Peter Smith via llvm-dev, Jerome Forissier
On 2020-04-28, Peter Smith via llvm-dev wrote:
>> Hi,
>>
>> In a 32-bit ARM build, I am seeing the following warning (edited for
>> simplicity, I can provide full logs if necessary):
>>
>> > llvm-objdump -l -d -x file.elf
>> > llvm-objdump: warning: 'file.elf': failed to parse debug information for file.elf
>>
>>
>> All object files and static libraries seem to have debug info (i.e.,
>> llvm-objdump does not complain when run on each file individually and
>> the disassembly output shows file/line information).
>>
>> In order to identify where the ELF file is lacking debug info, I added
>> some debug traces to llvm-objdump and it seems the following symbol is
>> the culprit: __ThumbV7PILongThunk_<my_func>
>>
>> Is this expected behavior? How to fix it?
>
>It is expected that __ThumbV7PILongThunk_<my_func> has no debug information. A thunk is a linker generated code-sequence to extend the range of a branch. Usually we would want a debugger to step over these bits of code as they are largely there to bridge between functions the user wrote and are not interesting in their own right. There is also the practical consideration that there is no source code for these code-sequences; and as they are called between procedures they are limited in what state they can modify. For example a Thunk in Arm is only permitted to change the inter-procedural scratch register r12.
>
>I would be surprised if missing debug information for a thunk would cause llvm-objdump to give an error message.

The behavior was added by https://reviews.llvm.org/D62462 which intended to address https://bugs.llvm.org/show_bug.cgi?id=41905

I checked some arbitrary ARM/AArch64 programs (lld/test/ELF/*.s) with llvm-objdump -S,
`failed to parse debug information for file.elf` is very easy to trigger (when debug information is not available),
even with programs without thunks.

This seems to me that this particular needs improvement. I will look into this.

Fāng-ruì Sòng via llvm-dev

unread,
Oct 2, 2020, 5:42:56 PM10/2/20
to Peter Smith via llvm-dev, Jerome Forissier
Sent https://reviews.llvm.org/D88715 to drop the --source warning.

--
宋方睿

Reply all
Reply to author
Forward
0 new messages