[PATCH] LoongArch: ld: Fix bug not generate plt when link a x.so

Xi Ruoyao xry111@xry111.site
Sat Aug 20 11:19:07 GMT 2022


On Sat, 2022-08-20 at 18:56 +0800, WANG Xuerui wrote:
> Hi,
> 
> On 8/20/22 17:08, liuzhensong wrote:
> >    bfd/
> >      elfnn-loongarch.c
> 
> Could use some explanation as to why this is a problem, with a minimal
> reproduction example or otherwise how did you encounter this. Because 
> the patch title is not of much help.

I guess this comes from the -mcmodel=medium option (under review at GCC
side), which generates a pair of pcalau12i/jirl instructions for local
function call.  But pcalau12i/jirl is not enough for a global call
(calling a function in DSO from the main image will obviously exceed the
2GiB range) so a PLT entry is needed.

> Also a testsuite addition would probably be nice.

I agree.

/* snip */

> >           if (h != NULL)
> >             {
> > +             /* For pcalau12i + jirl.  */
> > +               {

Why do we ever need this `{`, ...

> > +                 h->needs_plt = 1;
> > +                 if (h->plt.refcount < 0)
> > +                   h->plt.refcount = 0;
> > +                 h->plt.refcount++;
> > +               }

and this `}`?

> > +
> >               h->non_got_ref = 1;
> >               h->pointer_equality_needed = 1;
> >             }

-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University


More information about the Binutils mailing list