mirror of
https://github.com/raspberrypi/pico-sdk.git
synced 2025-03-14 04:18:33 +00:00
Work around issue with unreferenced sections marked allocated in the asm being discarded by GNU linker (#1391)
This commit is contained in:
parent
affbb31a8c
commit
c34d3d5602
@ -523,6 +523,18 @@ __force_inline static uint get_core_num(void) {
|
||||
|
||||
#else // __ASSEMBLER__
|
||||
|
||||
#if defined __GNUC__
|
||||
// note LLVM defines __GNUC__
|
||||
#ifdef __clang__
|
||||
#define PICO_ASSEMBLER_IS_CLANG 1
|
||||
#else
|
||||
#define PICO_ASSEMBLER_IS_GNU 1
|
||||
#endif
|
||||
#elif defined __ICCARM__
|
||||
#else
|
||||
#error Unsupported toolchain
|
||||
#endif
|
||||
|
||||
#define WRAPPER_FUNC_NAME(x) __wrap_##x
|
||||
#define SECTION_NAME(x) .text.##x
|
||||
#define RAM_SECTION_NAME(x) .time_critical.##x
|
||||
|
@ -324,13 +324,29 @@ hold_non_core0_in_bootrom:
|
||||
// ----------------------------------------------------------------------------
|
||||
// Stack/heap dummies to set size
|
||||
|
||||
.section .stack, "a"
|
||||
// Prior to SDK 1.5.1 these were `.section .stack` without the `, "a"`... Clang linker gives a warning about this,
|
||||
// however setting it explicitly to `, "a"` makes GCC *now* discard the section unless it is also KEEP. This
|
||||
// seems like very surprising behavior!
|
||||
//
|
||||
// Strictly the most correct thing to do (as .stack and .heap are unreferenced) is to mark them as "a", and also KEEP, which
|
||||
// works correctly for both GCC and Clang, however doing so may break anyone who already has custom linker scripts without
|
||||
// the KEEP. Therefore we will only add the "a" on Clang, but will also use KEEP to our own linker scripts.
|
||||
|
||||
.macro spacer_section name
|
||||
#if PICO_ASSEMBLER_IS_CLANG
|
||||
.section \name, "a"
|
||||
#else
|
||||
.section \name
|
||||
#endif
|
||||
.endm
|
||||
|
||||
spacer_section .stack
|
||||
// align to allow for memory protection (although this alignment is pretty much ignored by linker script)
|
||||
.align 5
|
||||
.p2align 5
|
||||
.equ StackSize, PICO_STACK_SIZE
|
||||
.space StackSize
|
||||
|
||||
.section .heap, "a"
|
||||
.align 2
|
||||
spacer_section .heap
|
||||
.p2align 2
|
||||
.equ HeapSize, PICO_HEAP_SIZE
|
||||
.space HeapSize
|
||||
|
@ -208,7 +208,7 @@ SECTIONS
|
||||
{
|
||||
__end__ = .;
|
||||
end = __end__;
|
||||
*(.heap*)
|
||||
KEEP(*(.heap*))
|
||||
__HeapLimit = .;
|
||||
} > RAM
|
||||
|
||||
@ -227,7 +227,7 @@ SECTIONS
|
||||
} > SCRATCH_X
|
||||
.stack_dummy (NOLOAD):
|
||||
{
|
||||
*(.stack*)
|
||||
KEEP(*(.stack*))
|
||||
} > SCRATCH_Y
|
||||
|
||||
.flash_end : {
|
||||
|
@ -210,7 +210,7 @@ SECTIONS
|
||||
{
|
||||
__end__ = .;
|
||||
end = __end__;
|
||||
*(.heap*)
|
||||
KEEP(*(.heap*))
|
||||
__HeapLimit = .;
|
||||
} > RAM
|
||||
|
||||
@ -229,7 +229,7 @@ SECTIONS
|
||||
} > SCRATCH_X
|
||||
.stack_dummy (NOLOAD):
|
||||
{
|
||||
*(.stack*)
|
||||
KEEP(*(.stack*))
|
||||
} > SCRATCH_Y
|
||||
|
||||
.flash_end : {
|
||||
|
@ -208,7 +208,7 @@ SECTIONS
|
||||
{
|
||||
__end__ = .;
|
||||
end = __end__;
|
||||
*(.heap*)
|
||||
KEEP(*(.heap*))
|
||||
__HeapLimit = .;
|
||||
} > RAM
|
||||
|
||||
@ -227,7 +227,7 @@ SECTIONS
|
||||
} > SCRATCH_X
|
||||
.stack_dummy (NOLOAD):
|
||||
{
|
||||
*(.stack*)
|
||||
KEEP(*(.stack*))
|
||||
} > SCRATCH_Y
|
||||
|
||||
.flash_end : {
|
||||
|
@ -178,7 +178,7 @@ SECTIONS
|
||||
{
|
||||
__end__ = .;
|
||||
end = __end__;
|
||||
*(.heap*)
|
||||
KEEP(*(.heap*))
|
||||
__HeapLimit = .;
|
||||
} > RAM
|
||||
|
||||
@ -197,7 +197,7 @@ SECTIONS
|
||||
} > SCRATCH_X
|
||||
.stack_dummy (NOLOAD):
|
||||
{
|
||||
*(.stack*)
|
||||
KEEP(*(.stack*))
|
||||
} > SCRATCH_Y
|
||||
|
||||
/* stack limit is poorly named, but historically is maximum heap ptr */
|
||||
|
Loading…
x
Reference in New Issue
Block a user