Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5439

SDK • Re: Intercepting printf() calls, redirecting to a ring_buffer, sending to a UART later

$
0
0
In src\rp2_common\pico_printf\printf.c, sprintf, vsnprintf, snprintf, and others are introduced like

Code:

int WRAPPER_FUNC(sprintf)(char *buffer, const char *format, ...) {
and WRAPPER_FUNC is

Code:

#define WRAPPER_FUNC(x) __wrap_ ## x
There's the linker command-line option:
--wrap symbol
Use a wrapper function for symbol. Any undefined reference to symbol will be resolved to __wrap_symbol. Any undefined reference to __real_symbol will be resolved to symbol. This can be used to provide a wrapper for a system function. The wrapper function should be called __wrap_symbol. If it wishes to call the system function, it should call __real_symbol.
Could you exploit that somehow?

Also, see src\rp2_common\pico_printf\include\pico\printf.h in the Pico SDK. There are various flags like LIB_PICO_PRINTF_PICO which are controlled by pico_set_printf_implementation(TARGET compiler) in CMake.

Statistics: Posted by carlk3 — Tue Mar 05, 2024 1:18 am



Viewing all articles
Browse latest Browse all 5439

Trending Articles