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.
This commit is contained in:
Senthil Kumar Selvaraj
2015-01-28 15:01:50 +10:30
committed by Alan Modra
parent e5fe4957b4
commit cc9ad334a7
9 changed files with 131 additions and 11 deletions

View File

@@ -29,5 +29,6 @@ SECTIONS
data_end = .;
} >DATAMEM
fred = ORIGIN(DATAMEM) + LENGTH(DATAMEM);
fred = ORIGIN(DATAMEM) + LENGTH(DATAMEM);
tred = ORIGIN(TEXTMEM) + LENGTH(TEXTMEM);
}