* 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

@ -1,3 +1,12 @@
2005-02-17 Zack Weinberg <zack@codesourcery.com>
* 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.
2005-02-17 Paul Brook <paul@codesourcery.com>
* scripttempl/armbpabi.sc: Add dummy name to version block.

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

View file

@ -1,3 +1,11 @@
2005-02-17 Zack Weinberg <zack@codesourcery.com>
* 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.
2005-02-17 Alexandre Oliva <aoliva@redhat.com>
* ld-frv/fdpic-static-6.d: Update.
@ -5,7 +13,7 @@
spelling of errors and warnings.
2005-02-15 Nigel Stephens <nigel@mips.com>
Maciej W. Rozycki <macro@mips.com>
Maciej W. Rozycki <macro@mips.com>
* ld-mips-elf/mips16-hilo.d: New test for the R_MIPS16_HI16 and
R_MIPS16_LO16 relocs.

View file

@ -22,7 +22,7 @@ if [istarget "rs6000-*-aix*"] {
return
}
set testname "ALIGN"
set testname "align1"
if ![ld_assemble $as $srcdir/$subdir/align.s tmpdir/align.o] {
unresolved $testname
@ -34,3 +34,7 @@ if ![ld_simple_link $ld tmpdir/align "-T $srcdir/$subdir/align.t tmpdir/align.o"
} else {
pass $testname
}
run_dump_test align2a
run_dump_test align2b
run_dump_test align2c

View file

@ -0,0 +1,6 @@
SECTIONS
{
.text : {*(.text)}
. = ALIGN(data_align);
.data : {*(.data)}
}

View file

@ -0,0 +1,13 @@
# ld: --defsym data_align=16 -T align2.t
# objdump: --section-headers
[^:]+: +file format.*
Sections:
Idx +Name +Size +VMA +LMA +File +off +Algn
+0 +\.text +00000004 +00000000 +00000000 +00001000 +2\*\*2
+CONTENTS, +ALLOC, +LOAD, +READONLY, +CODE
+1 +\.data +00000004 +00000010 +00000010 +00001010 +2\*\*2
+CONTENTS, +ALLOC, +LOAD, +DATA
+2 +\.bss +00000000 +00000014 +00000014 +00001014 +2\*\*2
+ALLOC

View file

@ -0,0 +1,4 @@
.text
.long 0
.data
.long 0x12345678

View file

@ -0,0 +1,13 @@
# ld: --defsym data_align=32 -T align2.t
# objdump: --section-headers
[^:]+: +file +format.*
Sections:
Idx +Name +Size +VMA +LMA +File off +Algn
+0 +\.text +00000004 +00000000 +00000000 +00001000 +2\*\*2
+CONTENTS, +ALLOC, +LOAD, +READONLY, +CODE
+1 +\.data +00000004 +00000020 +00000020 +00001020 +2\*\*2
+CONTENTS, +ALLOC, +LOAD, +DATA
+2 +\.bss +00000000 +00000024 +00000024 +00001024 +2\*\*2
+ALLOC

View file

@ -0,0 +1,4 @@
.text
.long 0
.data
.long 0x12345678

View file

@ -0,0 +1,2 @@
# ld: -T align2.t
# error: undefined symbol.*in expression

View file

@ -0,0 +1,4 @@
.text
.long 0
.data
.long 0x12345678