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: ELF phdrs in .debug files


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


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