This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: ELF phdrs in .debug files
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: Roland McGrath <roland at redhat dot com>
- Cc: binutils at sources dot redhat dot com
- Date: Mon, 21 May 2007 22:05:19 +0930
- Subject: Re: ELF phdrs in .debug files
- References: <20070519191051.A03B01F850B@magilla.localdomain>
On Sat, May 19, 2007 at 12:10:51PM -0700, Roland McGrath wrote:
> I am concerned by this change:
>
> 2007-05-11 Alan Modra <amodra@bigpond.net.au>
>
> PR 4479
> * objcopy.c (copy_object): Don't copy ELF program headers for
> --only-keep-debug.
>
> I think this is broken. The phdrs in the .debug file are used by consumers
> to deduce the difference between addresses in the .debug file and those in
> the main stripped file. These will differ when prelink has changed the
> stripped file's phdrs after the .debug file was stripped off.
>
> I don't know if gdb relies on this, but other consumers do.
gdb doesn't, apparently. What other consumers?
I think having program headers in a debug file is fundamentally
broken. After all, the primary purpose of a program header is to tell
an operating system or loader how to go about preparing a program for
executing. A file containing only debug info isn't a program, so the
program header is a lie, potentially confusing the loader.
For example, on Linux, a debug file without headers:
$ ./hello.debug
-bash: ./hello.debug: cannot execute binary file
Now with headers:
$ ./hello.debug.old
Illegal instruction
What's more, having the headers there increases debug file size, by
considerably more than just the space for the headers.
--
Alan Modra
IBM OzLabs - Linux Technology Centre