https://sourceware.org/bugzilla/show_bug.cgi?id=26551
--- Comment #8 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Fangrui Song from comment #7)
>
> >a.c <<e cat
> #include <dlfcn.h>
> int foo() { return 42; }
> int main() {
> void *h = dlopen("./b.so", RTLD_LAZY);
> int (*bar)(void) = dlsym(h, "bar");
> return bar();
> }
> e
> >b.c <<e cat
> int foo();
> int bar() { return foo(); }
> e
>
> cc -fuse-ld=bfd -shared -fPIC b.c -ldl -o b.so
> cc -fuse-ld=bfd -pie -fPIE a.c -Wl,--push-state -Wl,--as-needed ./b.so
> -Wl,--pop-state -ldl
>
> ./a.out => symbol lookup error: ./b.so: undefined symbol: foo
>
> -fuse-ld=gold or -fuse-ld=lld is good.
If it is the only use case, why not use
'--dynamic-list=DYNAMIC-LIST-FILE'
Specify the name of a dynamic list file to the linker. This is
typically used when creating shared libraries to specify a list of
global symbols whose references shouldn't be bound to the
definition within the shared library, or creating dynamically
linked executables to specify a list of symbols which should be
added to the symbol table in the executable. This option is only
meaningful on ELF platforms which support shared libraries.
--
You are receiving this mail because:
You are on the CC list for the bug.