* ldexp.c (assigning_to_dot): New global flag.

(fold_name): If assigning_to_dot is true, object immediately to
	an undefined symbol.
	(exp_fold_tree): Set and clear assigning_to_dot around the
	recursive call to exp_fold_tree to process the right-hand side
	of an assignment to the location counter.
testsuite:
	* ld-scripts/align.exp: Rename existing "ALIGN" test to "align1".
	Add dump tests "align2a", "align2b", "align2c".
	* ld-scripts/align2.t, ld-scripts/align2a.s, ld-scripts/align2a.d
	* ld-scripts/align2b.s, ld-scripts/align2b.d
	* ld-scripts/align2c.s, ld-scripts/align2c.d: New files.
This commit is contained in:
Zack Weinberg
2005-02-17 20:57:01 +00:00
parent f397e30345
commit fbbb9ac52f
11 changed files with 82 additions and 8 deletions

View File

@ -50,6 +50,9 @@ struct exp_data_seg exp_data_seg;
segment_type *segments;
/* Principally used for diagnostics. */
static bfd_boolean assigning_to_dot = FALSE;
/* Print the string representation of the given token. Surround it
with spaces if INFIX_P is TRUE. */
@ -596,7 +599,8 @@ fold_name (etree_type *tree,
}
}
}
else if (allocation_done == lang_final_phase_enum)
else if (allocation_done == lang_final_phase_enum
|| assigning_to_dot)
einfo (_("%F%S: undefined symbol `%s' referenced in expression\n"),
tree->name.name);
else if (h->type == bfd_link_hash_new)
@ -755,10 +759,13 @@ exp_fold_tree (etree_type *tree,
|| (allocation_done == lang_final_phase_enum
&& current_section == abs_output_section))
{
/* Notify the folder that this is an assignment to dot. */
assigning_to_dot = TRUE;
result = exp_fold_tree (tree->assign.src,
current_section,
allocation_done, dot,
dotp);
allocation_done, dot, dotp);
assigning_to_dot = FALSE;
if (! result.valid_p)
einfo (_("%F%S invalid assignment to location counter\n"));
else