mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-27 01:28:46 +00:00
Fix internal error in gold when script uses section address in assignment.
When processing assignment expressions in a linker script, gold processes absolute assignments early, but when one of those assignments involves the address of a section that has not yet been finalized, we get an internal error in address. This patch fixes the problem by gracefully returning from expression evaluation even if the address is not yet valid, and deferring the assignment in such a case. gold/ PR gold/14746 * expression.cc (Expression::Expression_eval_info): Add is_valid_pointer field. (Expression::eval_maybe_dot): Add is_valid_pointer parameter. Adjust all callers. (Addr_expression::value_from_output_section): Check whether address is valid. * script.cc (Symbol_assignment::set_if_absolute): Defer assignment if evaluation failed due to address that is not yet valid. * script.h: (Expression::eval_maybe_dot): Add is_valid_pointer parameter.
This commit is contained in:
@@ -987,7 +987,7 @@ Symbol_assignment::sized_finalize(Symbol_table* symtab, const Layout* layout,
|
||||
is_dot_available,
|
||||
dot_value, dot_section,
|
||||
§ion, NULL, &type,
|
||||
&vis, &nonvis, false);
|
||||
&vis, &nonvis, false, NULL);
|
||||
Sized_symbol<size>* ssym = symtab->get_sized_symbol<size>(this->sym_);
|
||||
ssym->set_value(final_val);
|
||||
ssym->set_type(type);
|
||||
@@ -1009,11 +1009,12 @@ Symbol_assignment::set_if_absolute(Symbol_table* symtab, const Layout* layout,
|
||||
return;
|
||||
|
||||
Output_section* val_section;
|
||||
bool is_valid;
|
||||
uint64_t val = this->val_->eval_maybe_dot(symtab, layout, false,
|
||||
is_dot_available, dot_value,
|
||||
dot_section, &val_section, NULL,
|
||||
NULL, NULL, NULL, false);
|
||||
if (val_section != NULL && val_section != dot_section)
|
||||
NULL, NULL, NULL, false, &is_valid);
|
||||
if (!is_valid || (val_section != NULL && val_section != dot_section))
|
||||
return;
|
||||
|
||||
if (parameters->target().get_size() == 32)
|
||||
|
||||
Reference in New Issue
Block a user