From cff9318706eebe5aec2326c538f428f6e3522735 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Mon, 18 Jun 2007 12:38:22 +0000 Subject: * 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. --- ld/ldexp.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'ld/ldexp.c') 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; -- cgit v1.2.1