aboutsummaryrefslogtreecommitdiff
path: root/ld/ldexp.c
diff options
context:
space:
mode:
authorSenthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com>2015-01-28 15:01:50 +1030
committerAlan Modra <amodra@gmail.com>2015-01-28 15:06:48 +1030
commitcc9ad334a71b0c032f711e86885fb73821f3be16 (patch)
treee721067748cda338595b230ab0557039b65d94f4 /ld/ldexp.c
parente5fe4957b4513015b40472086f22cf8723b95773 (diff)
downloadgdb-cc9ad334a71b0c032f711e86885fb73821f3be16.zip
gdb-cc9ad334a71b0c032f711e86885fb73821f3be16.tar.gz
gdb-cc9ad334a71b0c032f711e86885fb73821f3be16.tar.bz2
Allow symbols in MEMORY region specification
This patch fixes PR 4643 by allowing symbols in the LENGTH and ORIGIN fields of MEMORY regions. Previously, only constants and constant expressions are allowed. For the AVR target, this helps define memory constraints more accurately (per device), without having to create a ton of device specific linker scripts. ld/ PR 4643 * ldexp.c (fold_name): Fold LENGTH only after lang_first_phase_enum. * ldgram.y (memory_spec): Don't evaluate ORIGIN and LENGTH rightaway. * ldlang.h (struct memory_region_struct): Add origin_exp and length_exp fields. * ldlang.c (lang_do_memory_regions): New. (lang_memory_region_lookup): Initialize origin_exp and length_exp fields. (lang_process): Call lang_do_memory_regions. ld/testsuite/ * ld-scripts/memory.t: Define new symbol tred. * ld-scripts/memory_sym.t: New. * ld-scripts/script.exp: Perform MEMORY with symbols test, and conditionally check values of linker symbols.
Diffstat (limited to 'ld/ldexp.c')
-rw-r--r--ld/ldexp.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/ld/ldexp.c b/ld/ldexp.c
index f2c8620..ac66cc0 100644
--- a/ld/ldexp.c
+++ b/ld/ldexp.c
@@ -828,15 +828,18 @@ fold_name (etree_type *tree)
case LENGTH:
{
- lang_memory_region_type *mem;
-
- mem = lang_memory_region_lookup (tree->name.name, FALSE);
- if (mem != NULL)
- new_number (mem->length);
- else
- einfo (_("%F%S: undefined MEMORY region `%s'"
- " referenced in expression\n"),
- tree, tree->name.name);
+ 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%S: undefined MEMORY region `%s'"
+ " referenced in expression\n"),
+ tree, tree->name.name);
+ }
}
break;