Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/rp2040/boot_stage2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ function(pico_define_boot_stage2 NAME SOURCES)
if (PICO_C_COMPILER_IS_CLANG)
target_link_options(${NAME} PRIVATE "-nostdlib")
elseif (PICO_C_COMPILER_IS_GNU)
target_link_options(${NAME} PRIVATE "--specs=nosys.specs")
if (PICO_CLIB STREQUAL "newlib")
target_link_options(${NAME} PRIVATE "--specs=nosys.specs")
endif()
target_link_options(${NAME} PRIVATE "-nostartfiles")
endif ()

Expand Down
4 changes: 3 additions & 1 deletion src/rp2350/boot_stage2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ function(pico_define_boot_stage2 NAME SOURCES)
if (PICO_C_COMPILER_IS_CLANG)
target_link_options(${NAME} PRIVATE "-nostdlib")
elseif (PICO_C_COMPILER_IS_GNU)
target_link_options(${NAME} PRIVATE "--specs=nosys.specs")
if (PICO_CLIB STREQUAL "newlib")
target_link_options(${NAME} PRIVATE "--specs=nosys.specs")
endif()
target_link_options(${NAME} PRIVATE "-nostartfiles")
endif ()

Expand Down
8 changes: 7 additions & 1 deletion src/rp2_common/pico_clib_interface/picolibc_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ static FILE __stdio = FDEV_SETUP_STREAM(picolibc_putc,
picolibc_flush,
_FDEV_SETUP_RW);

#ifdef __GNUCLIKE_PRAGMA_DIAGNOSTIC
#pragma GCC diagnostic ignored "-Wpragmas"
#pragma GCC diagnostic ignored "-Wunknown-warning-option"
#pragma GCC diagnostic ignored "-Wredundant-decls"
#endif

FILE *const stdin = &__stdio; __strong_reference(stdin, stdout); __strong_reference(stdin, stderr);

void __weak __assert_func(const char *file, int line, const char *func, const char *failedexpr) {
Expand Down Expand Up @@ -151,4 +157,4 @@ PICO_RUNTIME_INIT_FUNC_PER_CORE(runtime_init_pre_core_tls_setup, PICO_RUNTIME_IN
// "ldr r0, =__tls_base\n"
// "bx lr\n"
// );
//}
//}
4 changes: 4 additions & 0 deletions src/rp2_common/pico_crt0/rp2040/memmap_blocked_ram.ld
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
__exidx_end
__etext
__data_start__
__bothinit_array_start
__preinit_array_start
__preinit_array_end
__init_array_start
__init_array_end
__bothinit_array_end
__fini_array_start
__fini_array_end
__data_end__
Expand Down Expand Up @@ -87,6 +89,7 @@ SECTIONS

. = ALIGN(4);
/* preinit data */
PROVIDE_HIDDEN (__bothinit_array_start = .);
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP(*(SORT(.preinit_array.*)))
KEEP(*(.preinit_array))
Expand All @@ -98,6 +101,7 @@ SECTIONS
KEEP(*(SORT(.init_array.*)))
KEEP(*(.init_array))
PROVIDE_HIDDEN (__init_array_end = .);
PROVIDE_HIDDEN (__bothinit_array_end = .);

. = ALIGN(4);
/* finit data */
Expand Down
4 changes: 4 additions & 0 deletions src/rp2_common/pico_crt0/rp2040/memmap_copy_to_ram.ld
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
__exidx_end
__etext
__data_start__
__bothinit_array_start
__preinit_array_start
__preinit_array_end
__init_array_start
__init_array_end
__bothinit_array_end
__fini_array_start
__fini_array_end
__data_end__
Expand Down Expand Up @@ -155,6 +157,7 @@ SECTIONS

. = ALIGN(4);
/* preinit data */
PROVIDE_HIDDEN (__bothinit_array_start = .);
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP(*(SORT(.preinit_array.*)))
KEEP(*(.preinit_array))
Expand All @@ -166,6 +169,7 @@ SECTIONS
KEEP(*(SORT(.init_array.*)))
KEEP(*(.init_array))
PROVIDE_HIDDEN (__init_array_end = .);
PROVIDE_HIDDEN (__bothinit_array_end = .);

. = ALIGN(4);
/* finit data */
Expand Down
4 changes: 4 additions & 0 deletions src/rp2_common/pico_crt0/rp2040/memmap_default.ld
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
__exidx_end
__etext
__data_start__
__bothinit_array_start
__preinit_array_start
__preinit_array_end
__init_array_start
__init_array_end
__bothinit_array_end
__fini_array_start
__fini_array_end
__data_end__
Expand Down Expand Up @@ -87,6 +89,7 @@ SECTIONS

. = ALIGN(4);
/* preinit data */
PROVIDE_HIDDEN (__bothinit_array_start = .);
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP(*(SORT(.preinit_array.*)))
KEEP(*(.preinit_array))
Expand All @@ -98,6 +101,7 @@ SECTIONS
KEEP(*(SORT(.init_array.*)))
KEEP(*(.init_array))
PROVIDE_HIDDEN (__init_array_end = .);
PROVIDE_HIDDEN (__bothinit_array_end = .);

. = ALIGN(4);
/* finit data */
Expand Down
4 changes: 4 additions & 0 deletions src/rp2_common/pico_crt0/rp2040/memmap_no_flash.ld
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
__exidx_end
__etext
__data_start__
__bothinit_array_start
__preinit_array_start
__preinit_array_end
__init_array_start
__init_array_end
__bothinit_array_end
__fini_array_start
__fini_array_end
__data_end__
Expand Down Expand Up @@ -118,6 +120,7 @@ SECTIONS

. = ALIGN(4);
/* preinit data */
PROVIDE_HIDDEN (__bothinit_array_start = .);
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP(*(SORT(.preinit_array.*)))
KEEP(*(.preinit_array))
Expand All @@ -129,6 +132,7 @@ SECTIONS
KEEP(*(SORT(.init_array.*)))
KEEP(*(.init_array))
PROVIDE_HIDDEN (__init_array_end = .);
PROVIDE_HIDDEN (__bothinit_array_end = .);

. = ALIGN(4);
/* finit data */
Expand Down
4 changes: 4 additions & 0 deletions src/rp2_common/pico_crt0/rp2350/memmap_copy_to_ram.ld
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
__exidx_end
__etext
__data_start__
__bothinit_array_start
__preinit_array_start
__preinit_array_end
__init_array_start
__init_array_end
__bothinit_array_end
__fini_array_start
__fini_array_end
__data_end__
Expand Down Expand Up @@ -173,6 +175,7 @@ SECTIONS

. = ALIGN(4);
/* preinit data */
PROVIDE_HIDDEN (__bothinit_array_start = .);
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP(*(SORT(.preinit_array.*)))
KEEP(*(.preinit_array))
Expand All @@ -184,6 +187,7 @@ SECTIONS
KEEP(*(SORT(.init_array.*)))
KEEP(*(.init_array))
PROVIDE_HIDDEN (__init_array_end = .);
PROVIDE_HIDDEN (__bothinit_array_end = .);

. = ALIGN(4);
/* finit data */
Expand Down
4 changes: 4 additions & 0 deletions src/rp2_common/pico_crt0/rp2350/memmap_default.ld
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
__exidx_end
__etext
__data_start__
__bothinit_array_start
__preinit_array_start
__preinit_array_end
__init_array_start
__init_array_end
__bothinit_array_end
__fini_array_start
__fini_array_end
__data_end__
Expand Down Expand Up @@ -77,6 +79,7 @@ SECTIONS

. = ALIGN(4);
/* preinit data */
PROVIDE_HIDDEN (__bothinit_array_start = .);
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP(*(SORT(.preinit_array.*)))
KEEP(*(.preinit_array))
Expand All @@ -88,6 +91,7 @@ SECTIONS
KEEP(*(SORT(.init_array.*)))
KEEP(*(.init_array))
PROVIDE_HIDDEN (__init_array_end = .);
PROVIDE_HIDDEN (__bothinit_array_end = .);

. = ALIGN(4);
/* finit data */
Expand Down
4 changes: 4 additions & 0 deletions src/rp2_common/pico_crt0/rp2350/memmap_no_flash.ld
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
__exidx_end
__etext
__data_start__
__bothinit_array_start
__preinit_array_start
__preinit_array_end
__init_array_start
__init_array_end
__bothinit_array_end
__fini_array_start
__fini_array_end
__data_end__
Expand Down Expand Up @@ -121,6 +123,7 @@ SECTIONS

. = ALIGN(4);
/* preinit data */
PROVIDE_HIDDEN (__bothinit_array_start = .);
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP(*(SORT(.preinit_array.*)))
KEEP(*(.preinit_array))
Expand All @@ -132,6 +135,7 @@ SECTIONS
KEEP(*(SORT(.init_array.*)))
KEEP(*(.init_array))
PROVIDE_HIDDEN (__init_array_end = .);
PROVIDE_HIDDEN (__bothinit_array_end = .);

. = ALIGN(4);
/* finit data */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

#if defined __GNUC__
#include <sys/cdefs.h>
#ifdef __PICOLIBC__
#define __printflike(a,b) __picolibc_format(printf,a,b)
#endif
// note LLVM defines __GNUC__
#ifdef __clang__
#define PICO_C_COMPILER_IS_CLANG 1
Expand Down
4 changes: 3 additions & 1 deletion src/rp2_common/pico_runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ endforeach()

# todo is this correct/needed?
if (PICO_C_COMPILER_IS_GNU)
target_link_options(pico_runtime INTERFACE "--specs=nosys.specs")
if (PICO_CLIB STREQUAL "newlib")
target_link_options(${NAME} PRIVATE "--specs=nosys.specs")
endif()
elseif (PICO_C_COMPILER_IS_CLANG)
# target_link_options(pico_runtime INTERFACE "-nostdlib")
endif()
Expand Down
23 changes: 21 additions & 2 deletions src/rp2_common/pico_standard_link/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ if (NOT TARGET pico_standard_link)
set(PICO_FLASH_SIZE_BYTES_STRING "${PICO_FLASH_SIZE_BYTES}")
configure_file(${CMAKE_CURRENT_LIST_DIR}/pico_flash_region.template.ld ${CMAKE_BINARY_DIR}/pico_flash_region.ld)
# add include path for linker scripts
target_link_options(pico_standard_link INTERFACE "LINKER:-L${CMAKE_BINARY_DIR}")
target_link_options(pico_standard_link INTERFACE "-L${CMAKE_BINARY_DIR}")

# LINKER script will be PICO_TARGET_LINKER_SCRIPT if set on target, or ${CMAKE_CURRENT_LIST_DIR}/memmap_foo.ld
# if PICO_TARGET_BINARY_TYPE is set to foo on the target, otherwise ${CMAKE_CURRENT_LIST_DIR}/memmap_${PICO_DEFAULT_BINARY_TYPE).ld
set(_LINKER_SCRIPT_EXPRESSION "$<IF:$<BOOL:$<TARGET_PROPERTY:PICO_TARGET_LINKER_SCRIPT>>,$<TARGET_PROPERTY:PICO_TARGET_LINKER_SCRIPT>,${PICO_LINKER_SCRIPT_PATH}/memmap_$<IF:$<STREQUAL:$<TARGET_PROPERTY:PICO_TARGET_BINARY_TYPE>,>,${PICO_DEFAULT_BINARY_TYPE},$<TARGET_PROPERTY:PICO_TARGET_BINARY_TYPE>>.ld>")
target_link_options(pico_standard_link INTERFACE
"LINKER:--script=${_LINKER_SCRIPT_EXPRESSION}"
"-T${_LINKER_SCRIPT_EXPRESSION}"
)
pico_add_link_depend(pico_standard_link ${_LINKER_SCRIPT_EXPRESSION})
unset(_LINKER_SCRIPT_EXPRESSION)
Expand Down Expand Up @@ -191,4 +191,23 @@ if (NOT TARGET pico_standard_link)
endif()
endif()
endif()

# Convert pico-sdk printf variant selection into picolibc version
# when using pico_printf_compiler

if (PICO_CLIB STREQUAL "picolibc")
if (RUNTIME_INCLUDE_PRINTF_MINIMAL)
target_link_options(pico_standard_link INTERFACE
$<$<STREQUAL:$<TARGET_PROPERTY:PICO_TARGET_PRINTF_IMPL>,pico_printf_compiler>:--printf=m>)
elseif (RUNTIME_INCLUDE_PRINTF_FLOAT)
# this is the default
elseif (RUNTIME_INCLUDE_PRINTF_LONG_LONG)
target_link_options(pico_standard_link INTERFACE
$<$<STREQUAL:$<TARGET_PROPERTY:PICO_TARGET_PRINTF_IMPL>,pico_printf_compiler>:--printf=l>)
else()
target_link_options(pico_standard_link INTERFACE
$<$<STREQUAL:$<TARGET_PROPERTY:PICO_TARGET_PRINTF_IMPL>,pico_printf_compiler>:--printf=i>)
endif()
endif()

endif()
Loading