This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [GOLD] -Ttext does not relocate as expected
- From: ryan <stdstack at gmail dot com>
- To: ryan <stdstack at gmail dot com>, Ian Lance Taylor <iant at google dot com>, Binutils <binutils at sourceware dot org>
- Date: Thu, 21 Mar 2013 00:31:28 -0700
- Subject: Re: [GOLD] -Ttext does not relocate as expected
- References: <CAOjn=HQxudFLCpUJqKw3jtBirW6X=nxUQPC4tGJDSW5=LD0jTQ at mail dot gmail dot com> <CAKOQZ8ytZu0iAOMoHqLF5q7nm8WRW1VUjv1GgRbns5cTy1+JEg at mail dot gmail dot com> <CAOjn=HQzvXgkaPpAaGbB-TbGQQHektrfMfdtA9wkaHw7xsS+aQ at mail dot gmail dot com> <CAKOQZ8x2sg1MEoaD_BvTFkAZHwxvjj1O5o_0GYVYFAsifYb4FA at mail dot gmail dot com> <CAOjn=HR3=q4AZkXiJYT+XEJmcEaXuf9UUiawTY=L8=QObCeUnw at mail dot gmail dot com> <20130321024538 dot GQ18331 at bubble dot grove dot modra dot org>
Thanks a lot Alan, Ian!
--Ryan
On Wed, Mar 20, 2013 at 7:45 PM, Alan Modra <amodra@gmail.com> wrote:
> On Wed, Mar 20, 2013 at 06:10:03PM -0700, ryan wrote:
>> >>>>> ld -m elf_i386 -N -e start -Ttext 0x7c00 -o boot.out boot.o
>
> It's indirectly caused by -N. I think the sequence of events is:
> 1) -N puts all input sections into the output .text section, including
> a zero size .data
> 2) this marks the output .text as writable
> 3) the following code in layout.cc doesn't recognize .text as part of
> the text segment
>
> else if (parameters->options().user_set_Ttext()
> && ((*p)->flags() & elfcpp::PF_W) == 0)
> {
> are_addresses_set = true;
> }
>
> 4) leading to
>
> if (!are_addresses_set)
> {
> // Skip the address forward one page, maintaining the same
> // position within the page. This lets us store both segments
>
> --
> Alan Modra
> Australia Development Lab, IBM