This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Wrong file name entry in .debug_info section


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]