* 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.
@ -14,7 +23,7 @@
not defined.
(gld${EMULATION_NAME}_parse_ld_so_conf_include): Do not use glob
if HAVE_GLOB is not defined.
2005-02-16 Kaz Kojima <kkojima@rr.iij4u.or.jp>
* emultempl/elf32.em (gld${EMULATION_NAME}_after_open): Define
@ -32,7 +41,7 @@
* ldlex.l (YY_NO_UNPUT): Define so that the yy_unput function is
not declared. It is not used and its presence causes a compile
time warning.
2005-02-11 Zack Weinberg <zack@codesourcery.com>
* emultempl/elf32.em (gld${EMULATION_NAME}_stat_needed):

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.
@ -216,7 +224,7 @@
2004-12-21 Tomer Levi <Tomer.Levi@nsc.com>
* ld-crx/reloc-abs32.d: Update reference file according
* ld-crx/reloc-abs32.d: Update reference file according
to disassembler printing method.
* ld-crx/reloc-rel16.d: Likewise.
* ld-crx/reloc-rel24.d: Likewise.

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