From 2a35377980a05b6eb7ed47e9979b0ff3849d749f Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Mon, 3 Sep 2012 19:41:36 +0200 Subject: Clean up and make linker scripts more uniform This includes: - fix some comments indent, - add entry point, - align exported symbols, - remove unneeded "." assignments. --- lib/lm3s/libopencm3_lm3s.ld | 14 +++++++++----- lib/lpc13xx/libopencm3_lpc13xx.ld | 14 +++++++++----- lib/lpc17xx/libopencm3_lpc17xx.ld | 12 ++++++------ lib/lpc43xx/libopencm3_lpc43xx.ld | 6 ++---- lib/lpc43xx/libopencm3_lpc43xx_rom_to_ram.ld | 5 ++--- lib/stm32/f1/libopencm3_stm32f1.ld | 12 ++++-------- lib/stm32/f2/libopencm3_stm32f2.ld | 12 ++++-------- lib/stm32/f4/libopencm3_stm32f4.ld | 3 +-- 8 files changed, 37 insertions(+), 41 deletions(-) diff --git a/lib/lm3s/libopencm3_lm3s.ld b/lib/lm3s/libopencm3_lm3s.ld index c1453fe..00ede3d 100644 --- a/lib/lm3s/libopencm3_lm3s.ld +++ b/lib/lm3s/libopencm3_lm3s.ld @@ -24,31 +24,34 @@ /* Enforce emmition of the vector table. */ EXTERN (vector_table) +/* Define the entry point of the output file. */ +ENTRY(reset_handler) + /* Define sections. */ SECTIONS { - . = ORIGIN(rom); - .text : { *(.vectors) /* Vector table */ *(.text*) /* Program code */ + . = ALIGN(4); *(.rodata*) /* Read-only data */ + . = ALIGN(4); _etext = .; } >rom - . = ORIGIN(ram); - .data : { _data = .; *(.data*) /* Read-write initialized data */ + . = ALIGN(4); _edata = .; } >ram AT >rom .bss : { *(.bss*) /* Read-write zero initialized data */ *(COMMON) + . = ALIGN(4); _ebss = .; - } >ram AT >rom + } >ram /* * The .eh_frame section appears to be used for C++ exception handling. @@ -62,6 +65,7 @@ SECTIONS */ /DISCARD/ : { *(.ARM.exidx) } + . = ALIGN(4); end = .; } diff --git a/lib/lpc13xx/libopencm3_lpc13xx.ld b/lib/lpc13xx/libopencm3_lpc13xx.ld index 5f1630f..a1892cd 100644 --- a/lib/lpc13xx/libopencm3_lpc13xx.ld +++ b/lib/lpc13xx/libopencm3_lpc13xx.ld @@ -24,31 +24,34 @@ /* Enforce emmition of the vector table. */ EXTERN (vector_table) +/* Define the entry point of the output file. */ +ENTRY(reset_handler) + /* Define sections. */ SECTIONS { - . = ORIGIN(rom); - .text : { *(.vectors) /* Vector table */ *(.text*) /* Program code */ + . = ALIGN(4); *(.rodata*) /* Read-only data */ + . = ALIGN(4); _etext = .; } >rom - . = ORIGIN(ram); - .data : { _data = .; *(.data*) /* Read-write initialized data */ + . = ALIGN(4); _edata = .; } >ram AT >rom .bss : { *(.bss*) /* Read-write zero initialized data */ *(COMMON) + . = ALIGN(4); _ebss = .; - } >ram AT >rom + } >ram /* * The .eh_frame section appears to be used for C++ exception handling. @@ -62,6 +65,7 @@ SECTIONS */ /DISCARD/ : { *(.ARM.exidx) } + . = ALIGN(4); end = .; } diff --git a/lib/lpc17xx/libopencm3_lpc17xx.ld b/lib/lpc17xx/libopencm3_lpc17xx.ld index 30a2c0f..a1892cd 100644 --- a/lib/lpc17xx/libopencm3_lpc17xx.ld +++ b/lib/lpc17xx/libopencm3_lpc17xx.ld @@ -1,4 +1,3 @@ - /* * This file is part of the libopencm3 project. * @@ -31,28 +30,28 @@ ENTRY(reset_handler) /* Define sections. */ SECTIONS { - . = ORIGIN(rom); - .text : { *(.vectors) /* Vector table */ *(.text*) /* Program code */ + . = ALIGN(4); *(.rodata*) /* Read-only data */ + . = ALIGN(4); _etext = .; } >rom - . = ORIGIN(ram); - .data : { _data = .; *(.data*) /* Read-write initialized data */ + . = ALIGN(4); _edata = .; } >ram AT >rom .bss : { *(.bss*) /* Read-write zero initialized data */ *(COMMON) + . = ALIGN(4); _ebss = .; - } >ram AT >rom + } >ram /* * The .eh_frame section appears to be used for C++ exception handling. @@ -66,6 +65,7 @@ SECTIONS */ /DISCARD/ : { *(.ARM.exidx) } + . = ALIGN(4); end = .; } diff --git a/lib/lpc43xx/libopencm3_lpc43xx.ld b/lib/lpc43xx/libopencm3_lpc43xx.ld index 47b403b..2fedf09 100644 --- a/lib/lpc43xx/libopencm3_lpc43xx.ld +++ b/lib/lpc43xx/libopencm3_lpc43xx.ld @@ -32,8 +32,6 @@ ENTRY(reset_handler) /* Define sections. */ SECTIONS { - . = ORIGIN(rom); - .text : { . = ALIGN(0x400); _text_ram = 0; /* Start of Code in RAM NULL because Copy of Code from ROM to RAM disabled */ @@ -51,12 +49,11 @@ SECTIONS } > rom __exidx_end = .; + . = ALIGN(4); _etext = .; _etext_ram = 0; /* Start of Code in RAM NULL because Copy of Code from ROM to RAM disabled */ _etext_rom = 0; /* Start of Code in RAM NULL because Copy of Code from ROM to RAM disabled */ - . = ORIGIN(ram); - .data : { _data = .; *(.data*) /* Read-write initialized data */ @@ -88,6 +85,7 @@ SECTIONS */ /DISCARD/ : { *(.ARM.exidx) } + . = ALIGN(4); end = .; /* Leave room above stack for IAP to run. */ diff --git a/lib/lpc43xx/libopencm3_lpc43xx_rom_to_ram.ld b/lib/lpc43xx/libopencm3_lpc43xx_rom_to_ram.ld index 0270ea8..e39f662 100644 --- a/lib/lpc43xx/libopencm3_lpc43xx_rom_to_ram.ld +++ b/lib/lpc43xx/libopencm3_lpc43xx_rom_to_ram.ld @@ -32,8 +32,6 @@ ENTRY(reset_handler) /* Define sections. */ SECTIONS { - . = ORIGIN(rom); - .text : { . = ALIGN(0x400); _text_ram = (. - ORIGIN(rom)) + ORIGIN(ram); /* Start of Code in RAM */ @@ -52,6 +50,7 @@ SECTIONS } > rom __exidx_end = .; + . = ALIGN(4); _etext = .; _etext_ram = (. - ORIGIN(rom)) + ORIGIN(ram); _etext_rom = (. - ORIGIN(rom)) + ORIGIN(rom_flash); @@ -64,7 +63,6 @@ SECTIONS } >ram_data AT >rom .bss : { - . = _edata; *(.bss*) /* Read-write zero initialized data */ *(COMMON) . = ALIGN(4); @@ -89,6 +87,7 @@ SECTIONS */ /DISCARD/ : { *(.ARM.exidx) } + . = ALIGN(4); end = .; /* Leave room above stack for IAP to run. */ diff --git a/lib/stm32/f1/libopencm3_stm32f1.ld b/lib/stm32/f1/libopencm3_stm32f1.ld index a64a1f7..f4f8e3b 100644 --- a/lib/stm32/f1/libopencm3_stm32f1.ld +++ b/lib/stm32/f1/libopencm3_stm32f1.ld @@ -30,8 +30,6 @@ ENTRY(reset_handler) /* Define sections. */ SECTIONS { - . = ORIGIN(rom); - .text : { *(.vectors) /* Vector table */ *(.text*) /* Program code */ @@ -42,9 +40,9 @@ SECTIONS } >rom /* - * Another section used by C++ stuff, appears when using newlib with - * 64bit (long long) printf support - */ + * Another section used by C++ stuff, appears when using newlib with + * 64bit (long long) printf support + */ .ARM.extab : { *(.ARM.extab*) } >rom @@ -54,8 +52,6 @@ SECTIONS __exidx_end = .; } >rom - . = ORIGIN(ram); - .data : AT (__exidx_end) { _data = .; *(.data*) /* Read-write initialized data */ @@ -68,7 +64,7 @@ SECTIONS *(COMMON) . = ALIGN(4); _ebss = .; - } >ram AT >rom + } >ram /* * The .eh_frame section appears to be used for C++ exception handling. diff --git a/lib/stm32/f2/libopencm3_stm32f2.ld b/lib/stm32/f2/libopencm3_stm32f2.ld index a64a1f7..f4f8e3b 100644 --- a/lib/stm32/f2/libopencm3_stm32f2.ld +++ b/lib/stm32/f2/libopencm3_stm32f2.ld @@ -30,8 +30,6 @@ ENTRY(reset_handler) /* Define sections. */ SECTIONS { - . = ORIGIN(rom); - .text : { *(.vectors) /* Vector table */ *(.text*) /* Program code */ @@ -42,9 +40,9 @@ SECTIONS } >rom /* - * Another section used by C++ stuff, appears when using newlib with - * 64bit (long long) printf support - */ + * Another section used by C++ stuff, appears when using newlib with + * 64bit (long long) printf support + */ .ARM.extab : { *(.ARM.extab*) } >rom @@ -54,8 +52,6 @@ SECTIONS __exidx_end = .; } >rom - . = ORIGIN(ram); - .data : AT (__exidx_end) { _data = .; *(.data*) /* Read-write initialized data */ @@ -68,7 +64,7 @@ SECTIONS *(COMMON) . = ALIGN(4); _ebss = .; - } >ram AT >rom + } >ram /* * The .eh_frame section appears to be used for C++ exception handling. diff --git a/lib/stm32/f4/libopencm3_stm32f4.ld b/lib/stm32/f4/libopencm3_stm32f4.ld index 0624b96..cf7e9ec 100644 --- a/lib/stm32/f4/libopencm3_stm32f4.ld +++ b/lib/stm32/f4/libopencm3_stm32f4.ld @@ -30,8 +30,6 @@ ENTRY(reset_handler) /* Define sections. */ SECTIONS { - . = ORIGIN(rom); - .text : { *(.vectors) /* Vector table */ *(.text*) /* Program code */ @@ -48,6 +46,7 @@ SECTIONS __exidx_end = .; + . = ALIGN(4); _etext = .; .data : { -- cgit v1.2.3 From 74cd991e7e8972cf22933743c847b5ce2b165798 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Mon, 3 Sep 2012 19:49:47 +0200 Subject: Use a specific symbol for data source address in flash That way, data source address does not depend on any other unrelated change in linker script. This also fixes cases when .data input section is aligned on 8 bytes. The new version does not provide any address for the output section so that it is aligned to the strictest input section. The _data_loadaddr symbol will always take this alignment into account. --- lib/lm3s/libopencm3_lm3s.ld | 1 + lib/lm3s/vector.c | 5 +++-- lib/lpc13xx/libopencm3_lpc13xx.ld | 1 + lib/lpc17xx/libopencm3_lpc17xx.ld | 1 + lib/lpc17xx/vector.c | 7 ++++--- lib/lpc43xx/libopencm3_lpc43xx.ld | 1 + lib/lpc43xx/libopencm3_lpc43xx_rom_to_ram.ld | 1 + lib/lpc43xx/vector.c | 7 ++++--- lib/stm32/f1/libopencm3_stm32f1.ld | 5 +++-- lib/stm32/f1/vector.c | 6 +++--- lib/stm32/f2/libopencm3_stm32f2.ld | 5 +++-- lib/stm32/f2/vector.c | 4 ++-- lib/stm32/f4/libopencm3_stm32f4.ld | 1 + lib/stm32/f4/vector.c | 4 ++-- 14 files changed, 30 insertions(+), 19 deletions(-) diff --git a/lib/lm3s/libopencm3_lm3s.ld b/lib/lm3s/libopencm3_lm3s.ld index 00ede3d..d6de32b 100644 --- a/lib/lm3s/libopencm3_lm3s.ld +++ b/lib/lm3s/libopencm3_lm3s.ld @@ -45,6 +45,7 @@ SECTIONS . = ALIGN(4); _edata = .; } >ram AT >rom + _data_loadaddr = LOADADDR(.data); .bss : { *(.bss*) /* Read-write zero initialized data */ diff --git a/lib/lm3s/vector.c b/lib/lm3s/vector.c index 5968d76..3a1c4d1 100644 --- a/lib/lm3s/vector.c +++ b/lib/lm3s/vector.c @@ -20,7 +20,7 @@ #define WEAK __attribute__ ((weak)) /* Symbols exported by the linker script(s): */ -extern unsigned _etext, _data, _edata, _ebss, _stack; +extern unsigned _data_loadaddr, _data, _edata, _ebss, _stack; void main(void); void reset_handler(void); @@ -61,9 +61,10 @@ void (*const vector_table[]) (void) = { void reset_handler(void) { volatile unsigned *src, *dest; + __asm__("MSR msp, %0" : : "r"(&_stack)); - for (src = &_etext, dest = &_data; dest < &_edata; src++, dest++) + for (src = &_data_loadaddr, dest = &_data; dest < &_edata; src++, dest++) *dest = *src; while (dest < &_ebss) diff --git a/lib/lpc13xx/libopencm3_lpc13xx.ld b/lib/lpc13xx/libopencm3_lpc13xx.ld index a1892cd..3d683de 100644 --- a/lib/lpc13xx/libopencm3_lpc13xx.ld +++ b/lib/lpc13xx/libopencm3_lpc13xx.ld @@ -45,6 +45,7 @@ SECTIONS . = ALIGN(4); _edata = .; } >ram AT >rom + _data_loadaddr = LOADADDR(.data); .bss : { *(.bss*) /* Read-write zero initialized data */ diff --git a/lib/lpc17xx/libopencm3_lpc17xx.ld b/lib/lpc17xx/libopencm3_lpc17xx.ld index a1892cd..3d683de 100644 --- a/lib/lpc17xx/libopencm3_lpc17xx.ld +++ b/lib/lpc17xx/libopencm3_lpc17xx.ld @@ -45,6 +45,7 @@ SECTIONS . = ALIGN(4); _edata = .; } >ram AT >rom + _data_loadaddr = LOADADDR(.data); .bss : { *(.bss*) /* Read-write zero initialized data */ diff --git a/lib/lpc17xx/vector.c b/lib/lpc17xx/vector.c index 016db7a..518f562 100644 --- a/lib/lpc17xx/vector.c +++ b/lib/lpc17xx/vector.c @@ -19,8 +19,8 @@ #define WEAK __attribute__ ((weak)) -/* Symbols exported by the linker script(s). */ -extern unsigned _etext, _data, _edata, _ebss, _stack; +/* Symbols exported by the linker script(s): */ +extern unsigned _data_loadaddr, _data, _edata, _ebss, _stack; void main(void); void reset_handler(void); @@ -60,9 +60,10 @@ void (*const vector_table[]) (void) = { void reset_handler(void) { volatile unsigned *src, *dest; + __asm__("MSR msp, %0" : : "r"(&_stack)); - for (src = &_etext, dest = &_data; dest < &_edata; src++, dest++) + for (src = &_data_loadaddr, dest = &_data; dest < &_edata; src++, dest++) *dest = *src; while (dest < &_ebss) diff --git a/lib/lpc43xx/libopencm3_lpc43xx.ld b/lib/lpc43xx/libopencm3_lpc43xx.ld index 2fedf09..b7f1d14 100644 --- a/lib/lpc43xx/libopencm3_lpc43xx.ld +++ b/lib/lpc43xx/libopencm3_lpc43xx.ld @@ -60,6 +60,7 @@ SECTIONS . = ALIGN(4); _edata = .; } >ram AT >rom + _data_loadaddr = LOADADDR(.data); .bss : { *(.bss*) /* Read-write zero initialized data */ diff --git a/lib/lpc43xx/libopencm3_lpc43xx_rom_to_ram.ld b/lib/lpc43xx/libopencm3_lpc43xx_rom_to_ram.ld index e39f662..4037ddc 100644 --- a/lib/lpc43xx/libopencm3_lpc43xx_rom_to_ram.ld +++ b/lib/lpc43xx/libopencm3_lpc43xx_rom_to_ram.ld @@ -61,6 +61,7 @@ SECTIONS . = ALIGN(4); _edata = .; } >ram_data AT >rom + _data_loadaddr = LOADADDR(.data); .bss : { *(.bss*) /* Read-write zero initialized data */ diff --git a/lib/lpc43xx/vector.c b/lib/lpc43xx/vector.c index daef5a9..23008bc 100644 --- a/lib/lpc43xx/vector.c +++ b/lib/lpc43xx/vector.c @@ -20,8 +20,8 @@ #define WEAK __attribute__ ((weak)) -/* Symbols exported by the linker script(s). */ -extern unsigned _etext, _data, _edata, _ebss, _stack; +/* Symbols exported by the linker script(s): */ +extern unsigned _data_loadaddr, _data, _edata, _ebss, _stack; extern unsigned _etext_ram, _text_ram, _etext_rom; void main(void); @@ -165,6 +165,7 @@ void (*const vector_table[]) (void) = { void reset_handler(void) { volatile unsigned *src, *dest; + __asm__("MSR msp, %0" : : "r"(&_stack)); /* Copy the code from ROM to Real RAM (if enabled) */ @@ -185,7 +186,7 @@ void reset_handler(void) /* Continue Execution in RAM */ } - for (src = &_etext, dest = &_data; dest < &_edata; src++, dest++) + for (src = &_data_loadaddr, dest = &_data; dest < &_edata; src++, dest++) *dest = *src; while (dest < &_ebss) diff --git a/lib/stm32/f1/libopencm3_stm32f1.ld b/lib/stm32/f1/libopencm3_stm32f1.ld index f4f8e3b..c4a1bce 100644 --- a/lib/stm32/f1/libopencm3_stm32f1.ld +++ b/lib/stm32/f1/libopencm3_stm32f1.ld @@ -52,12 +52,13 @@ SECTIONS __exidx_end = .; } >rom - .data : AT (__exidx_end) { + .data : { _data = .; *(.data*) /* Read-write initialized data */ . = ALIGN(4); _edata = .; - } >ram + } >ram AT >rom + _data_loadaddr = LOADADDR(.data); .bss : { *(.bss*) /* Read-write zero initialized data */ diff --git a/lib/stm32/f1/vector.c b/lib/stm32/f1/vector.c index 119ce30..f496ae4 100644 --- a/lib/stm32/f1/vector.c +++ b/lib/stm32/f1/vector.c @@ -19,8 +19,8 @@ #define WEAK __attribute__ ((weak)) -/* Symbols exported by the linker script(s). */ -extern unsigned __exidx_end, _data, _edata, _ebss, _stack; +/* Symbols exported by the linker script(s): */ +extern unsigned _data_loadaddr, _data, _edata, _ebss, _stack; void main(void); void reset_handler(void); @@ -197,7 +197,7 @@ void reset_handler(void) __asm__("MSR msp, %0" : : "r"(&_stack)); - for (src = &__exidx_end, dest = &_data; dest < &_edata; src++, dest++) + for (src = &_data_loadaddr, dest = &_data; dest < &_edata; src++, dest++) *dest = *src; while (dest < &_ebss) diff --git a/lib/stm32/f2/libopencm3_stm32f2.ld b/lib/stm32/f2/libopencm3_stm32f2.ld index f4f8e3b..c4a1bce 100644 --- a/lib/stm32/f2/libopencm3_stm32f2.ld +++ b/lib/stm32/f2/libopencm3_stm32f2.ld @@ -52,12 +52,13 @@ SECTIONS __exidx_end = .; } >rom - .data : AT (__exidx_end) { + .data : { _data = .; *(.data*) /* Read-write initialized data */ . = ALIGN(4); _edata = .; - } >ram + } >ram AT >rom + _data_loadaddr = LOADADDR(.data); .bss : { *(.bss*) /* Read-write zero initialized data */ diff --git a/lib/stm32/f2/vector.c b/lib/stm32/f2/vector.c index 64d2426..3429bfb 100644 --- a/lib/stm32/f2/vector.c +++ b/lib/stm32/f2/vector.c @@ -21,7 +21,7 @@ #define WEAK __attribute__ ((weak)) /* Symbols exported by the linker script(s): */ -extern unsigned __exidx_end, _data, _edata, _ebss, _stack; +extern unsigned _data_loadaddr, _data, _edata, _ebss, _stack; void main(void); void reset_handler(void); @@ -224,7 +224,7 @@ void reset_handler(void) __asm__("MSR msp, %0" : : "r"(&_stack)); - for (src = &__exidx_end, dest = &_data; dest < &_edata; src++, dest++) + for (src = &_data_loadaddr, dest = &_data; dest < &_edata; src++, dest++) *dest = *src; while (dest < &_ebss) diff --git a/lib/stm32/f4/libopencm3_stm32f4.ld b/lib/stm32/f4/libopencm3_stm32f4.ld index cf7e9ec..25b0ace 100644 --- a/lib/stm32/f4/libopencm3_stm32f4.ld +++ b/lib/stm32/f4/libopencm3_stm32f4.ld @@ -55,6 +55,7 @@ SECTIONS . = ALIGN(4); _edata = .; } >ram AT >rom + _data_loadaddr = LOADADDR(.data); .bss : { *(.bss*) /* Read-write zero initialized data */ diff --git a/lib/stm32/f4/vector.c b/lib/stm32/f4/vector.c index 1c901da..3429bfb 100644 --- a/lib/stm32/f4/vector.c +++ b/lib/stm32/f4/vector.c @@ -21,7 +21,7 @@ #define WEAK __attribute__ ((weak)) /* Symbols exported by the linker script(s): */ -extern unsigned _etext, _data, _edata, _ebss, _stack; +extern unsigned _data_loadaddr, _data, _edata, _ebss, _stack; void main(void); void reset_handler(void); @@ -224,7 +224,7 @@ void reset_handler(void) __asm__("MSR msp, %0" : : "r"(&_stack)); - for (src = &_etext, dest = &_data; dest < &_edata; src++, dest++) + for (src = &_data_loadaddr, dest = &_data; dest < &_edata; src++, dest++) *dest = *src; while (dest < &_ebss) -- cgit v1.2.3 From 82ef2936a673f0c6cba86e02d80104f56e1de5a2 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Mon, 3 Sep 2012 19:51:40 +0200 Subject: Support exceptions on all targets --- lib/lm3s/libopencm3_lm3s.ld | 23 ++++++++++++++++------- lib/lpc13xx/libopencm3_lpc13xx.ld | 23 ++++++++++++++++------- lib/lpc17xx/libopencm3_lpc17xx.ld | 23 ++++++++++++++++------- lib/lpc43xx/libopencm3_lpc43xx.ld | 25 ++++++++++--------------- lib/lpc43xx/libopencm3_lpc43xx_rom_to_ram.ld | 26 ++++++++++---------------- lib/stm32/f1/libopencm3_stm32f1.ld | 4 +++- lib/stm32/f2/libopencm3_stm32f2.ld | 4 +++- lib/stm32/f4/libopencm3_stm32f4.ld | 26 ++++++++++++++++---------- 8 files changed, 90 insertions(+), 64 deletions(-) diff --git a/lib/lm3s/libopencm3_lm3s.ld b/lib/lm3s/libopencm3_lm3s.ld index d6de32b..ceb391a 100644 --- a/lib/lm3s/libopencm3_lm3s.ld +++ b/lib/lm3s/libopencm3_lm3s.ld @@ -36,9 +36,24 @@ SECTIONS . = ALIGN(4); *(.rodata*) /* Read-only data */ . = ALIGN(4); - _etext = .; } >rom + /* + * Another section used by C++ stuff, appears when using newlib with + * 64bit (long long) printf support + */ + .ARM.extab : { + *(.ARM.extab*) + } >rom + .ARM.exidx : { + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + } >rom + + . = ALIGN(4); + _etext = .; + .data : { _data = .; *(.data*) /* Read-write initialized data */ @@ -60,12 +75,6 @@ SECTIONS */ /DISCARD/ : { *(.eh_frame) } - /* - * Another section used by C++ stuff, appears when using newlib with - * 64bit (long long) printf support - discard it for now. - */ - /DISCARD/ : { *(.ARM.exidx) } - . = ALIGN(4); end = .; } diff --git a/lib/lpc13xx/libopencm3_lpc13xx.ld b/lib/lpc13xx/libopencm3_lpc13xx.ld index 3d683de..4e0f1df 100644 --- a/lib/lpc13xx/libopencm3_lpc13xx.ld +++ b/lib/lpc13xx/libopencm3_lpc13xx.ld @@ -36,9 +36,24 @@ SECTIONS . = ALIGN(4); *(.rodata*) /* Read-only data */ . = ALIGN(4); - _etext = .; } >rom + /* + * Another section used by C++ stuff, appears when using newlib with + * 64bit (long long) printf support + */ + .ARM.extab : { + *(.ARM.extab*) + } >rom + .ARM.exidx : { + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + } >rom + + . = ALIGN(4); + _etext = .; + .data : { _data = .; *(.data*) /* Read-write initialized data */ @@ -60,12 +75,6 @@ SECTIONS */ /DISCARD/ : { *(.eh_frame) } - /* - * Another section used by C++ stuff, appears when using newlib with - * 64bit (long long) printf support - discard it for now. - */ - /DISCARD/ : { *(.ARM.exidx) } - . = ALIGN(4); end = .; } diff --git a/lib/lpc17xx/libopencm3_lpc17xx.ld b/lib/lpc17xx/libopencm3_lpc17xx.ld index 3d683de..4e0f1df 100644 --- a/lib/lpc17xx/libopencm3_lpc17xx.ld +++ b/lib/lpc17xx/libopencm3_lpc17xx.ld @@ -36,9 +36,24 @@ SECTIONS . = ALIGN(4); *(.rodata*) /* Read-only data */ . = ALIGN(4); - _etext = .; } >rom + /* + * Another section used by C++ stuff, appears when using newlib with + * 64bit (long long) printf support + */ + .ARM.extab : { + *(.ARM.extab*) + } >rom + .ARM.exidx : { + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + } >rom + + . = ALIGN(4); + _etext = .; + .data : { _data = .; *(.data*) /* Read-write initialized data */ @@ -60,12 +75,6 @@ SECTIONS */ /DISCARD/ : { *(.eh_frame) } - /* - * Another section used by C++ stuff, appears when using newlib with - * 64bit (long long) printf support - discard it for now. - */ - /DISCARD/ : { *(.ARM.exidx) } - . = ALIGN(4); end = .; } diff --git a/lib/lpc43xx/libopencm3_lpc43xx.ld b/lib/lpc43xx/libopencm3_lpc43xx.ld index b7f1d14..9402a54 100644 --- a/lib/lpc43xx/libopencm3_lpc43xx.ld +++ b/lib/lpc43xx/libopencm3_lpc43xx.ld @@ -42,12 +42,18 @@ SECTIONS . = ALIGN(4); } >rom - /* exception index - required due to libgcc.a issuing /0 exceptions */ - __exidx_start = .; + /* + * Another section used by C++ stuff, appears when using newlib with + * 64bit (long long) printf support + */ + .ARM.extab : { + *(.ARM.extab*) + } >rom .ARM.exidx : { + __exidx_start = .; *(.ARM.exidx*) - } > rom - __exidx_end = .; + __exidx_end = .; + } >rom . = ALIGN(4); _etext = .; @@ -69,23 +75,12 @@ SECTIONS _ebss = .; } >ram - /* exception unwind data - required due to libgcc.a issuing /0 exceptions */ - .ARM.extab : { - *(.ARM.extab*) - } >ram - /* * The .eh_frame section appears to be used for C++ exception handling. * You may need to fix this if you're using C++. */ /DISCARD/ : { *(.eh_frame) } - /* - * Another section used by C++ stuff, appears when using newlib with - * 64bit (long long) printf support - discard it for now. - */ - /DISCARD/ : { *(.ARM.exidx) } - . = ALIGN(4); end = .; diff --git a/lib/lpc43xx/libopencm3_lpc43xx_rom_to_ram.ld b/lib/lpc43xx/libopencm3_lpc43xx_rom_to_ram.ld index 4037ddc..06f7708 100644 --- a/lib/lpc43xx/libopencm3_lpc43xx_rom_to_ram.ld +++ b/lib/lpc43xx/libopencm3_lpc43xx_rom_to_ram.ld @@ -43,12 +43,18 @@ SECTIONS . = ALIGN(4); } >rom - /* exception index - required due to libgcc.a issuing /0 exceptions */ - __exidx_start = .; + /* + * Another section used by C++ stuff, appears when using newlib with + * 64bit (long long) printf support + */ + .ARM.extab : { + *(.ARM.extab*) + } >rom .ARM.exidx : { + __exidx_start = .; *(.ARM.exidx*) - } > rom - __exidx_end = .; + __exidx_end = .; + } >rom . = ALIGN(4); _etext = .; @@ -70,24 +76,12 @@ SECTIONS _ebss = .; } >ram_data - /* exception unwind data - required due to libgcc.a issuing /0 exceptions */ - .ARM.extab : { - . = _ebss; - *(.ARM.extab*) - } >ram_data - /* * The .eh_frame section appears to be used for C++ exception handling. * You may need to fix this if you're using C++. */ /DISCARD/ : { *(.eh_frame) } - /* - * Another section used by C++ stuff, appears when using newlib with - * 64bit (long long) printf support - discard it for now. - */ - /DISCARD/ : { *(.ARM.exidx) } - . = ALIGN(4); end = .; diff --git a/lib/stm32/f1/libopencm3_stm32f1.ld b/lib/stm32/f1/libopencm3_stm32f1.ld index c4a1bce..9d165f6 100644 --- a/lib/stm32/f1/libopencm3_stm32f1.ld +++ b/lib/stm32/f1/libopencm3_stm32f1.ld @@ -36,7 +36,6 @@ SECTIONS . = ALIGN(4); *(.rodata*) /* Read-only data */ . = ALIGN(4); - _etext = .; } >rom /* @@ -52,6 +51,9 @@ SECTIONS __exidx_end = .; } >rom + . = ALIGN(4); + _etext = .; + .data : { _data = .; *(.data*) /* Read-write initialized data */ diff --git a/lib/stm32/f2/libopencm3_stm32f2.ld b/lib/stm32/f2/libopencm3_stm32f2.ld index c4a1bce..9d165f6 100644 --- a/lib/stm32/f2/libopencm3_stm32f2.ld +++ b/lib/stm32/f2/libopencm3_stm32f2.ld @@ -36,7 +36,6 @@ SECTIONS . = ALIGN(4); *(.rodata*) /* Read-only data */ . = ALIGN(4); - _etext = .; } >rom /* @@ -52,6 +51,9 @@ SECTIONS __exidx_end = .; } >rom + . = ALIGN(4); + _etext = .; + .data : { _data = .; *(.data*) /* Read-write initialized data */ diff --git a/lib/stm32/f4/libopencm3_stm32f4.ld b/lib/stm32/f4/libopencm3_stm32f4.ld index 25b0ace..9d165f6 100644 --- a/lib/stm32/f4/libopencm3_stm32f4.ld +++ b/lib/stm32/f4/libopencm3_stm32f4.ld @@ -38,13 +38,18 @@ SECTIONS . = ALIGN(4); } >rom - /* exception index - required due to libgcc.a issuing /0 exceptions */ - __exidx_start = .; + /* + * Another section used by C++ stuff, appears when using newlib with + * 64bit (long long) printf support + */ + .ARM.extab : { + *(.ARM.extab*) + } >rom .ARM.exidx : { - *(.ARM.exidx*) - } > rom - __exidx_end = .; - + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + } >rom . = ALIGN(4); _etext = .; @@ -64,10 +69,11 @@ SECTIONS _ebss = .; } >ram - /* exception unwind data - required due to libgcc.a issuing /0 exceptions */ - .ARM.extab : { - *(.ARM.extab*) - } >ram + /* + * The .eh_frame section appears to be used for C++ exception handling. + * You may need to fix this if you're using C++. + */ + /DISCARD/ : { *(.eh_frame) } . = ALIGN(4); end = .; -- cgit v1.2.3