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.


Hi,

   I implemented SEGMENT_START and changed the handling of -Ttext,
-Tdata and -Tbss.   The -T* options now set section addresses in a
script unless SEGMENT_START is seen.  In that case, they are no longer
used to set section addresses but are still available to override the
default values of SEGMENT_START expressions.   Setting the address of
the .bss segment does not work very well because of the adjustment of
the .bss segment start to allow for sharing of the boundary page in
file.  I can fix that if this is a problem.

-Doug

2009-10-15  Doug Kwan  <dougkwan@google.com>

        * expression.cc (class Segment_start_expression): New class definition.
        (Segment_start_expression::value): New method definition.
        (script_exp_function_segment_start): Return a new
        Segment_start_expression.
        * gold/script-c.h (script_saw_segment_start_expression): New function
        prototype.
        * script-sections.cc (Script_sections::Script_sections): Initialize
        SAW_SEGMENT_START_EXPRESSION_ to false.
        (Script_sections::set_section_addresses): Use -Ttext, -Tdata
        and -Tbbs options to specify section addresses if given in
        command line and no SEGMENT_START expression is seen in a script.
        * script-sections.h (Script_sections::saw_segment_start_expression,
        Script_sections::set_saw_segment_start_expression): New method
        definition.
        (Script_sections::saw_segment_start_expression_): New data member
        declaration.
        * script.cc (script_saw_segment_start_expression): New function.
        * yyscript.y (SEGMENT_START): Call script_saw_segment_start_expression.
        * testsuite/Makefile.am (check_SCRIPTS): Add script_test_6.sh,
        script_test_7.sh and script_test_8.sh.
        (check_DATA): Add script_test_6.stdout, script_test_7.stdout and
        script_test_8.stdout.
        (MOSTLYCLEANFILES): Add script_test_6, script_test_7 and script_test_8.
        (script_test_6, script_test_6.stdout, script_test_7,
        script_test_7.stdout, script_test_8, script_test_8.stdout): New rules.
        * Makefile.in: Regenerate.
        * testsuite/script_test_6.sh: New file.
        * testsuite/script_test_6.t: Same.
        * testsuite/script_test_7.sh: Same.
        * testsuite/script_test_7.t: Same.
        * testsuite/script_test_8.sh: Same.


2009/10/15 Doug Kwan (Ãö®¶¼w) <dougkwan@google.com>:
> Hi,
>
>    Actually this changing the section addresses easier.  I chose this
> because the behaviour is more similar to the non-script case.   I will
> change the patch to set the section addresses only.
>
> -Doug
>
> 2009/10/15 Ian Lance Taylor <iant@google.com>:
>
>> 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
>>
>

Attachment: patch.txt
Description: Text document


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