From 4d190076076cf124abf573310db70f6946323a60 Mon Sep 17 00:00:00 2001 From: Maarten van der Schrieck Date: Fri, 12 Jan 2024 23:18:42 +0100 Subject: [PATCH] rp2_common/pico_standard_link: linker script fixes (#1539) The resulting elf binaries contained an unusual section that leads to an error when objcopy attempts to update a section (e.g. when using the picowota combined build mechanism). This seemed to be due to the order of sections, where two RAM-only sections were split by a RAM/FLASH section. By moving the RAM-only sections together, this issue disappeared. --- .../pico_standard_link/memmap_blocked_ram.ld | 12 ++++++------ .../pico_standard_link/memmap_copy_to_ram.ld | 12 ++++++------ src/rp2_common/pico_standard_link/memmap_default.ld | 12 ++++++------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/rp2_common/pico_standard_link/memmap_blocked_ram.ld b/src/rp2_common/pico_standard_link/memmap_blocked_ram.ld index e9142d29b..52384e1d6 100644 --- a/src/rp2_common/pico_standard_link/memmap_blocked_ram.ld +++ b/src/rp2_common/pico_standard_link/memmap_blocked_ram.ld @@ -117,10 +117,15 @@ SECTIONS __binary_info_end = .; . = ALIGN(4); - .ram_vector_table (NOLOAD): { + .ram_vector_table (NOLOAD): { *(.ram_vector_table) } > RAM + .uninitialized_data (NOLOAD): { + . = ALIGN(4); + *(.uninitialized_data*) + } > RAM + .data : { __data_start__ = .; *(vtable) @@ -173,11 +178,6 @@ SECTIONS /* __etext is (for backwards compatibility) the name of the .data init source pointer (...) */ __etext = LOADADDR(.data); - .uninitialized_data (NOLOAD): { - . = ALIGN(4); - *(.uninitialized_data*) - } > RAM - /* Start and end symbols must be word-aligned */ .scratch_x : { __scratch_x_start__ = .; diff --git a/src/rp2_common/pico_standard_link/memmap_copy_to_ram.ld b/src/rp2_common/pico_standard_link/memmap_copy_to_ram.ld index ea81ceced..1d7e514f5 100644 --- a/src/rp2_common/pico_standard_link/memmap_copy_to_ram.ld +++ b/src/rp2_common/pico_standard_link/memmap_copy_to_ram.ld @@ -96,10 +96,15 @@ SECTIONS . = ALIGN(4); /* Vector table goes first in RAM, to avoid large alignment hole */ - .ram_vector_table (NOLOAD): { + .ram_vector_table (NOLOAD): { *(.ram_vector_table) } > RAM + .uninitialized_data (NOLOAD): { + . = ALIGN(4); + *(.uninitialized_data*) + } > RAM + .text : { __ram_text_start__ = .; *(.init) @@ -175,11 +180,6 @@ SECTIONS /* __etext is (for backwards compatibility) the name of the .data init source pointer (...) */ __etext = LOADADDR(.data); - .uninitialized_data (NOLOAD): { - . = ALIGN(4); - *(.uninitialized_data*) - } > RAM - /* Start and end symbols must be word-aligned */ .scratch_x : { __scratch_x_start__ = .; diff --git a/src/rp2_common/pico_standard_link/memmap_default.ld b/src/rp2_common/pico_standard_link/memmap_default.ld index e85b32791..b4dadfc0c 100644 --- a/src/rp2_common/pico_standard_link/memmap_default.ld +++ b/src/rp2_common/pico_standard_link/memmap_default.ld @@ -117,10 +117,15 @@ SECTIONS __binary_info_end = .; . = ALIGN(4); - .ram_vector_table (NOLOAD): { + .ram_vector_table (NOLOAD): { *(.ram_vector_table) } > RAM + .uninitialized_data (NOLOAD): { + . = ALIGN(4); + *(.uninitialized_data*) + } > RAM + .data : { __data_start__ = .; *(vtable) @@ -173,11 +178,6 @@ SECTIONS /* __etext is (for backwards compatibility) the name of the .data init source pointer (...) */ __etext = LOADADDR(.data); - .uninitialized_data (NOLOAD): { - . = ALIGN(4); - *(.uninitialized_data*) - } > RAM - /* Start and end symbols must be word-aligned */ .scratch_x : { __scratch_x_start__ = .;