[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:
parent
ea589b9a4e
commit
d15a0e63fe
10
ld/README
10
ld/README
@ -90,7 +90,10 @@ Line description:
|
||||
"+" - Don't change the parent. Use for split long line to two.
|
||||
|
||||
<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
|
||||
|
||||
@ -118,14 +121,15 @@ Example:
|
||||
|
||||
--- devices.data file ---
|
||||
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
|
||||
|
||||
--- queried chip name ---
|
||||
stm32f051c4t6
|
||||
|
||||
--- 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
|
||||
appropriate initialization code, specified in linker file source linker.ld.S
|
||||
|
@ -30,31 +30,34 @@ ENTRY(reset_handler)
|
||||
MEMORY
|
||||
{
|
||||
/* RAM is always used */
|
||||
ram (rwx) : ORIGIN = RAM_OFF, LENGTH = RAM
|
||||
ram (rwx) : ORIGIN = _RAM_OFF, LENGTH = _RAM
|
||||
|
||||
#if defined(ROM)
|
||||
rom (rx) : ORIGIN = ROM_OFF, LENGTH = ROM
|
||||
#if defined(_ROM)
|
||||
rom (rx) : ORIGIN = _ROM_OFF, LENGTH = _ROM
|
||||
#endif
|
||||
#if defined(ROM2)
|
||||
rom2 (rx) : ORIGIN = ROM2_OFF, LENGTH = ROM2
|
||||
#if defined(_ROM1)
|
||||
rom1 (rx) : ORIGIN = _ROM1_OFF, LENGTH = _ROM1
|
||||
#endif
|
||||
#if defined(RAM1)
|
||||
ram1 (rwx) : ORIGIN = RAM1_OFF, LENGTH = RAM1
|
||||
#if defined(_ROM2)
|
||||
rom2 (rx) : ORIGIN = _ROM2_OFF, LENGTH = _ROM2
|
||||
#endif
|
||||
#if defined(RAM2)
|
||||
ram2 (rwx) : ORIGIN = RAM2_OFF, LENGTH = RAM2
|
||||
#if defined(_RAM1)
|
||||
ram1 (rwx) : ORIGIN = _RAM1_OFF, LENGTH = _RAM1
|
||||
#endif
|
||||
#if defined(CCM)
|
||||
ccm (rwx) : ORIGIN = CCM_OFF, LENGTH = CCM
|
||||
#if defined(_RAM2)
|
||||
ram2 (rwx) : ORIGIN = _RAM2_OFF, LENGTH = _RAM2
|
||||
#endif
|
||||
#if defined(EEP)
|
||||
eep (r) : ORIGIN = EEP_OFF, LENGTH = EEP
|
||||
#if defined(_CCM)
|
||||
ccm (rwx) : ORIGIN = _CCM_OFF, LENGTH = _CCM
|
||||
#endif
|
||||
#if defined(XSRAM)
|
||||
xsram (rw) : ORIGIN = XSRAM_OFF, LENGTH = XSRAM
|
||||
#if defined(_EEP)
|
||||
eep (r) : ORIGIN = _EEP_OFF, LENGTH = _EEP
|
||||
#endif
|
||||
#if defined(XDRAM)
|
||||
xdram (rw) : ORIGIN = XDRAM_OFF, LENGTH = XDRAM
|
||||
#if defined(_XSRAM)
|
||||
xsram (rw) : ORIGIN = _XSRAM_OFF, LENGTH = _XSRAM
|
||||
#endif
|
||||
#if defined(_XDRAM)
|
||||
xdram (rw) : ORIGIN = _XDRAM_OFF, LENGTH = _XDRAM
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -124,42 +127,42 @@ SECTIONS
|
||||
_ebss = .;
|
||||
} >ram
|
||||
|
||||
#if defined(EEP)
|
||||
#if defined(_EEP)
|
||||
.eep : {
|
||||
*(.eeprom*)
|
||||
. = ALIGN(4);
|
||||
} >eep
|
||||
#endif
|
||||
|
||||
#if defined(CCM)
|
||||
#if defined(_CCM)
|
||||
.ccm : {
|
||||
*(.ccmram*)
|
||||
. = ALIGN(4);
|
||||
} >ccm
|
||||
#endif
|
||||
|
||||
#if defined(RAM1)
|
||||
#if defined(_RAM1)
|
||||
.ram1 : {
|
||||
*(.ram1*)
|
||||
. = ALIGN(4);
|
||||
} >ram1
|
||||
#endif
|
||||
|
||||
#if defined(RAM2)
|
||||
#if defined(_RAM2)
|
||||
.ram2 : {
|
||||
*(.ram2*)
|
||||
. = ALIGN(4);
|
||||
} >ram2
|
||||
#endif
|
||||
|
||||
#if defined(XSRAM)
|
||||
#if defined(_XSRAM)
|
||||
.xsram : {
|
||||
*(.xsram*)
|
||||
. = ALIGN(4);
|
||||
} >xsram
|
||||
#endif
|
||||
|
||||
#if defined(XDRAM)
|
||||
#if defined(_XDRAM)
|
||||
.xdram : {
|
||||
*(.xdram*)
|
||||
. = ALIGN(4);
|
||||
|
1
ld/tests/dash.data
Normal file
1
ld/tests/dash.data
Normal file
@ -0,0 +1 @@
|
||||
dash END A B C D -mcpu=cortex-m0
|
1
ld/tests/dash.result
Normal file
1
ld/tests/dash.result
Normal file
@ -0,0 +1 @@
|
||||
-D_A -D_B -D_C -D_D -mcpu=cortex-m0
|
@ -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
|
@ -1 +1 @@
|
||||
-DA -DB -DC -DD
|
||||
-D_A -D_B -D_C -D_D
|
@ -1 +1 @@
|
||||
-DA -DB -DC -DD -DE -DF
|
||||
-D_A -D_B -D_C -D_D -D_E -D_F
|
@ -1 +1 @@
|
||||
-DA -DB -DC -DD -DE -DF
|
||||
-D_A -D_B -D_C -D_D -D_E -D_F
|
@ -1 +1 @@
|
||||
-DA -DB -DC -DD -DE -DF
|
||||
-D_A -D_B -D_C -D_D -D_E -D_F
|
@ -38,8 +38,12 @@ BEGIN {
|
||||
if ($2 != "+")
|
||||
PAT=$2;
|
||||
|
||||
for (i = 3; i <= NF; i = i + 1)
|
||||
printf "-D%s ",$i;
|
||||
for (i = 3; i <= NF; i = i + 1) {
|
||||
if ($i ~ /^-/)
|
||||
printf "%s ",$i;
|
||||
else
|
||||
printf "-D_%s ",$i;
|
||||
}
|
||||
|
||||
if (PAT=="END")
|
||||
exit;
|
||||
|
Loading…
x
Reference in New Issue
Block a user