[PATCH 1/5 v1] LoongArch: bfd: Add new reloc types.

Xi Ruoyao xry111@xry111.site
Tue Jul 19 05:40:02 GMT 2022


On Tue, 2022-07-19 at 12:29 +0800, Xi Ruoyao via Binutils wrote:
> On Mon, 2022-07-18 at 16:43 +0800, liuzhensong wrote:
> > @@ -2427,7 +2453,7 @@ loongarch_elf_relocate_section (bfd
> > *output_bfd,
> > struct bfd_link_info *info,
> >  
> >           if (h != NULL)
> >             {
> > -             off = h->got.offset;
> > +             off = h->got.offset & (~1);
> >  
> >               if (off == MINUS_ONE
> >                   && h->type != STT_GNU_IFUNC)
> > @@ -2455,79 +2481,76 @@ loongarch_elf_relocate_section (bfd
> > *output_bfd, struct bfd_link_info *info,
> 
> This cannot be correct: after "off = h->got.offset & (~1)", how could
> "off == MINUS_ONE" be true?
> 
> Either you calculated "off" wrong, or you should remove the dead code.

I guess you need the following changes.  With those changes Glibc ifunc
tests passed:

diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c
index 44b8d6dca9b..4d22ba037c8 100644
--- a/bfd/elfnn-loongarch.c
+++ b/bfd/elfnn-loongarch.c
@@ -2730,7 +2730,7 @@ loongarch_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
 	    {
 	      off = h->got.offset & (~1);
 
-	      if (off == MINUS_ONE
+	      if (h->got.offset == MINUS_ONE
 		  && h->type != STT_GNU_IFUNC)
 		{
 		  fatal = (loongarch_reloc_is_fatal
@@ -2742,7 +2742,7 @@ loongarch_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
 
 	      /* Hidden symbol not has .got entry, only .got.plt entry
 		 so gprel is (plt - got).  */
-	      if (off == MINUS_ONE
+	      if (h->got.offset == MINUS_ONE
 		  && h->type == STT_GNU_IFUNC)
 		{
 		  if (h->plt.offset == (bfd_vma) -1)

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


More information about the Binutils mailing list