tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: dlopen fails from static binary
In article <20160418074257.GU13361%homeworld.NetBSD.org@localhost>,
Emmanuel Dreyfus <manu%netbsd.org@localhost> wrote:
>On Mon, Apr 18, 2016 at 09:29:23AM +0200, Martin Husemann wrote:
>> > Is dlopen really supposed ot fail when called from
>> > static binary? In that case errno should be set, but to what value?
>> > Or perhaps we could support dlopen from static binary?
>>
>> We should fail to link in this case. Where does the dlopen stub come
>> from?
>
>It seems to be from libc:
>
>$ nm /usr/lib/libc.a|grep dlopen
>00000000 T ___dlopen
>00000000 W __dlopen
>00000000 W dlopen
> U __dlopen
>
>src/lib/libc/dlfcn/dlfcn_elf.c says:
>/*
> * For ELF, the dynamic linker directly resolves references to its
> * services to functions inside the dynamic linker itself. These
> * weak-symbol stubs are necessary so that "ld" won't complain about
> * undefined symbols. The stubs are executed only when the program is
> * linked statically, or when a given service isn't implemented in the
> * dynamic linker. They must return an error if called, and they must
> * be weak symbols so that the dynamic linker can override them.
> */
>
>static char dlfcn_error[] = "Service unavailable";
>
>/*ARGSUSED*/
>void *
>dlopen(const char *name, int mode)
>{
>
> return NULL;
>}
>
>
>That suggests we just need to set errno there. To what value? ENOEXEC?
EOPNOTSUPP?
christos
Home |
Main Index |
Thread Index |
Old Index