[LINKER] Add single underscore to all definitions, no -D for dashed param.

This makes possibility for the script to append the definitions to CFLAGS
and LDFLAGS, and with the feature of disabling of -D prependation it will
make possible to generate ARCH_FLAGS generic to each specific chip.
This commit is contained in:
BuFran
2013-07-14 08:00:18 +02:00
committed by Piotr Esden-Tempski
parent ea589b9a4e
commit d15a0e63fe
10 changed files with 46 additions and 33 deletions

View File

@@ -90,7 +90,10 @@ Line description:
"+" - Don't change the parent. Use for split long line to two. "+" - Don't change the parent. Use for split long line to two.
<data>: space-separated list of preprocessor symbols supplied to the linker. <data>: space-separated list of preprocessor symbols supplied to the linker.
-D option name is automatically prepended to each symbol definition -D option name with single underscore is automatically prepended to each
symbol definition
if the symbol starts with dash "-", it is interpreted as parameter to
linker, and no -D or underscore is generated.
All lines starting with # symbol are treated as Comments All lines starting with # symbol are treated as Comments
@@ -118,14 +121,15 @@ Example:
--- devices.data file --- --- devices.data file ---
stm32f05[01]?4* stm32f0 ROM=16K RAM=4K stm32f05[01]?4* stm32f0 ROM=16K RAM=4K
stm32f0 stm32 ROM_OFF=0x08000000 RAM_OFF=0x20000000 stm32f0 stm32 ROM_OFF=0x08000000 RAM_OFF=0x20000000 -mcpu=cortex-m0 -mthumb
stm32 END stm32 END
--- queried chip name --- --- queried chip name ---
stm32f051c4t6 stm32f051c4t6
--- output of the awk script --- --- output of the awk script ---
-DROM=16K -DRAM=4K -DROM_OFF=0x08000000 -DRAM_OFF=0x20000000 -D_ROM=16K -D_RAM=4K -D_ROM_OFF=0x08000000 -D_RAM_OFF=0x20000000 \
-mcpu=cortex-m0 -mthumb
The generated linker script file will contain sections rom and ram with The generated linker script file will contain sections rom and ram with
appropriate initialization code, specified in linker file source linker.ld.S appropriate initialization code, specified in linker file source linker.ld.S

View File

@@ -30,31 +30,34 @@ ENTRY(reset_handler)
MEMORY MEMORY
{ {
/* RAM is always used */ /* RAM is always used */
ram (rwx) : ORIGIN = RAM_OFF, LENGTH = RAM ram (rwx) : ORIGIN = _RAM_OFF, LENGTH = _RAM
#if defined(ROM) #if defined(_ROM)
rom (rx) : ORIGIN = ROM_OFF, LENGTH = ROM rom (rx) : ORIGIN = _ROM_OFF, LENGTH = _ROM
#endif #endif
#if defined(ROM2) #if defined(_ROM1)
rom2 (rx) : ORIGIN = ROM2_OFF, LENGTH = ROM2 rom1 (rx) : ORIGIN = _ROM1_OFF, LENGTH = _ROM1
#endif #endif
#if defined(RAM1) #if defined(_ROM2)
ram1 (rwx) : ORIGIN = RAM1_OFF, LENGTH = RAM1 rom2 (rx) : ORIGIN = _ROM2_OFF, LENGTH = _ROM2
#endif #endif
#if defined(RAM2) #if defined(_RAM1)
ram2 (rwx) : ORIGIN = RAM2_OFF, LENGTH = RAM2 ram1 (rwx) : ORIGIN = _RAM1_OFF, LENGTH = _RAM1
#endif #endif
#if defined(CCM) #if defined(_RAM2)
ccm (rwx) : ORIGIN = CCM_OFF, LENGTH = CCM ram2 (rwx) : ORIGIN = _RAM2_OFF, LENGTH = _RAM2
#endif #endif
#if defined(EEP) #if defined(_CCM)
eep (r) : ORIGIN = EEP_OFF, LENGTH = EEP ccm (rwx) : ORIGIN = _CCM_OFF, LENGTH = _CCM
#endif #endif
#if defined(XSRAM) #if defined(_EEP)
xsram (rw) : ORIGIN = XSRAM_OFF, LENGTH = XSRAM eep (r) : ORIGIN = _EEP_OFF, LENGTH = _EEP
#endif #endif
#if defined(XDRAM) #if defined(_XSRAM)
xdram (rw) : ORIGIN = XDRAM_OFF, LENGTH = XDRAM xsram (rw) : ORIGIN = _XSRAM_OFF, LENGTH = _XSRAM
#endif
#if defined(_XDRAM)
xdram (rw) : ORIGIN = _XDRAM_OFF, LENGTH = _XDRAM
#endif #endif
} }
@@ -124,42 +127,42 @@ SECTIONS
_ebss = .; _ebss = .;
} >ram } >ram
#if defined(EEP) #if defined(_EEP)
.eep : { .eep : {
*(.eeprom*) *(.eeprom*)
. = ALIGN(4); . = ALIGN(4);
} >eep } >eep
#endif #endif
#if defined(CCM) #if defined(_CCM)
.ccm : { .ccm : {
*(.ccmram*) *(.ccmram*)
. = ALIGN(4); . = ALIGN(4);
} >ccm } >ccm
#endif #endif
#if defined(RAM1) #if defined(_RAM1)
.ram1 : { .ram1 : {
*(.ram1*) *(.ram1*)
. = ALIGN(4); . = ALIGN(4);
} >ram1 } >ram1
#endif #endif
#if defined(RAM2) #if defined(_RAM2)
.ram2 : { .ram2 : {
*(.ram2*) *(.ram2*)
. = ALIGN(4); . = ALIGN(4);
} >ram2 } >ram2
#endif #endif
#if defined(XSRAM) #if defined(_XSRAM)
.xsram : { .xsram : {
*(.xsram*) *(.xsram*)
. = ALIGN(4); . = ALIGN(4);
} >xsram } >xsram
#endif #endif
#if defined(XDRAM) #if defined(_XDRAM)
.xdram : { .xdram : {
*(.xdram*) *(.xdram*)
. = ALIGN(4); . = ALIGN(4);

1
ld/tests/dash.data Normal file
View File

@@ -0,0 +1 @@
dash END A B C D -mcpu=cortex-m0

1
ld/tests/dash.result Normal file
View File

@@ -0,0 +1 @@
-D_A -D_B -D_C -D_D -mcpu=cortex-m0

View File

@@ -1 +1 @@
-DA=parameter -DB=parameter -DC=parameter -DD=parameter -DE==parameter -DF=parameter -DG=parameter -D_A=parameter -D_B=parameter -D_C=parameter -D_D=parameter -D_E==parameter -D_F=parameter -D_G=parameter

View File

@@ -1 +1 @@
-DA -DB -DC -DD -D_A -D_B -D_C -D_D

View File

@@ -1 +1 @@
-DA -DB -DC -DD -DE -DF -D_A -D_B -D_C -D_D -D_E -D_F

View File

@@ -1 +1 @@
-DA -DB -DC -DD -DE -DF -D_A -D_B -D_C -D_D -D_E -D_F

View File

@@ -1 +1 @@
-DA -DB -DC -DD -DE -DF -D_A -D_B -D_C -D_D -D_E -D_F

View File

@@ -38,8 +38,12 @@ BEGIN {
if ($2 != "+") if ($2 != "+")
PAT=$2; PAT=$2;
for (i = 3; i <= NF; i = i + 1) for (i = 3; i <= NF; i = i + 1) {
printf "-D%s ",$i; if ($i ~ /^-/)
printf "%s ",$i;
else
printf "-D_%s ",$i;
}
if (PAT=="END") if (PAT=="END")
exit; exit;