This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Wrong file name entry in .debug_info section
- From: Nick Clifton <nickc at redhat dot com>
- To: kamlesh kumar <kamleshbhalui at gmail dot com>, binutils at sourceware dot org
- Date: Fri, 3 Aug 2018 11:40:05 +0100
- Subject: Re: Wrong file name entry in .debug_info section
- References: <CABKRkgg+-1fs88FS7Hefpppo=xXfmqd=Ep0c3Pr+MMpXHZirpg@mail.gmail.com>
Hi Kamlesh,
> gcc -g -c -xassembler-with-cpp -P hello.s
> readelf --debug-dump hello.o | grep DW_AT_name
>
> I get following:
>
> DW_AT_name :/tmp/cc8P6Tw2.s
>
> which is a temporary file generated by compiler now no more exist.>
> Why gas is putting wrong file name there.
Because that is the name of the input file that is passed to the assembler.
You can work around this in a rather cumbersome fashion by saving the compiler's
output into a temporary file of your own that is named after the input file:
gcc -g -S -xassembler-with-cpp -P hello.s > /tmp/hello.s
gcc -g -o hello.o /tmp/hello.s
readelf --debug-dump hello.o | grep DW_AT_name
<20> DW_AT_name : (indirect string, offset: 0x0): /tmp/hello.s
And of course you can play games with temporary directories in
order to get rid of the /tmp/ prefix to the DW_AT_name value.
> Even if compiler put *.file="hello.s" * at top of hello.s .
> why gas is not using that info?
Because there can be multiple .file directives in a single assembler source
file, so the assembler does not know which one to choose. Nor does it know
that the input file name is incorrect. The user might very well have created
a file called cc8P6Tw2.s, it is not for the assembler to decide that this name
is invalid.
Cheers
Nick