elfcpp::STV* vis_pointer;
// Pointer to where the rest of the symbol's st_other field should be stored.
unsigned char* nonvis_pointer;
+ // Whether the value is valid. In Symbol_assignment::set_if_absolute, we
+ // may be trying to evaluate the address of a section whose address is not
+ // yet finalized, and we need to fail the evaluation gracefully.
+ bool *is_valid_pointer;
};
// Evaluate an expression.
bool check_assertions)
{
return this->eval_maybe_dot(symtab, layout, check_assertions, false, 0,
- NULL, NULL, NULL, NULL, NULL, NULL, false);
+ NULL, NULL, NULL, NULL, NULL, NULL, false, NULL);
}
// Evaluate an expression which may refer to the dot symbol.
return this->eval_maybe_dot(symtab, layout, check_assertions, true,
dot_value, dot_section, result_section_pointer,
result_alignment_pointer, NULL, NULL, NULL,
- is_section_dot_assignment);
+ is_section_dot_assignment, NULL);
}
// Evaluate an expression which may or may not refer to the dot
elfcpp::STT* type_pointer,
elfcpp::STV* vis_pointer,
unsigned char* nonvis_pointer,
- bool is_section_dot_assignment)
+ bool is_section_dot_assignment,
+ bool* is_valid_pointer)
{
Expression_eval_info eei;
eei.symtab = symtab;
eei.result_alignment_pointer = result_alignment_pointer;
+ // Assume the value is valid until we try to evaluate an expression
+ // that can't be evaluated yet.
+ bool is_valid = true;
+ eei.is_valid_pointer = &is_valid;
+
uint64_t val = this->value(&eei);
+ if (is_valid_pointer != NULL)
+ *is_valid_pointer = is_valid;
+ else
+ gold_assert(is_valid);
+
// 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)
NULL,
NULL,
NULL,
- false);
+ false,
+ eei->is_valid_pointer);
}
void
NULL,
NULL,
NULL,
- false);
+ false,
+ eei->is_valid_pointer);
}
uint64_t
NULL,
NULL,
NULL,
- false);
+ false,
+ eei->is_valid_pointer);
}
void
NULL,
NULL,
NULL,
- false);
+ false,
+ eei->is_valid_pointer);
}
uint64_t
NULL,
NULL,
NULL,
- false);
+ false,
+ eei->is_valid_pointer);
}
uint64_t
NULL,
NULL,
NULL,
- false);
+ false,
+ eei->is_valid_pointer);
}
void
{
if (eei->result_section_pointer != NULL)
*eei->result_section_pointer = os;
- return os->address();
+ if (os->is_address_valid())
+ return os->address();
+ *eei->is_valid_pointer = false;
+ return 0;
}
uint64_t
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);
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)