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 Mon, May 21, 2007 at 06:56:19PM -0700, Roland McGrath wrote:
> > gdb doesn't, apparently.  What other consumers?
> 
> elfutils libdwfl.  There may be others we aren't aware of.  To begin with,
> it's an incompatible, information-losing ABI change, and I think that alone
> ought to be enough not to do it lightly.

You're going overboard with the rhetoric.  The fact is that libdwfl is
making use of information that no one has promised would be available,
that originally was not available with --only-keep-debug, and is only
in debug info files by accident.

> libdwfl follows the phdrs to find the
> difference between debug file addresses and stripped file addresses, which
> is a robust and very efficient method.

I'd say it is very fragile.  For starters, you have no guarantee that
the program headers will be available in debug info files.  ;-)
Leaving that aside, copying program headers is not as simple as you
seem to think.  See elf.c:copy_elf_program_header,
elf_modify_segment_map, _bfd_elf_map_sections_to_segments.  Even if we
revert my patch to remove the headers, I'm almost certain there will
be cases where objcopy generates different program headers in a debug
info file to those in the main executable.

If you want reliable copied headers, you are imposing a maintenance
burden on anyone touching BFD.

[snip]
> For example, on Linux, a nonprogram without execute permission:
> $ echo lose faster > foobar
> $ ./foobar
> bash: ./foobar: Permission denied
> 
> Now with execute permission:
> $ chmod +x foobar
> $ ./foobar
> ./foobar:1: lose: command not found
> 
> Your point?  (Mine is, "So don't do that.")

My point was to show that including program headers in debug info
files can confuse consumers of ELF files, in this case the loader.
All you've done here is create a little shell script, which doesn't
look at all like an ELF executable.

> > What's more, having the headers there increases debug file size, by
> > considerably more than just the space for the headers.
> 
> I don't follow this at all.  The headers themselves are precisely all that
> is required.  The p_offset fields in a debug file are not meaningful.  I
> certainly never suggested including the allocated sections that the program
> headers' segments cover (which would make it cp).

_bfd_elf_map_sections_to_segments assigns file offsets to all the
NOBITS sections.  These file offsets comply with the usual ELF
constraint that they be equal to the section vma modulo max page
size.  Net result is wasted file space.  We could change this
specially for --only-keep-debug, but again this means a mainenance
burden.

-- 
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]