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

WANG Xuerui i.swmail@xen0n.name
Sat Aug 20 10:56:18 GMT 2022


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;
>   	    }


More information about the Binutils mailing list