Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [Bug] modules zsh/tcp, zsh/zftp unloadable, probably affecting most modern Linuxes



> On 06/06/2023 07:42 Jun T <takimoto-j@xxxxxxxxxxxxxxxxx> wrote:
> I think the problem is '-Wl,-z,now'. man ld(1) says:
> 
>    now When generating an executable or shared library, mark it to
>        tell the dynamic linker to resolve all symbols when the program
>        is started, or when the shared library is loaded by dlopen,
>        instead of deferring function call resolution to the point when
>        the function is first called.
> 
> It seems this option has the higher precedence than the option
> '-z lazy' in the same command line, or the RTLD_LAZY for dlopen().
> 
> On Fedora-38:
> % readelf --dynamic /usr/lib64/zsh/5.9/zsh/zftp.so | grep FLAG
>  0x000000000000001e (FLAGS)              BIND_NOW
>  0x000000006ffffffb (FLAGS_1)            Flags: NOW
> 
> I think this flag in zftp.so is the result of '-z now'
> 
> On Debian-11, /usr/lib/x86_64-linux-gnu/zsh/5.8/zsh/zftp.so has the
> same flag. I guess Debian binary package is also built with '-z now'.
> 
> The zftp.so built by myself does not have this flag.
> 
> Why '-z now' is used when building binary packages? For security?

I think this is just so that failure to find symbols at all will
show up quickly in the build rather than at run time, which would
be a real pain.

One solution might be to build first with -z now to confirm that it
does link, and then -z lazy to make it more useful when installed.

pws




Messages sorted by: Reverse Date, Date, Thread, Author