Right. That was clear in the proposal itself. My point here was:
Assume that the executable is built with the STB_SECONDARY def
because it was not available in libc.a at link time. So far so
fine. Now if the executable is run on a machine where libc.a
provides the def, then the executable still uses the STB_SECONDARY
def because it has been built fully archive.
In other words, we have a situation where the executable uses
STB_SECONDARY def even if the libc.a on the machine provides
the def.
Of course, this is more of a limitation of archive executable
and not the proposal. The proposal best fits the case where
the executable is run on the machine where it is linked. Only
then the semantics of STB_SECONDARY is meaningful.
> > This proposal targets only a very specific case of libc.a not
> providing the
> > symbol on some version of OS. Why not make it more generic?
> >
> > Say:
> > ld 1.o 2.o lib1.a lib2.a libc.a
> >
> > Now, assume that lib1.a is from a different vendor than lib2.a.
> > The vendor of lib2.a decides to provide a STB_SECONDARY
> > foo to make the user avoid updating libc.a and without changing
> > the link order.
> >
> > What if the vendor of lib1.a also wants to the do the same. The
> > vendor wants to provide a STB_SECONDARY foo only if there is
> > none in any of the link objects.
>
> The first STB_SECONDARY foo will be used and linker will keep
> searching for STB_GLOBAL/STB_WEAK foo.
What I am suggesting is to pick the last STB_SECONDARY foo.
In the above example, when both lib1.a and lib2.a say
"I want my def to be the last one to be picked", lets pick
from the last. The above is just an extended case of the original:
ld 1.o lib1.a libc.a
where lib1.a expects the def to be picked from libc.a if
available.
In that way, we can define the "winner STB_SECONDARY" as the
last of all definitions available on the link line.
What is the drawback of this approach?
>
> > If we consider the generic case, the actual requirement then is
> > to have a mechanism to control the level of STB_WEAKness.
> >
> > How about defining STB_SECONDARY as a symbol of bind
> > type STB_WEAK but wins only if it is the last one in the link
> order?
>
> That is basically my proposal.
The proposal says to pick the first one if there multiple
STB_SECONDARY. I am suggesting to use the last one.
> > Unless we are trying to provide a generic solution (and not just
> target
> > libc.a), a new standard binding type may not be substantial.
> >
> > Also, the new standard type should change STB_NUM to 4.
> > #define STB_NUM 3 /* Number of defined types. */
>
> STB_NUM will be updated if STB_SECODARY is accepted.
STB_SECONDARY is a useful addition to ELF, but my only concern
is that we are spending a standard value in ELF bind types
for a very corner case of libc.a It would have been better
if we can make it more useful by extending it to dynamic linker
processing at runtime.
-Supra