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: [PATCH][GOLD] Handle -Ttext, -Tdata and -Tbss options in scripts.


"Doug Kwan (éæå)" <dougkwan@google.com> writes:

>     This patch adds support of -Ttext, -Tdata and -Tbss options in
> scripts.  Basically, it does a dot assignment at the first section of
> the appropriate type.

> 2009-10-15  Doug Kwan  <dougkwan@google.com>
>
>         * script-sections.cc (Script_sections::set_section_addresses):
>         Handle -Ttext, -Tdata and -Tbbs options.
>         (Script_sections::create_segments): If the -Tbss option is used,
>         begin a new segment when seeing a new run of BBS sections.

I don't think we should do this.  The patch is well-written, and there
is a sense in which it is clearly correct: -Ttext really should set
the address of the text segment, even when using a linker script.
However, the purpose of supporting linker scripts in gold is to be
compatible with the GNU linker, and this is not how the GNU linker
handles -Ttext, et. al.  In the GNU linker, -Ttext sets the address of
the .text section, not the text segment, and similarly -Tdata and
-Tbss set the addresses of the .data and the .bss sections.

In the GNU linker this is changed by the use of SEGMENT_START in a
linker script.  If SEGMENT_START is used, then -Ttext, et. al., change
that value.  gold currently parses SEGMENT_START but does not
implement it--see script_exp_function_segment_start in expression.cc.

So I think the right thing to do here is to have the script code
support -Ttext, et. al., as changing the address of the relevant
section only, in Output_section_definition::set_section_addresses,
*unless* SEGMENT_START is used, in which case we should use the value
in script_exp_function_segment_start.

I think that would be compatible, which is the goal here.

Ian


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