help with dl module and clang

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

help with dl module and clang

Daniel Braniss-2
Hi,
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.

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 …
BTW, when linking the main program with cc I get
        /usr/bin/ld: warning: cannot find entry symbol xport-dynamic; defaulting to 0000000000402140


thanks,
        danny
PS: I’m running FreeBSD 11.2

_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: help with dl module and clang

Dimitry Andric-4
On 3 Nov 2018, at 15:51, Daniel Braniss <[hidden email]> wrote:
>
> 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.
>
> 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 …
> BTW, when linking the main program with cc I get
> /usr/bin/ld: warning: cannot find entry symbol xport-dynamic; defaulting to 0000000000402140

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.

I think this will also help with the exporting of the symbols of your
main program.

-Dimitry


signature.asc (230 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: help with dl module and clang

Daniel Braniss-2


> On 3 Nov 2018, at 17:47, Dimitry Andric <[hidden email]> wrote:
>
> On 3 Nov 2018, at 15:51, Daniel Braniss <[hidden email]> wrote:
>>
>> 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.
>>
>> 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 …
>> BTW, when linking the main program with cc I get
>> /usr/bin/ld: warning: cannot find entry symbol xport-dynamic; defaulting to 0000000000402140
>
> 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.
>

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 :-))!!!!!

thanks!!!!!!

and now have to try profiling (gprof) which started this mess,

thanks again!!

danny


> I think this will also help with the exporting of the symbols of your
> main program.
>
> -Dimitry
>

_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: help with dl module and clang

Daniel Braniss-2


> On 3 Nov 2018, at 17:58, Daniel Braniss <[hidden email]> wrote:
>
>
>
>> On 3 Nov 2018, at 17:47, Dimitry Andric <[hidden email]> wrote:
>>
>> On 3 Nov 2018, at 15:51, Daniel Braniss <[hidden email]> wrote:
>>>
>>> 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.
>>>
>>> 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 …
>>> BTW, when linking the main program with cc I get
>>> /usr/bin/ld: warning: cannot find entry symbol xport-dynamic; defaulting to 0000000000402140
>>
>> 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.
>>
>
> 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 :-))!!!!!
>
> thanks!!!!!!
>
> and now have to try profiling (gprof) which started this mess,
>
> thanks again!!
>
> danny
>
>
>> I think this will also help with the exporting of the symbols of your
>> main program.
>>
>> -Dimitry
>>
>
ok, new problem, it also happens with gcc:

when compiling the main program with flag -pg (gprof)
dlopen fails with dlerror: Service unavailable

what magic is needed now?

danny

> _______________________________________________
> [hidden email] mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "[hidden email]"

_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: help with dl module and clang

Dimitry Andric-4
On 3 Nov 2018, at 17:11, Daniel Braniss <[hidden email]> wrote:
...
> ok, new problem, it also happens with gcc:
>
> when compiling the main program with flag -pg (gprof)
> dlopen fails with dlerror: Service unavailable
>
> what magic is needed now?

Usually, this occurs when you attempt to dlopen from a statically linked
executable.  Is this executable statically linked?

-Dimitry


signature.asc (230 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: help with dl module and clang

Konstantin Belousov
In reply to this post by Daniel Braniss-2
On Sat, Nov 03, 2018 at 06:11:19PM +0200, Daniel Braniss wrote:

>
>
> > On 3 Nov 2018, at 17:58, Daniel Braniss <[hidden email]> wrote:
> >
> >
> >
> >> On 3 Nov 2018, at 17:47, Dimitry Andric <[hidden email]> wrote:
> >>
> >> On 3 Nov 2018, at 15:51, Daniel Braniss <[hidden email]> wrote:
> >>>
> >>> 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.
> >>>
> >>> 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 …
> >>> BTW, when linking the main program with cc I get
> >>> /usr/bin/ld: warning: cannot find entry symbol xport-dynamic; defaulting to 0000000000402140
> >>
> >> 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.
> >>
> >
> > 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 :-))!!!!!
> >
> > thanks!!!!!!
> >
> > and now have to try profiling (gprof) which started this mess,
> >
> > thanks again!!
> >
> > danny
> >
> >
> >> I think this will also help with the exporting of the symbols of your
> >> main program.
> >>
> >> -Dimitry
> >>
> >
> ok, new problem, it also happens with gcc:
>
> 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.

>
> what magic is needed now?
>
> danny
>
> > _______________________________________________
> > [hidden email] mailing list
> > https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> > To unsubscribe, send any mail to "[hidden email]"
>
> _______________________________________________
> [hidden email] mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "[hidden email]"
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: help with dl module and clang

Daniel Braniss-2


> On 3 Nov 2018, at 18:35, Konstantin Belousov <[hidden email]> wrote:
>
> On Sat, Nov 03, 2018 at 06:11:19PM +0200, Daniel Braniss wrote:
>>
>>
>>> On 3 Nov 2018, at 17:58, Daniel Braniss <[hidden email]> wrote:
>>>
>>>
>>>
>>>> On 3 Nov 2018, at 17:47, Dimitry Andric <[hidden email]> wrote:
>>>>
>>>> On 3 Nov 2018, at 15:51, Daniel Braniss <[hidden email]> wrote:
>>>>>
>>>>> 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.
>>>>>
>>>>> 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 …
>>>>> BTW, when linking the main program with cc I get
>>>>> /usr/bin/ld: warning: cannot find entry symbol xport-dynamic; defaulting to 0000000000402140
>>>>
>>>> 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.
>>>>
>>>
>>> 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 :-))!!!!!
>>>
>>> thanks!!!!!!
>>>
>>> and now have to try profiling (gprof) which started this mess,
>>>
>>> thanks again!!
>>>
>>> danny
>>>
>>>
>>>> I think this will also help with the exporting of the symbols of your
>>>> main program.
>>>>
>>>> -Dimitry
>>>>
>>>
>> ok, new problem, it also happens with gcc:
>>
>> 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’s NOT statically linked:
l
e-kots-b# ldd /vol/src/libexec/idng/idngd/idngd
/vol/src/libexec/idng/idngd/idngd:
       libpq.so.5 => /usr/local/lib/libpq.so.5 (0x800932000)
       libcrypto.so.8 => /lib/libcrypto.so.8 (0x800c00000)
       libldap-2.4.so.2 => /usr/local/lib/libldap-2.4.so.2 (0x801070000)
       libthr.so.3 => /lib/libthr.so.3 (0x8012b7000)
       libintl.so.8 => /usr/local/lib/libintl.so.8 (0x8014df000)
       libssl.so.8 => /usr/lib/libssl.so.8 (0x8016ea000)
       libc.so.7 => /lib/libc.so.7 (0x80195d000)
       liblber-2.4.so.2 => /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


>
>>
>> what magic is needed now?
>>
>> danny
>>
>>> _______________________________________________
>>> [hidden email] <mailto:[hidden email]> mailing list
>>> https://lists.freebsd.org/mailman/listinfo/freebsd-hackers <https://lists.freebsd.org/mailman/listinfo/freebsd-hackers>
>>> To unsubscribe, send any mail to "[hidden email] <mailto:[hidden email]>"
>>
>> _______________________________________________
>> [hidden email] <mailto:[hidden email]> mailing list
>> https://lists.freebsd.org/mailman/listinfo/freebsd-hackers <https://lists.freebsd.org/mailman/listinfo/freebsd-hackers>
>> To unsubscribe, send any mail to "[hidden email] <mailto:[hidden email]>"

_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: help with dl module and clang

Konstantin Belousov
On Sat, Nov 03, 2018 at 07:31:33PM +0200, Daniel Braniss wrote:

>
>
> > On 3 Nov 2018, at 18:35, Konstantin Belousov <[hidden email]> wrote:
> >
> > On Sat, Nov 03, 2018 at 06:11:19PM +0200, Daniel Braniss wrote:
> >>
> >>
> >>> On 3 Nov 2018, at 17:58, Daniel Braniss <[hidden email]> wrote:
> >>>
> >>>
> >>>
> >>>> On 3 Nov 2018, at 17:47, Dimitry Andric <[hidden email]> wrote:
> >>>>
> >>>> On 3 Nov 2018, at 15:51, Daniel Braniss <[hidden email]> wrote:
> >>>>>
> >>>>> 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.
> >>>>>
> >>>>> 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 …
> >>>>> BTW, when linking the main program with cc I get
> >>>>> /usr/bin/ld: warning: cannot find entry symbol xport-dynamic; defaulting to 0000000000402140
> >>>>
> >>>> 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.
> >>>>
> >>>
> >>> 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 :-))!!!!!
> >>>
> >>> thanks!!!!!!
> >>>
> >>> and now have to try profiling (gprof) which started this mess,
> >>>
> >>> thanks again!!
> >>>
> >>> danny
> >>>
> >>>
> >>>> I think this will also help with the exporting of the symbols of your
> >>>> main program.
> >>>>
> >>>> -Dimitry
> >>>>
> >>>
> >> ok, new problem, it also happens with gcc:
> >>
> >> 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’s NOT statically linked:
> l
> e-kots-b# ldd /vol/src/libexec/idng/idngd/idngd
> /vol/src/libexec/idng/idngd/idngd:
>        libpq.so.5 => /usr/local/lib/libpq.so.5 (0x800932000)
>        libcrypto.so.8 => /lib/libcrypto.so.8 (0x800c00000)
>        libldap-2.4.so.2 => /usr/local/lib/libldap-2.4.so.2 (0x801070000)
>        libthr.so.3 => /lib/libthr.so.3 (0x8012b7000)
>        libintl.so.8 => /usr/local/lib/libintl.so.8 (0x8014df000)
>        libssl.so.8 => /usr/lib/libssl.so.8 (0x8016ea000)
>        libc.so.7 => /lib/libc.so.7 (0x80195d000)
>        liblber-2.4.so.2 => /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

I suppose that dlopen(3) is called from the text of the idngd binary ?
Put the readelf -a idngd output somewhere.
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: help with dl module and clang

Daniel Braniss-2


> On 4 Nov 2018, at 19:22, Konstantin Belousov <[hidden email]> wrote:
>
> On Sat, Nov 03, 2018 at 07:31:33PM +0200, Daniel Braniss wrote:
>>
>>
>>> On 3 Nov 2018, at 18:35, Konstantin Belousov <[hidden email]> wrote:
>>>
>>> On Sat, Nov 03, 2018 at 06:11:19PM +0200, Daniel Braniss wrote:
>>>>
>>>>
>>>>> On 3 Nov 2018, at 17:58, Daniel Braniss <[hidden email]> wrote:
>>>>>
>>>>>
>>>>>
>>>>>> On 3 Nov 2018, at 17:47, Dimitry Andric <[hidden email]> wrote:
>>>>>>
>>>>>> On 3 Nov 2018, at 15:51, Daniel Braniss <[hidden email]> wrote:
>>>>>>>
>>>>>>> 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.
>>>>>>>
>>>>>>> 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 …
>>>>>>> BTW, when linking the main program with cc I get
>>>>>>> /usr/bin/ld: warning: cannot find entry symbol xport-dynamic; defaulting to 0000000000402140
>>>>>>
>>>>>> 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.
>>>>>>
>>>>>
>>>>> 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 :-))!!!!!
>>>>>
>>>>> thanks!!!!!!
>>>>>
>>>>> and now have to try profiling (gprof) which started this mess,
>>>>>
>>>>> thanks again!!
>>>>>
>>>>> danny
>>>>>
>>>>>
>>>>>> I think this will also help with the exporting of the symbols of your
>>>>>> main program.
>>>>>>
>>>>>> -Dimitry
>>>>>>
>>>>>
>>>> ok, new problem, it also happens with gcc:
>>>>
>>>> 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’s NOT statically linked:
>> l
>> e-kots-b# ldd /vol/src/libexec/idng/idngd/idngd
>> /vol/src/libexec/idng/idngd/idngd:
>>       libpq.so.5 => /usr/local/lib/libpq.so.5 (0x800932000)
>>       libcrypto.so.8 => /lib/libcrypto.so.8 (0x800c00000)
>>       libldap-2.4.so.2 => /usr/local/lib/libldap-2.4.so.2 (0x801070000)
>>       libthr.so.3 => /lib/libthr.so.3 (0x8012b7000)
>>       libintl.so.8 => /usr/local/lib/libintl.so.8 (0x8014df000)
>>       libssl.so.8 => /usr/lib/libssl.so.8 (0x8016ea000)
>>       libc.so.7 => /lib/libc.so.7 (0x80195d000)
>>       liblber-2.4.so.2 => /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
>
> I suppose that dlopen(3) is called from the text of the idngd binary ?
correct

> Put the readelf -a idngd output somewhere.
        www.cs.huji.ac.il/~danny/idngd.elf.out <http://www.cs.huji.ac.il/~danny/idngd.elf.out>



_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: help with dl module and clang

Joerg Sonnenberger-2
In reply to this post by Dimitry Andric-4
On Sat, Nov 03, 2018 at 04:47:37PM +0100, Dimitry Andric wrote:

> On 3 Nov 2018, at 15:51, Daniel Braniss <[hidden email]> wrote:
> >
> > 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.
> >
> > 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 …
> > BTW, when linking the main program with cc I get
> > /usr/bin/ld: warning: cannot find entry symbol xport-dynamic; defaulting to 0000000000402140
>
> 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.

Or cc -rdynamic.

Joerg
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[hidden email]"