This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: [PATCH] MIPS: microMIPS and MCU ASE instruction set support


Richard Sandiford wrote:

> > 	(mips_relax_frag): Handle microMIPS.
> 
> +     gas_assert (fixp->fx_r_type == BFD_RELOC_16_PCREL_S2
> +	      || fixp->fx_r_type == BFD_RELOC_MICROMIPS_7_PCREL_S1
> +	      || fixp->fx_r_type == BFD_RELOC_MICROMIPS_10_PCREL_S1
> +	      || fixp->fx_r_type == BFD_RELOC_MICROMIPS_16_PCREL_S1);
> +
> +      /* For 7/10 PCREL_S1, we just need to use 
> fixp->fx_addnumber.  */
> +      if (fixp->fx_r_type == BFD_RELOC_MICROMIPS_7_PCREL_S1
> +	  || fixp->fx_r_type == BFD_RELOC_MICROMIPS_10_PCREL_S1)
> +	reloc->addend = fixp->fx_addnumber;
> +      else
> +	/* At this point, fx_addnumber is "symbol offset - 
> pcrel address".
> +	   Relocations want only the symbol offset.  */
> +	reloc->addend = fixp->fx_addnumber + reloc->address;
> 
> A better comment is needed.  _Why_ do you just need fx_addnumber?
> 

  Thanks for the review!  The explanation is in another place as
follows.
Maybe we need to copy the comment to tc_gen_reloc from md_pcrel_from.
Ex:
long
md_pcrel_from (fixS *fixP)
{
  valueT addr = fixP->fx_where + fixP->fx_frag->fr_address;
  switch (fixP->fx_r_type)
    {
    /* We don't add addr, because it will cause the error checking of
       "addnumber" fail in write.c for *7/10_PCREL_S1.
        In tc_gen_reloc, we just use fixp->fx_addnumber.  */
    case BFD_RELOC_MICROMIPS_7_PCREL_S1:
    case BFD_RELOC_MICROMIPS_10_PCREL_S1:
      /* Return the beginning of the delay slot from the current insn.
*/
      return 2;

    case BFD_RELOC_MICROMIPS_16_PCREL_S1:
    case BFD_RELOC_MICROMIPS_JMP:
    case BFD_RELOC_16_PCREL_S2:
    case BFD_RELOC_MIPS_JMP:
      /* Return the address of the delay slot.  */
      return addr + 4;
...

  The field of *7/10_PCREL_S1 is limited in the 16-bit instructions.
If we add the "address", write.c will fail to check these two
relocations due to overflow or something (I kind of forgot). From
debugging, adding "address" is no use at all, because later "address" is
subtracted.
Maybe, we can do the same thing to *16_PCREL* by discarding address in
tc_gen_reloc() and md_pcrel_from(),
such that code looks cleaner and the same.
Thanks!

Regards,
Chao-ying


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]