diff options
author | Cary Coutant <ccoutant@google.com> | 2011-10-31 22:51:03 +0000 |
---|---|---|
committer | Cary Coutant <ccoutant@google.com> | 2011-10-31 22:51:03 +0000 |
commit | 286adcf4f8c8bb15d46dca29dd7e9a8c935f5e3e (patch) | |
tree | 906b1740ca3a14e1c98515db9662b67fc532b2ca /gold/expression.cc | |
parent | 9634ed06a66c3693045bb8b3bf86b43942239dd8 (diff) | |
download | fsf-binutils-gdb-286adcf4f8c8bb15d46dca29dd7e9a8c935f5e3e.zip fsf-binutils-gdb-286adcf4f8c8bb15d46dca29dd7e9a8c935f5e3e.tar.gz fsf-binutils-gdb-286adcf4f8c8bb15d46dca29dd7e9a8c935f5e3e.tar.bz2 |
PR gold/13023
* expression.cc (Expression::eval_with_dot): Add
is_section_dot_assignment parameter.
(Expression::eval_maybe_dot): Likewise. Adjust value when rhs is
absolute and assigning to dot within a section.
* script-sections.cc
(Output_section_element_assignment::set_section_addresses): Pass
dot_section to set_if_absolute.
(Output_section_element_dot_assignment::finalize_symbols): Pass TRUE
as is_section_dot_assignment flag to eval_with_dot.
(Output_section_element_dot_assignment::set_section_addresses):
Likewise.
* script.cc (Symbol_assignment::set_if_absolute): Add dot_section
parameter. Also set value if relative to dot_section; set the
symbol's output_section.
* script.h (Expression::eval_with_dot): Add is_section_dot_assignment
parameter. Adjust all callers.
(Expression::eval_maybe_dot): Likewise.
(Symbol_assignment::set_if_absolute): Add dot_section parameter.
Adjust all callers.
* testsuite/script_test_2.t: Test assignment of an absolute value
to dot within an output section element.
Diffstat (limited to 'gold/expression.cc')
-rw-r--r-- | gold/expression.cc | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/gold/expression.cc b/gold/expression.cc index e527b5e..b611a68 100644 --- a/gold/expression.cc +++ b/gold/expression.cc @@ -77,7 +77,7 @@ Expression::eval(const Symbol_table* symtab, const Layout* layout, bool check_assertions) { return this->eval_maybe_dot(symtab, layout, check_assertions, - false, 0, NULL, NULL, NULL); + false, 0, NULL, NULL, NULL, false); } // Evaluate an expression which may refer to the dot symbol. @@ -87,11 +87,13 @@ Expression::eval_with_dot(const Symbol_table* symtab, const Layout* layout, bool check_assertions, uint64_t dot_value, Output_section* dot_section, Output_section** result_section_pointer, - uint64_t* result_alignment_pointer) + uint64_t* result_alignment_pointer, + bool is_section_dot_assignment) { return this->eval_maybe_dot(symtab, layout, check_assertions, true, dot_value, dot_section, result_section_pointer, - result_alignment_pointer); + result_alignment_pointer, + is_section_dot_assignment); } // Evaluate an expression which may or may not refer to the dot @@ -102,7 +104,8 @@ Expression::eval_maybe_dot(const Symbol_table* symtab, const Layout* layout, bool check_assertions, bool is_dot_available, uint64_t dot_value, Output_section* dot_section, Output_section** result_section_pointer, - uint64_t* result_alignment_pointer) + uint64_t* result_alignment_pointer, + bool is_section_dot_assignment) { Expression_eval_info eei; eei.symtab = symtab; @@ -113,14 +116,24 @@ Expression::eval_maybe_dot(const Symbol_table* symtab, const Layout* layout, eei.dot_section = dot_section; // We assume the value is absolute, and only set this to a section - // if we find a section relative reference. + // if we find a section-relative reference. if (result_section_pointer != NULL) *result_section_pointer = NULL; eei.result_section_pointer = result_section_pointer; eei.result_alignment_pointer = result_alignment_pointer; - return this->value(&eei); + uint64_t val = this->value(&eei); + + // If this is an assignment to dot within a section, and the value + // is absolute, treat it as a section-relative offset. + if (is_section_dot_assignment && *result_section_pointer == NULL) + { + gold_assert(dot_section != NULL); + val += dot_section->address(); + *result_section_pointer = dot_section; + } + return val; } // A number. @@ -257,7 +270,8 @@ class Unary_expression : public Expression eei->dot_value, eei->dot_section, arg_section_pointer, - eei->result_alignment_pointer); + eei->result_alignment_pointer, + false); } void @@ -336,7 +350,8 @@ class Binary_expression : public Expression eei->dot_value, eei->dot_section, section_pointer, - alignment_pointer); + alignment_pointer, + false); } uint64_t @@ -350,7 +365,8 @@ class Binary_expression : public Expression eei->dot_value, eei->dot_section, section_pointer, - alignment_pointer); + alignment_pointer, + false); } void @@ -500,7 +516,8 @@ class Trinary_expression : public Expression eei->dot_value, eei->dot_section, section_pointer, - NULL); + NULL, + false); } uint64_t @@ -514,7 +531,8 @@ class Trinary_expression : public Expression eei->dot_value, eei->dot_section, section_pointer, - alignment_pointer); + alignment_pointer, + false); } uint64_t @@ -528,7 +546,8 @@ class Trinary_expression : public Expression eei->dot_value, eei->dot_section, section_pointer, - alignment_pointer); + alignment_pointer, + false); } void |