This is the mail archive of the 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: [PATCH] - objcopy --extract-symbol clears e_flags ELF header field

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.

Alan Modra
Australia Development Lab, IBM

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