This is the mail archive of the
mailing list for the binutils project.
Re: [gold, strip] Question about the changed offset when stripping
- From: Alexander Ivchenko <aivchenk at gmail dot com>
- To: Alexander Ivchenko <aivchenk at gmail dot com>, Cary Coutant <ccoutant at google dot com>, binutils <binutils at sourceware dot org>, Ian Lance Taylor <iant at google dot com>
- Date: Mon, 9 Dec 2013 16:33:26 +0400
- Subject: Re: [gold, strip] Question about the changed offset when stripping
- Authentication-results: sourceware.org; auth=none
- References: <CACysShjNGcO=Y5ZU=QDLWetw31FRZUu7ZYbvo2DyJWZ+eOZZ2Q at mail dot gmail dot com> <20131129134722 dot GN9211 at bubble dot grove dot modra dot org> <CAHACq4qbwykqOcTjuQovsqoE0d2dC4FAAtfZOxr=0XrYsViJqw at mail dot gmail dot com> <20131203100957 dot GA3306 at bubble dot grove dot modra dot org> <CACysShi4sKtg_R6RAhGmgKs0qRuvbsU3fLpC-Hz27YMy-sGtrA at mail dot gmail dot com> <20131203112323 dot GC3306 at bubble dot grove dot modra dot org> <CACysShiAr=iLP2Ju2dWsubV5USXxDhQitmydvRfC2=b07Fp7hA at mail dot gmail dot com>
Indeed my problem with debugging was due to those missing 4 bytes
between .got.plt and .bss.
that lead to differences between stripped/not_stripped program headers
of the same binary:
LOAD 0x003d60 0x00004d60 0x00004d60 *0x002a0* 0x002b0 RW 0x1000
LOAD 0x003d60 0x00004d60 0x00004d60 *0x0029c* 0x002b0 RW 0x1000
I didn't look into the code of gdb, but it says in the doc:
"The sections of the debugging information file should have the same
names, addresses, and sizes as the original file".
So, presumably, that includes .bss.
However, after updating to gdbserver 7.6 I was able to load the debug
info.. Also if I firstly just objcopy the linked binary (thus, erasing
the padding between .got.plt and .bss) and then strip
Still, one thing I still worry about. I see that gold is intentionally
making this padding.
I see in the code:
// Pad the total relro size to a multiple of the maximum
// section alignment seen.
uint64_t aligned_size = align_address(relro_size, max_align);
// Note the amount of padding added after the last relro section.
last_relro_pad = aligned_size - relro_size;
*has_relro = true
... and then:
*poff += last_relro_pad;
addr += last_relro_pad;
// If there is nothing in the ORDER_RELRO_LAST list,
// the padding will occur at the end of the relro
// segment, and we need to add it to *INCREASE_RELRO.
*increase_relro += last_relro_pad;
Since all stripped binaries in e.g. Android (at least that is true for
x86, may be other arch's are also affected), that were linked by gold,
are missing that padding, how critical that is?
Ian, Carry, could you please comment?
2013/12/3 Alexander Ivchenko <email@example.com>:
> 2013/12/3 Alan Modra <firstname.lastname@example.org>:
>> On Tue, Dec 03, 2013 at 02:30:48PM +0400, Alexander Ivchenko wrote:
>>> Still, it looks a bit strange that strip did the job that it was not
>>> asked for: erasing the padding between got.plt and bss.
>> No, strip didn't change any padding. The VMA is unchanged after strip.
>> Since .bss is not loaded from file, the file offset hardly matters.
> Well, still it did change the padding between the "file offset of
> .got.plt + size of (.got.plt)" and "file offset of .bss".
> Even if it hardly matters, I did not ask strip to do that. But anyway,
> I see your point, thanks.