Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/thirdpin/libopencm3.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorBuFran <BuFran@seznam.cz>2013-07-14 10:00:18 +0400
committerPiotr Esden-Tempski <piotr@esden.net>2014-01-03 00:50:02 +0400
commitd15a0e63fe11735381d5196b22789bb6d94a5f16 (patch)
treed3628502637b01f34c84fc62e09104cabd1700a8 /ld
parentea589b9a4ed6f7876c1fa0f9c7c653168fc9b277 (diff)
[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.
Diffstat (limited to 'ld')
-rw-r--r--ld/README10
-rw-r--r--ld/linker.ld.S49
-rw-r--r--ld/tests/dash.data1
-rw-r--r--ld/tests/dash.result1
-rw-r--r--ld/tests/longline.result2
-rw-r--r--ld/tests/single.result2
-rw-r--r--ld/tests/tree1.result2
-rw-r--r--ld/tests/tree5.result2
-rw-r--r--ld/tests/twomatch.result2
9 files changed, 40 insertions, 31 deletions
diff --git a/ld/README b/ld/README
index 0e30b598..f270afbf 100644
--- a/ld/README
+++ b/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
diff --git a/ld/linker.ld.S b/ld/linker.ld.S
index 7618d158..daa6b7c3 100644
--- a/ld/linker.ld.S
+++ b/ld/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);
diff --git a/ld/tests/dash.data b/ld/tests/dash.data
new file mode 100644
index 00000000..eb12e28e
--- /dev/null
+++ b/ld/tests/dash.data
@@ -0,0 +1 @@
+dash END A B C D -mcpu=cortex-m0 \ No newline at end of file
diff --git a/ld/tests/dash.result b/ld/tests/dash.result
new file mode 100644
index 00000000..8d876a24
--- /dev/null
+++ b/ld/tests/dash.result
@@ -0,0 +1 @@
+-D_A -D_B -D_C -D_D -mcpu=cortex-m0 \ No newline at end of file
diff --git a/ld/tests/longline.result b/ld/tests/longline.result
index 1e8f54b5..78a1477a 100644
--- a/ld/tests/longline.result
+++ b/ld/tests/longline.result
@@ -1 +1 @@
--DA=parameter -DB=parameter -DC=parameter -DD=parameter -DE==parameter -DF=parameter -DG=parameter \ No newline at end of file
+-D_A=parameter -D_B=parameter -D_C=parameter -D_D=parameter -D_E==parameter -D_F=parameter -D_G=parameter \ No newline at end of file
diff --git a/ld/tests/single.result b/ld/tests/single.result
index 2ba3e0ca..3191ddd9 100644
--- a/ld/tests/single.result
+++ b/ld/tests/single.result
@@ -1 +1 @@
--DA -DB -DC -DD \ No newline at end of file
+-D_A -D_B -D_C -D_D \ No newline at end of file
diff --git a/ld/tests/tree1.result b/ld/tests/tree1.result
index 34e125f8..b71bb04e 100644
--- a/ld/tests/tree1.result
+++ b/ld/tests/tree1.result
@@ -1 +1 @@
--DA -DB -DC -DD -DE -DF \ No newline at end of file
+-D_A -D_B -D_C -D_D -D_E -D_F \ No newline at end of file
diff --git a/ld/tests/tree5.result b/ld/tests/tree5.result
index 34e125f8..b71bb04e 100644
--- a/ld/tests/tree5.result
+++ b/ld/tests/tree5.result
@@ -1 +1 @@
--DA -DB -DC -DD -DE -DF \ No newline at end of file
+-D_A -D_B -D_C -D_D -D_E -D_F \ No newline at end of file
diff --git a/ld/tests/twomatch.result b/ld/tests/twomatch.result
index 34e125f8..b71bb04e 100644
--- a/ld/tests/twomatch.result
+++ b/ld/tests/twomatch.result
@@ -1 +1 @@
--DA -DB -DC -DD -DE -DF \ No newline at end of file
+-D_A -D_B -D_C -D_D -D_E -D_F \ No newline at end of file