[PATCH v2 1/5] LoongArch: Reject R_LARCH_32 from becoming a runtime reloc in ELFCLASS64

Xi Ruoyao xry111@xry111.site
Thu Jun 27 12:39:54 GMT 2024


On Thu, 2024-06-27 at 18:58 +0800, Jinyang He wrote:

/* snip */

> > @@ -2861,7 +2861,28 @@ loongarch_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
> >   	      /* No alloc space of func allocate_dynrelocs.  */
> >   	      if (unresolved_reloc
> >   		  && !(h && (h->is_weakalias || !h->dyn_relocs)))
> > -		loongarch_elf_append_rela (output_bfd, sreloc, &outrel);
> > +		{
> > +		  if (is_pic && r_type != R_LARCH_NN)
> > +		    {
> > +		      /* Not to use ELFCLASSNN in string literal or it'll
> > +			 puzzle gettext.  */
> > +
> > +		      /* xgettext:c-format  */
> > +		      char *msg = bfd_asprintf (
> > +			_("reloc is unresolved and cannot be turned to "
> > +			  "a runtime reloc in ELFCLASS%d"),
> > +			NN);
> > +
> > +		      /* loongarch_reloc_is_fatal will output
> > +			 "R_LARCH_32" or "R_LARCH_64" for us.  */
> I'd like to do this rejection earlier in `check_relocs` than
> `relocate_section`. Generally loongarch32 do not produce R_LARCH_64,
> so this rejection should be efficient only for R_LARCH_32 on loongarch64.

Ok, in V3 I'll use the same approach as RISC-V then.


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


More information about the Binutils mailing list