This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH][GOLD] Handle -Ttext, -Tdata and -Tbss options in scripts.
"Doug Kwan (éæå)" <dougkwan@google.com> writes:
> 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.
> +// SEGMENT_START.
> +
> // In the GNU linker SEGMENT_START basically returns the value for
> // -Ttext, -Tdata, or -Tbss. We could implement this by copying the
> // values from General_options to Parameters. But I doubt that
> @@ -1120,10 +1122,60 @@ script_exp_function_sizeof_headers()
> // because -Ttext set the address of the .text section rather than the
> // text segment. In gold -Ttext sets the text segment address anyhow.
Please remove this entire comment, and keep only your new
SEGMENT_START comment.
> + // Check to see if we want to use any of -Ttext, -Tdata and -Tbss options
> + // to set section addresses. If the script has any SEGMENT_START
> + // expression, we do not set the section addresses.
> + bool use_Tsection_options =
> + (!this->saw_segment_start_expression_
> + && (parameters->options().user_set_Ttext()
> + || parameters->options().user_set_Tdata()
> + || parameters->options().user_set_Tbss()));
Please just name this variable use_tsection_options, without the
capital letter.
> + if (parameters->options().user_set_Ttext()
> + && !strcmp(os->name(), ".text"))
> + new_dot_value = parameters->options().Ttext();
> + else if (parameters->options().user_set_Tdata()
> + && !strcmp(os->name(), ".data"))
> + new_dot_value = parameters->options().Tdata();
> + else if (parameters->options().user_set_Tbss()
> + && !strcmp(os->name(), ".bss"))
> + new_dot_value = parameters->options().Tbss();
Please write strcmp() == 0 rather than !strcmp().
This is OK with those changes.
Thanks for tackling this.
Ian