[PATCH v2 1/1] sandbox: redefine getc()

The sandbox is built with the SDL2 library with invokes the X11 library which in turn calls getc(). But getc() in glibc is defined as
int getc(FILE *)
This does not match our definition.
int getc(void)
The sandbox crashes when called with parameter -l.
Rename our library symbol to be called _u_boot_getc(). To keep the coding changes minimal use a define on the sandbox only.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de --- v2: apply changes only to the sandbox --- include/stdio.h | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/include/stdio.h b/include/stdio.h index aedf374452..43cba1dde5 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -4,6 +4,11 @@ #include <stdarg.h> #include <linux/compiler.h>
+/* The SDL library invokes getc() but this should not be our getc(). */ +#ifdef CONFIG_SANDBOX +#define getc _u_boot_getc +#endif + /* stdin */ int getc(void); int tstc(void); -- 2.28.0

On Tue, Sep 29, 2020 at 08:43:12PM +0200, Heinrich Schuchardt wrote:
The sandbox is built with the SDL2 library with invokes the X11 library which in turn calls getc(). But getc() in glibc is defined as
int getc(FILE *)
This does not match our definition.
int getc(void)
The sandbox crashes when called with parameter -l.
Rename our library symbol to be called _u_boot_getc(). To keep the coding changes minimal use a define on the sandbox only.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de
v2: apply changes only to the sandbox
Wolfgang, I was wondering could we not, given the few callers of 'getc' carefully change our internal usage / name to 'getchar', which is more POSIX-like and have our EXPORT_FUNC line be: EXPORT_FUNC(getc, int, getchar, void) and that might be the clean solution here?

Dear Tom,
In message 20200929185004.GO14816@bill-the-cat you wrote:
Wolfgang, I was wondering could we not, given the few callers of 'getc' carefully change our internal usage / name to 'getchar', which is more POSIX-like and have our EXPORT_FUNC line be: EXPORT_FUNC(getc, int, getchar, void)
I guess we could, indeed.
and that might be the clean solution here?
Probably.
I haven't tested this, though.
Best regards,
Wolfgang Denk
participants (3)
-
Heinrich Schuchardt
-
Tom Rini
-
Wolfgang Denk