This is the mail archive of the
mailing list for the binutils project.
Re: [PATCH] - objcopy --extract-symbol clears e_flags ELF header field
- From: Alan Modra <amodra at gmail dot com>
- To: Hans-Peter Nilsson <hp at bitrange dot com>
- Cc: Ronald Hoogenboom <hoogenboom30 at zonnet dot nl>, binutils at sourceware dot org
- Date: Mon, 19 Oct 2015 21:09:46 +1030
- Subject: Re: [PATCH] - objcopy --extract-symbol clears e_flags ELF header field
- Authentication-results: sourceware.org; auth=none
- References: <561D44BC dot 9080307 at atom dot grundel> <20151014002120 dot GK4434 at bubble dot grove dot modra dot org> <561EB0A7 dot 9000402 at atom dot grundel> <20151015130648 dot GA13961 at bubble dot grove dot modra dot org> <alpine dot BSF dot 2 dot 02 dot 1510180506480 dot 83989 at arjuna dot pair dot com>
On Sun, Oct 18, 2015 at 05:13:23AM -0400, Hans-Peter Nilsson wrote:
> That's because objcopy --extract-symbol hacks in a start-address
> 0 instead of letting it be or consulting the target (new
> framework may be needed). Why does it change the start-address?
> The symbols are left, so why zero the start-adress; why is that
> more logical than keeping it when removing all contents?
> If the answer is ELF-related, I think it'd be up to ELF bits to
> handle the start-address-zeroing.
I believe the start address may have been zeroed for aout. If you
leave the start address as is, then on arm-aout I see objcopy
--extract-symbol overwriting the exec header (at file offset zero)
with the symbols. This of course results in an invalid aout object
The reason this happens is that N_SYMOFF is defined relative to
N_TXTOFF + N_TXTSIZE, and for zmagic these two both depend on
N_HEADER_IN_TEXT. There is an implicit assumption that if
N_HEADER_IN_TEXT is true then the text size (a_text) is at least the
header size, and that isn't always so; I believe this is just a bug
with the way a_text is written but I don't care to untangle the
A start address of zero means the default N_HEADER_IN_TEXT is false,
avoiding this problem on arm-aout.
Australia Development Lab, IBM