diff --git a/pkg/mpaland-printf/Makefile.include b/pkg/mpaland-printf/Makefile.include index 6bb85ab56a..2a0c8c5bc0 100644 --- a/pkg/mpaland-printf/Makefile.include +++ b/pkg/mpaland-printf/Makefile.include @@ -14,6 +14,7 @@ LINKFLAGS += -Wl,-wrap=putchar LINKFLAGS += -Wl,-wrap=putc LINKFLAGS += -Wl,-wrap=fputc LINKFLAGS += -Wl,-wrap=puts +LINKFLAGS += -Wl,-wrap=fputs # By wrapping the newlib only `_printf_common` symbol to the undefined # `__wrap__printf_common` symbol, linking will fail if any reference to diff --git a/pkg/mpaland-printf/patches/0004-Wrapper-targets-Add-endpoints-for-Wl-wrap.patch b/pkg/mpaland-printf/patches/0004-Wrapper-targets-Add-endpoints-for-Wl-wrap.patch index 6c53e70bce..2490ff42a8 100644 --- a/pkg/mpaland-printf/patches/0004-Wrapper-targets-Add-endpoints-for-Wl-wrap.patch +++ b/pkg/mpaland-printf/patches/0004-Wrapper-targets-Add-endpoints-for-Wl-wrap.patch @@ -1,15 +1,15 @@ -From a01af4cb4991f6d5f0320f03d1f1d918df07caec Mon Sep 17 00:00:00 2001 +From b1ee169d8cfd6e37817ad267736aa1f92f1a2076 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Sat, 11 May 2024 17:51:38 +0200 -Subject: [PATCH] Wrapper targets: Add endpoints for -Wl,wrap=... +Subject: [PATCH 4/6] Wrapper targets: Add endpoints for -Wl,wrap=... This adds aliases needed to wrap printf() and friends. --- - printf.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 99 insertions(+) + printf.c | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 108 insertions(+) diff --git a/printf.c b/printf.c -index edf41d1..e00c3e5 100644 +index edf41d1..ed7f72b 100644 --- a/printf.c +++ b/printf.c @@ -32,6 +32,9 @@ @@ -22,7 +22,7 @@ index edf41d1..e00c3e5 100644 #include "printf.h" #include "stdio_base.h" -@@ -920,3 +923,99 @@ static void _putchar(char character) +@@ -920,3 +923,108 @@ static void _putchar(char character) { stdio_write(&character, sizeof(character)); } @@ -54,19 +54,19 @@ index edf41d1..e00c3e5 100644 + _putchar((char)c); + return 1; +} -+ + -+int __wrap_putc(int c, FILE *stream) -+{ -+ (void)stream; -+ _putchar((char)c); -+ return 1; -+} -+ -+ -+__attribute__((alias("__wrap_putc"))) -+int __wrap_fputc(int c, FILE *stream); -+ ++ ++int __wrap_putc(int c, FILE *stream) ++{ ++ (void)stream; ++ _putchar((char)c); ++ return 1; ++} ++ ++ ++__attribute__((alias("__wrap_putc"))) ++int __wrap_fputc(int c, FILE *stream); ++ + +int __wrap_puts(const char *s) +{ @@ -74,6 +74,15 @@ index edf41d1..e00c3e5 100644 + stdio_write(s, len); + stdio_write("\n", 1); + return len + 1; ++} ++ ++ ++int __wrap_fputs(const char *s, FILE *stream) ++{ ++ (void)stream; ++ size_t len = strlen(s); ++ write_all(s, len); ++ return len; +} + + @@ -104,13 +113,13 @@ index edf41d1..e00c3e5 100644 + } + + return vprintf_(format, va); -+} ++} + -+ -+int __wrap_vsprintf(char* buffer, const char* format, va_list va) -+{ -+ return __wrap_vsnprintf(buffer, (size_t)-1, format, va); -+} ++ ++int __wrap_vsprintf(char* buffer, const char* format, va_list va) ++{ ++ return __wrap_vsnprintf(buffer, (size_t)-1, format, va); ++} + + +int __wrap_dprintf(int fd, const char *format, ...)