> -----Original Message-----
> From: Basile Starynkevitch <bas...@starynkevitch.net>
> Sent: Thursday, June 19, 2025 11:51
> To: Bob Dubner <rdub...@cobolworx.com>
> Cc: gcc@gcc.gnu.org
> Subject: GCC harm in ARM
> 
> HEllo,
> 
> 
> Bob Dubner wrote on gcc@
> >
> > Thus, the statement
> >
> >     CALL "foo"
> >
> > might be the equivalent, implemented in C, of
> >
> >     extern <type> foo(...); //External reference
> >     foo();
> >
> > or
> >
> >     static <type> foo(...); // Forward reference to a static
> > function
> >     foo();
> >
> > At the point of the CALL, we don't know which it's going to be.
> >
> > This is further complicated by COBOL being able to do something that C
> can't:
> >
> >     CALL call_me
> >
> > If C could do it, it would look like this:
> >
> >     char call_me[] = "foo";
> >     call_me();      // I told you C can't do it.
> >
> 
> 
> If you restrict the GCC compiler and the compiled program to run on a
> Linux (or
> POSIX) operating system, the dlsym(3) function is doing that (on global
> functions only): fetching a function pointer from the string name of that
> global
> function.
> https://man7.org/linux/man-pages/man3/dlsym.3.html
> https://man7.org/linux/man-pages/man3/dlopen.3.html
> 
> (you might consider generating unique C identifiers with some random
> generator)
> 
> Of course, dlsym(3) is computationally costly, you may want to cache the
> result.

Thank you.  I am using dlopen/dlsym to handle cases where the called function's 
name is a variable.  And I am cacheing the dlsym results.

One point I was attempting to make is that for COBOL, the capability is in the 
language specification.  For C/C++ the capability is not part of the language.

> 
> And Cobol GCC experts (I am not one) could of course consider either
> generating
> code with libgccjit (it is now inside GCC) or perhaps use GNU lightning to
> generate machine code.
> https://www.gnu.org/software/lightning/
> 
> Experimentally dlopen can be used many thousands of times (and with enough
> RAM
> perhaps hundred thousands of times). See
> https://github.com/bstarynk/misc-basile/blob/master/manydl.c
> 
> 
> Regards
> --
> Basile STARYNKEVITCH                            <bas...@starynkevitch.net>
> 8 rue de la Faïencerie
> http://starynkevitch.net/Basile/
> 92340 Bourg-la-Reine                         https://github.com/bstarynk
> France
> https://github.com/RefPerSys/RefPerSys

Reply via email to