* ldgram.y (exp): Add two operand ALIGN.
* ldexp.c (fold_binary): Add ALIGN_K case. * ld.texinfo (ALIGN): Document two operand version. * ld-scripts/align.{s,t,exp}: New.
This commit is contained in:
parent
627fe3fb79
commit
876f40905a
9 changed files with 75 additions and 10 deletions
|
@ -1,7 +1,7 @@
|
||||||
2004-02-20 Nathan Sidwell <nathan@codesourcery.com>
|
2004-02-20 Nathan Sidwell <nathan@codesourcery.com>
|
||||||
|
|
||||||
* binutils-all/objcopy.exp: Reorder arguments for POSIXLY_CORRECT
|
* binutils-all/objcopy.exp: Reorder arguments for POSIXLY_CORRECT
|
||||||
systems.p
|
systems.
|
||||||
|
|
||||||
For older changes see ChangeLog-9303
|
For older changes see ChangeLog-9303
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
2004-02-20 Nathan Sidwell <nathan@codesourcery.com>
|
||||||
|
|
||||||
|
* ldgram.y (exp): Add two operand ALIGN.
|
||||||
|
* ldexp.c (fold_binary): Add ALIGN_K case.
|
||||||
|
* ld.texinfo (ALIGN): Document two operand version.
|
||||||
|
|
||||||
2004-02-19 Nathan Sidwell <nathan@codesourcery.com>
|
2004-02-19 Nathan Sidwell <nathan@codesourcery.com>
|
||||||
|
|
||||||
* ldlang.c (map_input_to_output_sections): Initialize sections
|
* ldlang.c (map_input_to_output_sections): Initialize sections
|
||||||
|
|
|
@ -4383,17 +4383,25 @@ SECTIONS @{ @dots{}
|
||||||
@end group
|
@end group
|
||||||
@end smallexample
|
@end smallexample
|
||||||
|
|
||||||
@item ALIGN(@var{exp})
|
@item ALIGN(@var{align})
|
||||||
@kindex ALIGN(@var{exp})
|
@itemx ALIGN(@var{exp},@var{align})
|
||||||
|
@kindex ALIGN(@var{align})
|
||||||
|
@kindex ALIGN(@var{exp},@var{align})
|
||||||
@cindex round up location counter
|
@cindex round up location counter
|
||||||
@cindex align location counter
|
@cindex align location counter
|
||||||
Return the location counter (@code{.}) aligned to the next @var{exp}
|
@cindex round up expression
|
||||||
boundary.
|
@cindex align expression
|
||||||
@code{ALIGN} doesn't change the value of the location counter---it just
|
Return the location counter (@code{.}) or arbitrary expression aligned
|
||||||
does arithmetic on it. Here is an example which aligns the output
|
to the next @var{align} boundary. The single operand @code{ALIGN}
|
||||||
@code{.data} section to the next @code{0x2000} byte boundary after the
|
doesn't change the value of the location counter---it just does
|
||||||
preceding section and sets a variable within the section to the next
|
arithmetic on it. The two operand @code{ALIGN} allows an arbitrary
|
||||||
@code{0x8000} boundary after the input sections:
|
expression to be aligned upwards (@code{ALIGN(@var{align})} is
|
||||||
|
equivalent to @code{ALIGN(., @var{align})}).
|
||||||
|
|
||||||
|
Here is an example which aligns the output @code{.data} section to the
|
||||||
|
next @code{0x2000} byte boundary after the preceding section and sets a
|
||||||
|
variable within the section to the next @code{0x8000} boundary after the
|
||||||
|
input sections:
|
||||||
@smallexample
|
@smallexample
|
||||||
@group
|
@group
|
||||||
SECTIONS @{ @dots{}
|
SECTIONS @{ @dots{}
|
||||||
|
|
|
@ -394,6 +394,10 @@ fold_binary (etree_type *tree,
|
||||||
result = other;
|
result = other;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case ALIGN_K:
|
||||||
|
result.value = align_n (result.value, other.value);
|
||||||
|
break;
|
||||||
|
|
||||||
case DATA_SEGMENT_ALIGN:
|
case DATA_SEGMENT_ALIGN:
|
||||||
if (allocation_done != lang_first_phase_enum
|
if (allocation_done != lang_first_phase_enum
|
||||||
&& current_section == abs_output_section
|
&& current_section == abs_output_section
|
||||||
|
|
|
@ -804,6 +804,8 @@ exp :
|
||||||
{ $$ = exp_unop(ABSOLUTE, $3); }
|
{ $$ = exp_unop(ABSOLUTE, $3); }
|
||||||
| ALIGN_K '(' exp ')'
|
| ALIGN_K '(' exp ')'
|
||||||
{ $$ = exp_unop(ALIGN_K,$3); }
|
{ $$ = exp_unop(ALIGN_K,$3); }
|
||||||
|
| ALIGN_K '(' exp ',' exp ')'
|
||||||
|
{ $$ = exp_binop(ALIGN_K,$3,$5); }
|
||||||
| DATA_SEGMENT_ALIGN '(' exp ',' exp ')'
|
| DATA_SEGMENT_ALIGN '(' exp ',' exp ')'
|
||||||
{ $$ = exp_binop (DATA_SEGMENT_ALIGN, $3, $5); }
|
{ $$ = exp_binop (DATA_SEGMENT_ALIGN, $3, $5); }
|
||||||
| DATA_SEGMENT_END '(' exp ')'
|
| DATA_SEGMENT_END '(' exp ')'
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
2004-02-20 Nathan Sidwell <nathan@codesourcery.com>
|
||||||
|
|
||||||
|
* ld-scripts/align.{s,t,exp}: New.
|
||||||
|
|
||||||
2004-02-19 Nathan Sidwell <nathan@codesourcery.com>
|
2004-02-19 Nathan Sidwell <nathan@codesourcery.com>
|
||||||
|
|
||||||
* ld-scripts/data.{s,t,d,exp}: New.
|
* ld-scripts/data.{s,t,d,exp}: New.
|
||||||
|
|
31
ld/testsuite/ld-scripts/align.exp
Normal file
31
ld/testsuite/ld-scripts/align.exp
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
# Test ALIGN in a linker script.
|
||||||
|
# By Nathan Sidwell, CodeSourcery LLC
|
||||||
|
# Copyright 2004
|
||||||
|
# Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This file is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
set testname "ALIGN"
|
||||||
|
|
||||||
|
if ![ld_assemble $as $srcdir/$subdir/align.s tmpdir/align.o] {
|
||||||
|
unresolved $testname
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if ![ld_simple_link $ld tmpdir/align "-T $srcdir/$subdir/align.t tmpdir/align.o"] {
|
||||||
|
fail $testname
|
||||||
|
} else {
|
||||||
|
pass $testname
|
||||||
|
}
|
2
ld/testsuite/ld-scripts/align.s
Normal file
2
ld/testsuite/ld-scripts/align.s
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
.text
|
||||||
|
.long 0
|
8
ld/testsuite/ld-scripts/align.t
Normal file
8
ld/testsuite/ld-scripts/align.t
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
.text : {*(.text)}
|
||||||
|
.data ALIGN(0x40) : AT (ALIGN (LOADADDR (.text) + SIZEOF (.text), 0x80))
|
||||||
|
{}
|
||||||
|
ASSERT (LOADADDR(.data) == 0x80, "dyadic ALIGN broken")
|
||||||
|
ASSERT (ADDR(.data) == 0x40, "monadic ALIGN broken")
|
||||||
|
}
|
Loading…
Reference in a new issue