From 3d9c8f6b3f033a6092425b7344647fb51dbed5c6 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Sun, 26 Aug 2018 14:23:38 +0930 Subject: Delay evaluation of alignment expressions in output sections git commit 702d16713 broke expressions using CONSTANT(COMMONPAGESIZE) in ALIGN or SUBALIGN of output section statements, because these optional fields were evaluated at script parse time and the patch in question delayed setting of config.commonpagesize. The right thing to do is keep the tree representation of those fields for later evaluation. PR 23571 * ldlang.h (section_alignment): Make it an expression tree. (subsection_alignment): Likewise. * ldlang.c (topower): Delete. (output_section_statement_newfunc): Adjust initialization. (init_os): Evaluate section_alignment. (lang_size_sections_1): Likewise. (size_input_section): Evaluate subsection_alignment. (lang_enter_output_section_statement): Don't evaluate here. (lang_new_phdr): Use exp_get_vma rather than exp_get_value_int. * ldexp.h (exp_get_value_int): Delete. (exp_get_power): Declare. * ldexp.c (exp_get_value_int): Delete. (exp_get_power): New function. * emultempl/pe.em (place_orphan): Build expression for section alignment. * emultempl/pep.em (place_orphan): Likewise. * testsuite/ld-scripts/pr23571.d, * testsuite/ld-scripts/pr23571.t: New test. * testsuite/ld-scripts/align.exp: Run it. --- ld/ldlang.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ld/ldlang.h') diff --git a/ld/ldlang.h b/ld/ldlang.h index 3d66169..dfac0b1 100644 --- a/ld/ldlang.h +++ b/ld/ldlang.h @@ -143,6 +143,8 @@ typedef struct lang_output_section_statement_struct fill_type *fill; union etree_union *addr_tree; union etree_union *load_base; + union etree_union *section_alignment; + union etree_union *subsection_alignment; /* If non-null, an expression to evaluate after setting the section's size. The expression is evaluated inside REGION (above) with '.' @@ -153,8 +155,6 @@ typedef struct lang_output_section_statement_struct lang_output_section_phdr_list *phdrs; unsigned int block_value; - int subsection_alignment; /* Alignment of components. */ - int section_alignment; /* Alignment of start of section. */ int constraint; flagword flags; enum section_type sectype; -- cgit v1.1