Re: [PATCH 1/1] sandbox: replace putchar(ch) by fputc(ch, stdout)
On Sat, 20 Nov 2021 at 05:28, Heinrich Schuchardt wrote: > > When compiled with -Og for better debugability u-boot ends up in a stack > overflow using > > gcc (Ubuntu 11.2.0-7ubuntu2) 11.2.0 > GNU Binutils for Ubuntu 2.37 > > putchar(ch) is defined as a macro which ends up calling U-Boot's putc() > implementation instead of the glibc one, which calls os_putc() ... > > Let's use fputc(ch, stdout) instead as fputc() does not exist in U-Boot. > > Signed-off-by: Heinrich Schuchardt > --- > arch/sandbox/cpu/os.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Reviewed-by: Simon Glass Applied to u-boot-dm/next, thanks!
Re: [PATCH 1/1] sandbox: replace putchar(ch) by fputc(ch, stdout)
On Sat, 20 Nov 2021 at 05:28, Heinrich Schuchardt wrote: > > When compiled with -Og for better debugability u-boot ends up in a stack > overflow using > > gcc (Ubuntu 11.2.0-7ubuntu2) 11.2.0 > GNU Binutils for Ubuntu 2.37 > > putchar(ch) is defined as a macro which ends up calling U-Boot's putc() > implementation instead of the glibc one, which calls os_putc() ... > > Let's use fputc(ch, stdout) instead as fputc() does not exist in U-Boot. > > Signed-off-by: Heinrich Schuchardt > --- > arch/sandbox/cpu/os.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Reviewed-by: Simon Glass
[PATCH 1/1] sandbox: replace putchar(ch) by fputc(ch, stdout)
When compiled with -Og for better debugability u-boot ends up in a stack overflow using gcc (Ubuntu 11.2.0-7ubuntu2) 11.2.0 GNU Binutils for Ubuntu 2.37 putchar(ch) is defined as a macro which ends up calling U-Boot's putc() implementation instead of the glibc one, which calls os_putc() ... Let's use fputc(ch, stdout) instead as fputc() does not exist in U-Boot. Signed-off-by: Heinrich Schuchardt --- arch/sandbox/cpu/os.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index b72dafca2b..25a04a650a 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -628,7 +628,7 @@ int os_get_filesize(const char *fname, loff_t *size) void os_putc(int ch) { - putchar(ch); + fputc(ch, stdout); } void os_puts(const char *str) -- 2.32.0