Date: Sat, 3 Nov 2018 19:31:33 +0200 From: Daniel Braniss <danny@cs.huji.ac.il> To: Konstantin Belousov <kostikbel@gmail.com> Cc: Dimitry Andric <dim@FreeBSD.org>, freebsd-hackers@FreeBSD.org Subject: Re: help with dl module and clang Message-ID: <FA5207CF-3584-4D4E-A21F-AF76A0207729@cs.huji.ac.il> In-Reply-To: <20181103163508.GS5335@kib.kiev.ua> References: <4B8101F4-9A89-4486-8DF3-93DC799EF6D4@cs.huji.ac.il> <E3B4CDF3-2DE9-4785-963C-9158105C263E@FreeBSD.org> <2E58B6A3-B3E4-4266-9B40-5F3D64433460@cs.huji.ac.il> <08A14290-0A6E-4002-892E-D4254EB23076@cs.huji.ac.il> <20181103163508.GS5335@kib.kiev.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
> On 3 Nov 2018, at 18:35, Konstantin Belousov <kostikbel@gmail.com> = wrote: >=20 > On Sat, Nov 03, 2018 at 06:11:19PM +0200, Daniel Braniss wrote: >>=20 >>=20 >>> On 3 Nov 2018, at 17:58, Daniel Braniss <danny@cs.huji.ac.il> wrote: >>>=20 >>>=20 >>>=20 >>>> On 3 Nov 2018, at 17:47, Dimitry Andric <dim@FreeBSD.org> wrote: >>>>=20 >>>> On 3 Nov 2018, at 15:51, Daniel Braniss <danny@cs.huji.ac.il> = wrote: >>>>>=20 >>>>> I have a program that loads some modules via dlopen(), these = modules call some routines >>>>> which are in the main program, this works when using gcc, but with = cc it does not. >>>>>=20 >>>>> when compiling the main program I use -export-dynamic, and the = modules link fine when compiled with >>>>> gcc, but when compiling with clang/cc i get dlerror: ...Undefined = symbol =E2=80=A6 >>>>> BTW, when linking the main program with cc I get >>>>> /usr/bin/ld: warning: cannot find entry symbol xport-dynamic; = defaulting to 0000000000402140 >>>>=20 >>>> Instead of using -export-dynamic (which is a linker flag) as a flag = to >>>> cc, try using -Wl,-export-dynamic instead. Now, the linker = interprets >>>> this as the -e flag, which is something totally different. >>>>=20 >>>=20 >>> i had tried that before but i had -WI (upper case i) but re-reading = the manual >>> it should be-Wl (lower case l as in lima :-))!!!!! >>>=20 >>> thanks!!!!!! >>>=20 >>> and now have to try profiling (gprof) which started this mess, >>>=20 >>> thanks again!! >>>=20 >>> danny >>>=20 >>>=20 >>>> I think this will also help with the exporting of the symbols of = your >>>> main program. >>>>=20 >>>> -Dimitry >>>>=20 >>>=20 >> ok, new problem, it also happens with gcc: >>=20 >> when compiling the main program with flag -pg (gprof) >> dlopen fails with dlerror: Service unavailable > This means that your binary is linked statically. > dlopen(3) is not supported for static linking, ld-elf.so.1 is required > for dynamic loading to work. as far as I can tell, it=E2=80=99s NOT statically linked: l e-kots-b# ldd /vol/src/libexec/idng/idngd/idngd=20 /vol/src/libexec/idng/idngd/idngd: libpq.so.5 =3D> /usr/local/lib/libpq.so.5 (0x800932000) libcrypto.so.8 =3D> /lib/libcrypto.so.8 (0x800c00000) libldap-2.4.so.2 =3D> /usr/local/lib/libldap-2.4.so.2 = (0x801070000) libthr.so.3 =3D> /lib/libthr.so.3 (0x8012b7000) libintl.so.8 =3D> /usr/local/lib/libintl.so.8 (0x8014df000) libssl.so.8 =3D> /usr/lib/libssl.so.8 (0x8016ea000) libc.so.7 =3D> /lib/libc.so.7 (0x80195d000) liblber-2.4.so.2 =3D> /usr/local/lib/liblber-2.4.so.2 = (0x801d18000) e-kots-b# file !$ file /vol/src/libexec/idng/idngd/idngd /vol/src/libexec/idng/idngd/idngd: ELF 64-bit LSB executable, x86-64, = version 1 (FreeBSD), dynamically linked, interpreter = /libexec/ld-elf.so.1, for FreeBSD 11.2 (1102501 <tel:1102501>), = FreeBSD-style, not stripped >=20 >>=20 >> what magic is needed now? >>=20 >> danny >>=20 >>> _______________________________________________ >>> freebsd-hackers@freebsd.org <mailto:freebsd-hackers@freebsd.org> = mailing list >>> https://lists.freebsd.org/mailman/listinfo/freebsd-hackers = <https://lists.freebsd.org/mailman/listinfo/freebsd-hackers> >>> To unsubscribe, send any mail to = "freebsd-hackers-unsubscribe@freebsd.org = <mailto:freebsd-hackers-unsubscribe@freebsd.org>" >>=20 >> _______________________________________________ >> freebsd-hackers@freebsd.org <mailto:freebsd-hackers@freebsd.org> = mailing list >> https://lists.freebsd.org/mailman/listinfo/freebsd-hackers = <https://lists.freebsd.org/mailman/listinfo/freebsd-hackers> >> To unsubscribe, send any mail to = "freebsd-hackers-unsubscribe@freebsd.org = <mailto:freebsd-hackers-unsubscribe@freebsd.org>"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?FA5207CF-3584-4D4E-A21F-AF76A0207729>