Hi Jean-Marc!

Any chance you could try the patch from the previous email? It seems to do the
right thing. In the long run we probably want to move to a reentrant bison 
parser
and avoid playing with global state.

thank you
  holger

> On 16. Mar 2024, at 21:10, Holger Hans Peter Freyther <hol...@freyther.de> 
> wrote:
> 
> genbc is a special binary that is using two bison generated parsers and
> a single lexer. The lexer and parser exchange data through the yylval
> variable. Newer versions of the GNU linker detect the multiple
> definitions.
> 
> Avoid this by mapping yychar and yynerrs to private state and yylval to
> call a function to get the value.
> 
> Fixes:
> /usr/bin/ld: genbc-impl.o:(.bss+0xc): multiple definition of `yychar'; 
> genbc-decl.o:(.bss+0x4c): first defined here
> /usr/bin/ld: genbc-impl.o:(.bss+0x10): multiple definition of `yylval'; 
> genbc-decl.o:(.bss+0x50): first defined here
> /usr/bin/ld: genbc-impl.o:(.bss+0x18): multiple definition of `yynerrs'; 
> genbc-decl.o:(.bss+0x58): first defined here
> ---
> libgst/ChangeLog    | 6 ++++++
> libgst/genbc-decl.y | 3 +++
> libgst/genbc.c      | 6 ++++++
> libgst/genbc.h      | 1 +
> 4 files changed, 16 insertions(+)
> 
> diff --git a/libgst/ChangeLog b/libgst/ChangeLog
> index 9dece1d9..1ce4c68f 100644
> --- a/libgst/ChangeLog
> +++ b/libgst/ChangeLog
> @@ -1,3 +1,9 @@
> +2024-03-16  Holger Hans Peter Freyther  <hol...@freyther.de>
> +
> + * genbc-impl.y: Map yynerrs, yychar to local state. Map yylval to the 
> shared state.
> + * genbc.h: Add genbc_yylval to provide authorize
> + * genbc.c: Add genbc_yylval to work on single yylval.
> +
> 2023-10-29  Holger Hans Peter Freyther  <hol...@freyther.de>
> 
> * sysdep/common/files.c: Add NULL checks to _gst_file_is_readable,
> diff --git a/libgst/genbc-decl.y b/libgst/genbc-decl.y
> index 7c73941d..9d0df7b5 100644
> --- a/libgst/genbc-decl.y
> +++ b/libgst/genbc-decl.y
> @@ -56,6 +56,9 @@
> #include "genbc.h"
> #include "avltrees.h"
> 
> +#define yynerrs decl_yynerrs
> +#define yychar decl_yychar
> +#define yylval (*genbc_yylval())
> #define yyparse decl_yyparse
> #define yydebug decl_yydebug
> #define YYERROR_VERBOSE
> diff --git a/libgst/genbc.c b/libgst/genbc.c
> index cae5f6d3..e6a8042d 100644
> --- a/libgst/genbc.c
> +++ b/libgst/genbc.c
> @@ -54,6 +54,12 @@
> int errors = 0;
> const char *current_file;
> 
> +YYSTYPE*
> +genbc_yylval ()
> +{
> +  return &yylval;
> +}
> +
> void
> yyprint (FILE *file, int type, YYSTYPE yylval)
> {
> diff --git a/libgst/genbc.h b/libgst/genbc.h
> index 44501c8e..6eab493e 100644
> --- a/libgst/genbc.h
> +++ b/libgst/genbc.h
> @@ -78,6 +78,7 @@ extern int impl_yyparse ();
> extern int impl_yydebug;
> 
> /* genbc.c declarations */
> +extern YYSTYPE *genbc_yylval ();
> extern const char *current_file;
> extern void yyprint (FILE *file, int type, YYSTYPE yylval);
> extern void yyerror (const char *s);
> -- 
> 2.44.0
> 


Reply via email to