From 912ebfa0d748b4a762dbc4311364c38692c7f626 Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Wed, 6 Mar 2019 15:20:29 +0000 Subject: [PATCH] Allow the use of the ORIGIN and LENGTH attributes in expressions inside MEMORY regions. PR 24289 * ldexp.c (fold_name): Allow lookups of the LENGTH and ORIGIN attributes during the first phase. --- ld/ChangeLog | 6 ++++++ ld/ldexp.c | 44 ++++++++++++++++++++------------------------ 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/ld/ChangeLog b/ld/ChangeLog index 1877a1c1616..c2cbe87947e 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,9 @@ +2019-03-06 Nick Bowler + + PR 24289 + * ldexp.c (fold_name): Allow lookups of the LENGTH and ORIGIN + attributes during the first phase. + 2019-03-01 Andreas Krebbel This reverts commit 5a12586d44fa8d5dfc74cbca4f2f36a273a16335. diff --git a/ld/ldexp.c b/ld/ldexp.c index 60b17ef5764..daf0f2e3823 100644 --- a/ld/ldexp.c +++ b/ld/ldexp.c @@ -864,34 +864,30 @@ fold_name (etree_type *tree) case LENGTH: { - if (expld.phase != lang_first_phase_enum) - { - lang_memory_region_type *mem; - - mem = lang_memory_region_lookup (tree->name.name, FALSE); - if (mem != NULL) - new_number (mem->length); - else - einfo (_("%F%P:%pS: undefined MEMORY region `%s'" - " referenced in expression\n"), - tree, tree->name.name); - } + lang_memory_region_type *mem; + + mem = lang_memory_region_lookup (tree->name.name, FALSE); + if (mem != NULL) + new_number (mem->length); + else + einfo (_("%F%P:%pS: undefined MEMORY region `%s'" + " referenced in expression\n"), + tree, tree->name.name); } break; case ORIGIN: - if (expld.phase != lang_first_phase_enum) - { - lang_memory_region_type *mem; - - mem = lang_memory_region_lookup (tree->name.name, FALSE); - if (mem != NULL) - new_rel_from_abs (mem->origin); - else - einfo (_("%F%P:%pS: undefined MEMORY region `%s'" - " referenced in expression\n"), - tree, tree->name.name); - } + { + lang_memory_region_type *mem; + + mem = lang_memory_region_lookup (tree->name.name, FALSE); + if (mem != NULL) + new_rel_from_abs (mem->origin); + else + einfo (_("%F%P:%pS: undefined MEMORY region `%s'" + " referenced in expression\n"), + tree, tree->name.name); + } break; case CONSTANT: -- 2.30.2