bfd_hash_allocate (table, sizeof (struct definedness_hash_entry));
if (ret == NULL)
- einfo (_("%P%F: bfd_hash_allocate failed creating symbol %s\n"), name);
+ einfo (_("%F%P: bfd_hash_allocate failed creating symbol %s\n"), name);
ret->by_object = 0;
ret->iteration = 0;
bfd_hash_lookup (&definedness_table, name, TRUE, FALSE);
if (defentry == NULL)
- einfo (_("%P%F: bfd_hash_lookup failed creating symbol %s\n"), name);
+ einfo (_("%F%P: bfd_hash_lookup failed creating symbol %s\n"), name);
/* If the symbol was already defined, and not by a script, then it
must be defined by an object file or by the linker target code. */
expld.result.value = ((bfd_signed_vma) lhs.value
% (bfd_signed_vma) expld.result.value);
else if (expld.phase != lang_mark_phase_enum)
- einfo (_("%F%S %% by zero\n"), tree->binary.rhs);
+ einfo (_("%F%P:%pS %% by zero\n"), tree->binary.rhs);
arith_result_section (&lhs);
break;
expld.result.value = ((bfd_signed_vma) lhs.value
/ (bfd_signed_vma) expld.result.value);
else if (expld.phase != lang_mark_phase_enum)
- einfo (_("%F%S / by zero\n"), tree->binary.rhs);
+ einfo (_("%F%P:%pS / by zero\n"), tree->binary.rhs);
arith_result_section (&lhs);
break;
tree->name.name,
TRUE, FALSE, TRUE);
if (!h)
- einfo (_("%P%F: bfd_link_hash_lookup failed: %E\n"));
+ einfo (_("%F%P: bfd_link_hash_lookup failed: %E\n"));
else if (h->type == bfd_link_hash_defined
|| h->type == bfd_link_hash_defweak)
{
if (expld.phase <= lang_mark_phase_enum)
new_rel (h->u.def.value, h->u.def.section);
else
- einfo (_("%X%S: unresolvable symbol `%s'"
+ einfo (_("%X%P:%pS: unresolvable symbol `%s'"
" referenced in expression\n"),
tree, tree->name.name);
}
else if (expld.phase == lang_final_phase_enum
|| (expld.phase != lang_mark_phase_enum
&& expld.assigning_to_dot))
- einfo (_("%F%S: undefined symbol `%s'"
+ einfo (_("%F%P:%pS: undefined symbol `%s'"
" referenced in expression\n"),
tree, tree->name.name);
else if (h->type == bfd_link_hash_new)
if (expld.assign_src == NULL)
expld.assign_src = h;
else
- expld.assign_src = (struct bfd_link_hash_entry *) 0 - 1;
+ expld.assign_src = (struct bfd_link_hash_entry *) - 1;
}
break;
if (os == NULL)
{
if (expld.phase == lang_final_phase_enum)
- einfo (_("%F%S: undefined section `%s'"
+ einfo (_("%F%P:%pS: undefined section `%s'"
" referenced in expression\n"),
tree, tree->name.name);
}
if (os == NULL)
{
if (expld.phase == lang_final_phase_enum)
- einfo (_("%F%S: undefined section `%s'"
+ einfo (_("%F%P:%pS: undefined section `%s'"
" referenced in expression\n"),
tree, tree->name.name);
}
if (os == NULL)
{
if (expld.phase == lang_final_phase_enum)
- einfo (_("%F%S: undefined section `%s'"
+ einfo (_("%F%P:%pS: undefined section `%s'"
" referenced in expression\n"),
tree, tree->name.name);
new_number (0);
if (mem != NULL)
new_number (mem->length);
else
- einfo (_("%F%S: undefined MEMORY region `%s'"
+ einfo (_("%F%P:%pS: undefined MEMORY region `%s'"
" referenced in expression\n"),
tree, tree->name.name);
}
if (mem != NULL)
new_rel_from_abs (mem->origin);
else
- einfo (_("%F%S: undefined MEMORY region `%s'"
+ einfo (_("%F%P:%pS: undefined MEMORY region `%s'"
" referenced in expression\n"),
tree, tree->name.name);
}
else if (strcmp (tree->name.name, "COMMONPAGESIZE") == 0)
new_number (config.commonpagesize);
else
- einfo (_("%F%S: unknown constant `%s' referenced in expression\n"),
+ einfo (_("%F%P:%pS: unknown constant `%s' referenced in expression\n"),
tree, tree->name.name);
break;
if (tree->assign.dst[0] == '.' && tree->assign.dst[1] == 0)
{
if (tree->type.node_class != etree_assign)
- einfo (_("%F%S can not PROVIDE assignment to"
+ einfo (_("%F%P:%pS can not PROVIDE assignment to"
" location counter\n"), tree);
if (expld.phase != lang_first_phase_enum)
{
|| expld.section == bfd_und_section_ptr)
{
if (expld.phase != lang_mark_phase_enum)
- einfo (_("%F%S invalid assignment to"
+ einfo (_("%F%P:%pS invalid assignment to"
" location counter\n"), tree);
}
else if (expld.dotp == NULL)
- einfo (_("%F%S assignment to location counter"
+ einfo (_("%F%P:%pS assignment to location counter"
" invalid outside of SECTIONS\n"), tree);
/* After allocation, assignment to dot should not be
nextdot += expld.section->vma;
if (nextdot < expld.dot
&& expld.section != bfd_abs_section_ptr)
- einfo (_("%F%S cannot move location counter backwards"
+ einfo (_("%F%P:%pS cannot move location counter backwards"
" (from %V to %V)\n"),
tree, expld.dot, nextdot);
else
2) Section relative symbol values cannot be correctly
converted to absolute values, as is required by many
expressions, until final section sizing is complete. */
- if ((expld.result.valid_p
- && (expld.phase == lang_final_phase_enum
- || expld.assign_name != NULL))
- || (expld.phase <= lang_mark_phase_enum
- && tree->type.node_class == etree_assign
- && tree->assign.defsym))
+ if (expld.phase == lang_final_phase_enum
+ || expld.assign_name != NULL)
{
+ if (tree->type.node_class == etree_provide)
+ tree->type.node_class = etree_provided;
+
if (h == NULL)
{
h = bfd_link_hash_lookup (link_info.hash, tree->assign.dst,
TRUE, FALSE, TRUE);
if (h == NULL)
- einfo (_("%P%F:%s: hash creation failed\n"),
+ einfo (_("%F%P:%s: hash creation failed\n"),
tree->assign.dst);
}
- if (expld.result.section == NULL)
- expld.result.section = expld.section;
- if (!update_definedness (tree->assign.dst, h) && 0)
+ /* If the expression is not valid then fake a zero value. In
+ the final phase any errors will already have been raised,
+ in earlier phases we want to create this definition so
+ that it can be seen by other expressions. */
+ if (!expld.result.valid_p
+ && h->type == bfd_link_hash_new)
+ {
+ expld.result.value = 0;
+ expld.result.section = NULL;
+ expld.result.valid_p = TRUE;
+ }
+
+ if (expld.result.valid_p)
{
- /* Symbol was already defined. For now this error
- is disabled because it causes failures in the ld
- testsuite: ld-elf/var1, ld-scripts/defined5, and
- ld-scripts/pr14962. Some of these no doubt
- reflect scripts used in the wild. */
- (*link_info.callbacks->multiple_definition)
- (&link_info, h, link_info.output_bfd,
- expld.result.section, expld.result.value);
+ if (expld.result.section == NULL)
+ expld.result.section = expld.section;
+ if (!update_definedness (tree->assign.dst, h) && 0)
+ {
+ /* Symbol was already defined. For now this error
+ is disabled because it causes failures in the ld
+ testsuite: ld-elf/var1, ld-scripts/defined5, and
+ ld-scripts/pr14962. Some of these no doubt
+ reflect scripts used in the wild. */
+ (*link_info.callbacks->multiple_definition)
+ (&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;
+ 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);
}
- 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;
- if (tree->type.node_class == etree_provide)
- tree->type.node_class = etree_provided;
-
- /* 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.result.valid_p
- && expld.assign_src != NULL
- && expld.assign_src != (struct bfd_link_hash_entry *) 0 - 1)
- bfd_copy_link_hash_symbol_type (link_info.output_bfd, h,
- expld.assign_src);
- }
- else if (expld.phase == lang_final_phase_enum)
- {
- h = bfd_link_hash_lookup (link_info.hash, tree->assign.dst,
- FALSE, FALSE, TRUE);
- if (h != NULL
- && h->type == bfd_link_hash_new)
- h->type = bfd_link_hash_undefined;
}
expld.assign_name = NULL;
}
exp_assop (const char *dst,
etree_type *src,
enum node_tree_enum class,
- bfd_boolean defsym,
bfd_boolean hidden)
{
etree_type *n;
n->assign.type.node_class = class;
n->assign.src = src;
n->assign.dst = dst;
- n->assign.defsym = defsym;
n->assign.hidden = hidden;
return n;
}
etree_type *
exp_assign (const char *dst, etree_type *src, bfd_boolean hidden)
{
- return exp_assop (dst, src, etree_assign, FALSE, hidden);
+ return exp_assop (dst, src, etree_assign, hidden);
}
/* Handle --defsym command-line option. */
etree_type *
exp_defsym (const char *dst, etree_type *src)
{
- return exp_assop (dst, src, etree_assign, TRUE, FALSE);
+ return exp_assop (dst, src, etree_assign, FALSE);
}
/* Handle PROVIDE. */
etree_type *
exp_provide (const char *dst, etree_type *src, bfd_boolean hidden)
{
- return exp_assop (dst, src, etree_provide, FALSE, hidden);
+ return exp_assop (dst, src, etree_provide, hidden);
}
/* Handle ASSERT. */
return;
case etree_rel:
if (tree->rel.section->owner != NULL)
- minfo ("%B:", tree->rel.section->owner);
+ minfo ("%pB:", tree->rel.section->owner);
minfo ("%s+0x%v", tree->rel.section->name, tree->rel.value);
return;
case etree_assign:
if (expld.result.valid_p)
return expld.result.value;
else if (name != NULL && expld.phase != lang_mark_phase_enum)
- einfo (_("%F%S: nonconstant expression for %s\n"),
+ einfo (_("%F%P:%pS: nonconstant expression for %s\n"),
tree, name);
}
return def;
if (!expld.result.valid_p)
{
if (name != NULL && expld.phase != lang_mark_phase_enum)
- einfo (_("%F%S: nonconstant expression for %s\n"),
+ einfo (_("%F%P:%pS: nonconstant expression for %s\n"),
tree, name);
return def;
}
}
else if (name != NULL && expld.phase != lang_mark_phase_enum)
{
- einfo (_("%F%S: nonconstant expression for %s\n"),
+ einfo (_("%F%P:%pS: nonconstant expression for %s\n"),
tree, name);
}
}
definedness_newfunc,
sizeof (struct definedness_hash_entry),
13))
- einfo (_("%P%F: can not create hash table: %E\n"));
+ einfo (_("%F%P: can not create hash table: %E\n"));
}
/* Convert absolute symbols defined by a script from "dot" (also