etree_type *
exp_intop (bfd_vma value)
{
- etree_type *new_e = (etree_type *) stat_alloc (sizeof (new_e->value));
+ etree_type *new_e = stat_alloc (sizeof (new_e->value));
new_e->type.node_code = INT;
new_e->type.filename = ldlex_filename ();
new_e->type.lineno = lineno;
etree_type *
exp_bigintop (bfd_vma value, char *str)
{
- etree_type *new_e = (etree_type *) stat_alloc (sizeof (new_e->value));
+ etree_type *new_e = stat_alloc (sizeof (new_e->value));
new_e->type.node_code = INT;
new_e->type.filename = ldlex_filename ();
new_e->type.lineno = lineno;
etree_type *
exp_relop (asection *section, bfd_vma value)
{
- etree_type *new_e = (etree_type *) stat_alloc (sizeof (new_e->rel));
+ etree_type *new_e = stat_alloc (sizeof (new_e->rel));
new_e->type.node_code = REL;
new_e->type.filename = ldlex_filename ();
new_e->type.lineno = lineno;
break;
case NAME:
- if (expld.assign_name != NULL
- && strcmp (expld.assign_name, tree->name.name) == 0)
- {
- /* Self-assignment is only allowed for absolute symbols
- defined in a linker script. */
- h = bfd_wrapped_link_hash_lookup (link_info.output_bfd,
- &link_info,
- tree->name.name,
- FALSE, FALSE, TRUE);
- if (!(h != NULL
- && (h->type == bfd_link_hash_defined
- || h->type == bfd_link_hash_defweak)
- && h->u.def.section == bfd_abs_section_ptr
- && (def = symbol_defined (tree->name.name)) != NULL
- && def->iteration == (lang_statement_iteration & 255)))
- expld.assign_name = NULL;
- }
if (tree->name.name[0] == '.' && tree->name.name[1] == 0)
new_rel_from_abs (expld.dot);
else
expld.assign_src = h;
else
expld.assign_src = (struct bfd_link_hash_entry *) - 1;
+
+ /* Self-assignment is only allowed for absolute symbols
+ defined in a linker script. */
+ if (expld.assign_name != NULL
+ && strcmp (expld.assign_name, tree->name.name) == 0
+ && !(h != NULL
+ && (h->type == bfd_link_hash_defined
+ || h->type == bfd_link_hash_defweak)
+ && h->u.def.section == bfd_abs_section_ptr
+ && (def = symbol_defined (tree->name.name)) != NULL
+ && def->iteration == (lang_statement_iteration & 255)))
+ expld.assign_name = NULL;
}
break;
case LENGTH:
{
- if (expld.phase != lang_first_phase_enum)
- {
- lang_memory_region_type *mem;
-
- mem = lang_memory_region_lookup (tree->name.name, FALSE);
- if (mem != NULL)
- new_number (mem->length);
- else
- einfo (_("%F%P:%pS: undefined MEMORY region `%s'"
- " referenced in expression\n"),
- tree, tree->name.name);
- }
+ lang_memory_region_type *mem;
+
+ mem = lang_memory_region_lookup (tree->name.name, FALSE);
+ if (mem != NULL)
+ new_number (mem->length);
+ else
+ einfo (_("%F%P:%pS: undefined MEMORY region `%s'"
+ " referenced in expression\n"),
+ tree, tree->name.name);
}
break;
case ORIGIN:
- if (expld.phase != lang_first_phase_enum)
- {
- lang_memory_region_type *mem;
-
- mem = lang_memory_region_lookup (tree->name.name, FALSE);
- if (mem != NULL)
- new_rel_from_abs (mem->origin);
- else
- einfo (_("%F%P:%pS: undefined MEMORY region `%s'"
- " referenced in expression\n"),
- tree, tree->name.name);
- }
+ {
+ lang_memory_region_type *mem;
+
+ mem = lang_memory_region_lookup (tree->name.name, FALSE);
+ if (mem != NULL)
+ new_rel_from_abs (mem->origin);
+ else
+ einfo (_("%F%P:%pS: undefined MEMORY region `%s'"
+ " referenced in expression\n"),
+ tree, tree->name.name);
+ }
break;
case CONSTANT:
converted to absolute values, as is required by many
expressions, until final section sizing is complete. */
if (expld.phase == lang_final_phase_enum
- || expld.assign_name != NULL)
+ || expld.phase == lang_fixed_phase_enum
+ || expld.assign_name != NULL)
{
if (tree->type.node_class == etree_provide)
tree->type.node_class = etree_provided;
(&link_info, h, link_info.output_bfd,
expld.result.section, expld.result.value);
}
- h->type = bfd_link_hash_defined;
- h->u.def.value = expld.result.value;
- h->u.def.section = expld.result.section;
- h->linker_def = ! tree->assign.type.lineno;
- h->ldscript_def = 1;
- h->rel_from_abs = expld.rel_from_abs;
- if (tree->assign.hidden)
- bfd_link_hide_symbol (link_info.output_bfd,
- &link_info, h);
-
- /* Copy the symbol type if this is an expression only
- referencing a single symbol. (If the expression
- contains ternary conditions, ignoring symbols on
- false branches.) */
- if (expld.assign_src != NULL
- && (expld.assign_src
- != (struct bfd_link_hash_entry *) -1))
- bfd_copy_link_hash_symbol_type (link_info.output_bfd, h,
- expld.assign_src);
+ if (expld.phase == lang_fixed_phase_enum)
+ {
+ if (h->type == bfd_link_hash_defined)
+ {
+ expld.result.value = h->u.def.value;
+ expld.result.section = h->u.def.section;
+ }
+ }
+ else
+ {
+ h->type = bfd_link_hash_defined;
+ h->u.def.value = expld.result.value;
+ h->u.def.section = expld.result.section;
+ h->linker_def = ! tree->assign.type.lineno;
+ h->ldscript_def = 1;
+ h->rel_from_abs = expld.rel_from_abs;
+ if (tree->assign.hidden)
+ bfd_link_hide_symbol (link_info.output_bfd,
+ &link_info, h);
+
+ /* Copy the symbol type if this is an expression only
+ referencing a single symbol. (If the expression
+ contains ternary conditions, ignoring symbols on
+ false branches.) */
+ if (expld.assign_src != NULL
+ && (expld.assign_src
+ != (struct bfd_link_hash_entry *) -1))
+ bfd_copy_link_hash_symbol_type (link_info.output_bfd,
+ h, expld.assign_src);
+ }
}
}
- expld.assign_name = NULL;
+ if (expld.phase != lang_fixed_phase_enum)
+ expld.assign_name = NULL;
}
break;
etree_type *
exp_binop (int code, etree_type *lhs, etree_type *rhs)
{
- etree_type *new_e = (etree_type *) stat_alloc (MAX (sizeof (new_e->binary),
- sizeof (new_e->value)));
+ etree_type *new_e = stat_alloc (MAX (sizeof (new_e->binary),
+ sizeof (new_e->value)));
new_e->type.node_code = code;
new_e->type.filename = lhs->type.filename;
new_e->type.lineno = lhs->type.lineno;
etree_type *
exp_trinop (int code, etree_type *cond, etree_type *lhs, etree_type *rhs)
{
- etree_type *new_e = (etree_type *) stat_alloc (MAX (sizeof (new_e->trinary),
- sizeof (new_e->value)));
+ etree_type *new_e = stat_alloc (MAX (sizeof (new_e->trinary),
+ sizeof (new_e->value)));
new_e->type.node_code = code;
new_e->type.filename = cond->type.filename;
new_e->type.lineno = cond->type.lineno;
etree_type *
exp_unop (int code, etree_type *child)
{
- etree_type *new_e = (etree_type *) stat_alloc (MAX (sizeof (new_e->unary),
- sizeof (new_e->value)));
+ etree_type *new_e = stat_alloc (MAX (sizeof (new_e->unary),
+ sizeof (new_e->value)));
new_e->unary.type.node_code = code;
new_e->unary.type.filename = child->type.filename;
new_e->unary.type.lineno = child->type.lineno;
etree_type *
exp_nameop (int code, const char *name)
{
- etree_type *new_e = (etree_type *) stat_alloc (sizeof (new_e->name));
+ etree_type *new_e = stat_alloc (sizeof (new_e->name));
new_e->name.type.node_code = code;
new_e->name.type.filename = ldlex_filename ();
{
etree_type *n;
- n = (etree_type *) stat_alloc (sizeof (n->assign));
+ n = stat_alloc (sizeof (n->assign));
n->assign.type.node_code = '=';
n->assign.type.filename = src->type.filename;
n->assign.type.lineno = src->type.lineno;
{
etree_type *n;
- n = (etree_type *) stat_alloc (sizeof (n->assert_s));
+ n = stat_alloc (sizeof (n->assert_s));
n->assert_s.type.node_code = '!';
n->assert_s.type.filename = exp->type.filename;
n->assert_s.type.lineno = exp->type.lineno;