[PATCH] LTO: Restore the wrapper symbol check before reference

H.J. Lu hjl.tools@gmail.com
Fri Aug 2 17:20:25 GMT 2024


On Fri, Aug 2, 2024 at 4:41 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Fri, Aug 2, 2024 at 4:30 AM H.J. Lu <hjl.tools@gmail.com> wrote:
> >
> > On Fri, Aug 2, 2024 at 4:25 AM H.J. Lu <hjl.tools@gmail.com> wrote:
> > >
> > > Call unwrap_hash_lookup to check for the wrapper symbol before the wrapped
> > > reference.  The testcase is hard to create since for simple tests, GCC 14
> > > always outputs the wrapped reference first.
> > >
> > >         PR ld/31956
> > >         * plugin.c (get_symbols): Restore the wrapper symbol check before
> > >         the wrapped reference.
> > >
> > > Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
> > > ---
> > >  ld/plugin.c | 14 ++++++++++++--
> > >  1 file changed, 12 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/ld/plugin.c b/ld/plugin.c
> > > index 03ee9880d10..51c4765cc5b 100644
> > > --- a/ld/plugin.c
> > > +++ b/ld/plugin.c
> > > @@ -778,8 +778,18 @@ get_symbols (const void *handle, int nsyms, struct ld_plugin_symbol *syms,
> > >         {
> > >           blhe = h;
> > >           /* Check if a symbol is a wrapper symbol.  */
> > > -         if (blhe && blhe->wrapper_symbol)
> > > -           wrap_status = wrapper;
> > > +         if (blhe)
> > > +           {
> > > +             if (blhe->wrapper_symbol)
> > > +               wrap_status = wrapper;
> > > +             else if (link_info.wrap_hash != NULL)
> > > +               {
> > > +                 struct bfd_link_hash_entry *unwrap
> > > +                   = unwrap_hash_lookup (&link_info, (bfd *) abfd, blhe);
> > > +                 if (unwrap != NULL && unwrap != h)
> > > +                   wrap_status = wrapper;
> >
> > This patch works for pcp,  but may not be the best.
>
> I sent v2 with the updated commit log.   I will add a testcase later.
>

I sent v3 with a testcase.


-- 
H.J.


More information about the Binutils mailing list