[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug ld/26551] A definition referenced by an unneeded (--as-needed) shar
From: |
hjl.tools at gmail dot com |
Subject: |
[Bug ld/26551] A definition referenced by an unneeded (--as-needed) shared object should be exported |
Date: |
Wed, 02 Sep 2020 12:00:26 +0000 |
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.
- [Bug ld/26551] A definition referenced by an unneeded (--as-needed) shared object should be exported, i at maskray dot me, 2020/09/01
- [Bug ld/26551] A definition referenced by an unneeded (--as-needed) shared object should be exported, i at maskray dot me, 2020/09/01
- [Bug ld/26551] A definition referenced by an unneeded (--as-needed) shared object should be exported, hjl.tools at gmail dot com, 2020/09/01
- [Bug ld/26551] A definition referenced by an unneeded (--as-needed) shared object should be exported, i at maskray dot me, 2020/09/02
- [Bug ld/26551] A definition referenced by an unneeded (--as-needed) shared object should be exported,
hjl.tools at gmail dot com <=
- [Bug ld/26551] A definition referenced by an unneeded (--as-needed) shared object should be exported, matz at suse dot de, 2020/09/02
- [Bug ld/26551] A definition referenced by an unneeded (--as-needed) shared object should be exported, i at maskray dot me, 2020/09/02
- [Bug ld/26551] A definition referenced by an unneeded (--as-needed) shared object should be exported, hjl.tools at gmail dot com, 2020/09/02