On Sat, Nov 25, 2023 at 08:53:48AM +0100, Emanuele Torre wrote:
> Now I can see that compat.o is actually being used to create
> lib/sh/libsh.a, and that libsh.a contains the legal_ symbols
> 
> [...]
> 
> But the bash executable still does not contain the legal_ symbols:
> 
>     $ grep -abo legal_identifier ./bash || echo nope
>     nope
> 
>     $ ./bash -c 'enable -f {examples/loadables/,}mktemp; mktemp -v foo'
>     ./bash: symbol lookup error: examples/loadables/mktemp: undefined symbol: 
> legal_identifier

gcc is not including the legal_ symbols defined in lib/sh/compat.o from
libsh.a into bash because they are not being used and libsh.a is a
library file and not an object file.

If lib/sh/compat.o is linked directly with bash, the legal_ symbols are
actually included; e.g.:

    $ git diff Makefile.in
    diff --git a/Makefile.in b/Makefile.in
    index a257fa8d..96179a62 100644
    --- a/Makefile.in
    +++ b/Makefile.in
    @@ -500,6 +500,7 @@ OBJECTS      = shell.o eval.o y.tab.o general.o 
make_cmd.o print_cmd.o $(GLOBO) \
               trap.o input.o unwind_prot.o pathexp.o sig.o test.o version.o \
               alias.o $(ARRAY_O) arrayfunc.o assoc.o braces.o bracecomp.o 
bashhist.o \
               bashline.o $(SIGLIST_O) list.o stringlib.o locale.o findcmd.o 
redir.o \
    +          lib/sh/compat.o \
               pcomplete.o pcomplib.o syntax.o xmalloc.o $(SIGNAMES_O)
     
     # Where the source code of the shell builtins resides.

And they can be used by old loadable builtin:

     $ ./bash -c 'enable -f {examples/loadables/,}mktemp; mktemp -v foo'
     /tmp/shtmp.vq2zXK

o/
 emanuele6

Reply via email to