[PATCH] LoongArch: Fix symbol size after relaxation

Xi Ruoyao xry111@xry111.site
Wed Aug 6 04:09:16 GMT 2025


On Wed, 2025-08-06 at 11:59 +0800, mengqinggang wrote:
> Hi Ruoyao:
> 
> Some modification suggestions may make the code better understood.

/* snip */

> > +      /* This shouldn't happen unless people write something really insane like
> > +	     .reloc ., R_LARCH_ALIGN, 60
> > +	     .rept 15
> > +	     1: nop
> > +	     .endr
> > +	     .set x, 1b
> > +	     .size x, . - 1b
> > +	 But let's just try to make it "work" anyway.  */
> > +      if (orig_value - addr < op->size)
> 
>                      if (orig_value < addr + op->size)
> 
> > 

/* snip */

> > +      if (orig_end - addr <= op->size)
> > +	{
> > +	  *size -= orig_end - addr;
> > +	  return;
> > +	}
> > +
> > +      *size -= op->size;
> 
>                  if (orig_end <= addr + op->size)
>                          *size -= orig_end -addr;
>                    else
>                          *size -= op->size;

Ok.  I was afraid of a wrapping around of unsigned addition in these two
cases, but op->size is calculated by the relax pass so the wrapping
shouldn't happen anyway.

-- 
Xi Ruoyao <xry111@xry111.site>


More information about the Binutils mailing list