Re: [PATCH v3 1/1] aarch64: mingw: Prevent relocation types from being overwritten

Alan Modra <[email protected]> Wed, 22 Jul 2026 22:34:08 +0930
Newsgroups gmane.comp.gnu.binutils
Message-ID <[email protected]>
On Wed, Jul 22, 2026 at 01:43:19PM +0200, Jan Beulich wrote:
> On 22.07.2026 13:04, Evgeny Karpov wrote:
> > --- a/bfd/cofflink.c
> > +++ b/bfd/cofflink.c
> > @@ -3115,6 +3115,9 @@ _bfd_coff_generic_relocate_section (bfd *output_bfd,
> >  
> >        symndx = rel->r_symndx;
> >  
> > +      if (rel->r_vaddr == (bfd_vma) -1)
> > +	continue;
> > +
> >        if (symndx == -1)
> >  	{
> >  	  h = NULL;
> 
> I have to admit that I have reservations against such a(n) (ab)use of a
> particular value. Yes, -1 may be very unlikely to occur in this field,
> but is it excluded by the spec? Alan, what's your take here?

Firstly, is it really necessary?  What exactly goes wrong with the
current code?

If necessary, I think I'd prefer changing include/coff/internal.h to

struct internal_reloc
{
  bfd_vma r_vaddr;		/* Virtual address of reference */
  long r_symndx;		/* Index into symbol table	*/
  unsigned long r_offset;	/* Used by Alpha ECOFF, SPARC, others */
  unsigned int r_type:16;	/* Relocation type		*/
  unsigned int r_size:8;	/* Used by RS/6000 and ECOFF	*/
  unsigned int r_extern:1;	/* Used by ECOFF		*/
  unsigned int r_ignore:1;
};

Make sure that doesn't break anything in all the coff/ecoff/xcoff/pe
targets.

-- 
Alan Modra