summaryrefslogtreecommitdiff
path: root/ld/ldexp.c
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2007-06-18 12:38:22 +0000
committerNathan Sidwell <nathan@codesourcery.com>2007-06-18 12:38:22 +0000
commitcff9318706eebe5aec2326c538f428f6e3522735 (patch)
treef38208b8459837195f5386ed0f4667290bb85a67 /ld/ldexp.c
parentc22879472d827ddcf241e2f05edf69682b99c050 (diff)
downloadbinutils-redhat-cff9318706eebe5aec2326c538f428f6e3522735.tar.gz
* ldlex.l, ldgram.y: Add ALIGNOF.
* ldexp.c (exp_print_token, foldname): Likewise. * ld.texinfo: Likewise. ld/testsuite/ * ld-scripts/alignof.s: New. * ld-scripts/alignof.t: New * ld-scripts/alignof.exp: New.
Diffstat (limited to 'ld/ldexp.c')
-rw-r--r--ld/ldexp.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/ld/ldexp.c b/ld/ldexp.c
index 43f96eaf5d..4f1d61d28d 100644
--- a/ld/ldexp.c
+++ b/ld/ldexp.c
@@ -97,6 +97,7 @@ exp_print_token (token_code_type code, int infix_p)
{ MAP, "MAP" },
{ ENTRY, "ENTRY" },
{ NEXT, "NEXT" },
+ { ALIGNOF, "ALIGNOF" },
{ SIZEOF, "SIZEOF" },
{ ADDR, "ADDR" },
{ LOADADDR, "LOADADDR" },
@@ -606,9 +607,9 @@ fold_name (etree_type *tree)
break;
case SIZEOF:
+ case ALIGNOF:
if (expld.phase != lang_first_phase_enum)
{
- int opb = bfd_octets_per_byte (output_bfd);
lang_output_section_statement_type *os;
os = lang_output_section_find (tree->name.name);
@@ -620,7 +621,16 @@ fold_name (etree_type *tree)
new_abs (0);
}
else if (os->processed_vma)
- new_abs (os->bfd_section->size / opb);
+ {
+ bfd_vma val;
+
+ if (tree->type.node_code == SIZEOF)
+ val = os->bfd_section->size / bfd_octets_per_byte (output_bfd);
+ else
+ val = (bfd_vma)1 << os->bfd_section->alignment_power;
+
+ new_abs (val);
+ }
}
break;