On Wed, Aug 5, 2020 at 7:36 AM Waldek Kozaczuk <[email protected]> wrote:

> This looks like a great solution. I was about to commit but I realized
> that alias symbols like  __res_init become global symbols vs weak in
> loader.elf. Does it have any practical consequences to how they are handled
> by OSv dynamic linker?
>

I never understood why we used weak aliases in OSv and just used the
"weak_alias" macro we had like a parrot. Pekka maybe you remember?

Now you asked me to think about it, my conclusion is that: 1. we never
needed to use weak aliases, and 2. We used them wrong :-)

The correct usage for weak aliases is for *statically-linked libraries*.
You usually define the *normal *name as a weak symbol and the
"__" name as a regular symbol (opposite of what we did in OSv many times!).
Here is a random example from nm of glibc.a:

0000000000000000 T _IO_fputs
0000000000000000 W fputs

This couple of symbols allows the user to *redefine *fputs() in his code as
some sort of wrapper that can also call the original version
under its alternative name, _IO_fputs. If fputs() was not a weak symbol,
and the user code redefined it, the same code could not
call _IO_fputs because the linker while bringing _IO_fputs would also bring
in fputs (the static linker brings in entire objects from
the ".a" archive) and cause a duplicate symbol. The weak symbol doesn't
cause this duplicate symbol problem.

This is not relevant to OSv, which is dynamically linked to OSv, and each
symbol can be overridden by the application regardless
of any other symbols. We never should have used weak symbols in OSv, they
never made any difference.

Nadav.

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/CANEVyjsY16w8rVtKDHYNE64rXT3-Bm7p4iwcmbVo%3D8LJgoabgw%40mail.gmail.com.

Reply via email to