public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] LoongArch: ld: Fix bug not generate plt when link a x.so
@ 2022-08-20  9:08 liuzhensong
  2022-08-20 10:56 ` WANG Xuerui
  0 siblings, 1 reply; 3+ messages in thread
From: liuzhensong @ 2022-08-20  9:08 UTC (permalink / raw)
  To: binutils
  Cc: i.swmail, xry111, maskray, caiyinyu, chenglulu, mengqinggang,
	xuchenghua, liuzhensong

  bfd/
    elfnn-loongarch.c
---
 bfd/elfnn-loongarch.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c
index 8d0f66ea7c1..a9ca20ee49b 100644
--- a/bfd/elfnn-loongarch.c
+++ b/bfd/elfnn-loongarch.c
@@ -746,6 +746,14 @@ loongarch_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
 	case R_LARCH_PCALA_HI20:
 	  if (h != NULL)
 	    {
+	      /* For pcalau12i + jirl.  */
+		{
+		  h->needs_plt = 1;
+		  if (h->plt.refcount < 0)
+		    h->plt.refcount = 0;
+		  h->plt.refcount++;
+		}
+
 	      h->non_got_ref = 1;
 	      h->pointer_equality_needed = 1;
 	    }
-- 
2.31.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] LoongArch: ld: Fix bug not generate plt when link a x.so
  2022-08-20  9:08 [PATCH] LoongArch: ld: Fix bug not generate plt when link a x.so liuzhensong
@ 2022-08-20 10:56 ` WANG Xuerui
  2022-08-20 11:19   ` Xi Ruoyao
  0 siblings, 1 reply; 3+ messages in thread
From: WANG Xuerui @ 2022-08-20 10:56 UTC (permalink / raw)
  To: liuzhensong, binutils
  Cc: i.swmail, xry111, maskray, caiyinyu, chenglulu, mengqinggang, xuchenghua

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.

Also a testsuite addition would probably be nice.

> ---
>   bfd/elfnn-loongarch.c | 8 ++++++++
>   1 file changed, 8 insertions(+)
>
> diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c
> index 8d0f66ea7c1..a9ca20ee49b 100644
> --- a/bfd/elfnn-loongarch.c
> +++ b/bfd/elfnn-loongarch.c
> @@ -746,6 +746,14 @@ loongarch_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
>   	case R_LARCH_PCALA_HI20:
>   	  if (h != NULL)
>   	    {
> +	      /* For pcalau12i + jirl.  */
> +		{
> +		  h->needs_plt = 1;
> +		  if (h->plt.refcount < 0)
> +		    h->plt.refcount = 0;
> +		  h->plt.refcount++;
> +		}
> +
>   	      h->non_got_ref = 1;
>   	      h->pointer_equality_needed = 1;
>   	    }

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] LoongArch: ld: Fix bug not generate plt when link a x.so
  2022-08-20 10:56 ` WANG Xuerui
@ 2022-08-20 11:19   ` Xi Ruoyao
  0 siblings, 0 replies; 3+ messages in thread
From: Xi Ruoyao @ 2022-08-20 11:19 UTC (permalink / raw)
  To: WANG Xuerui, liuzhensong, binutils
  Cc: maskray, caiyinyu, chenglulu, mengqinggang, xuchenghua

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-08-20 11:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-20  9:08 [PATCH] LoongArch: ld: Fix bug not generate plt when link a x.so liuzhensong
2022-08-20 10:56 ` WANG Xuerui
2022-08-20 11:19   ` Xi Ruoyao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).