This is the mail archive of the binutils@sources.redhat.com 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: d10v: swapping insns requires swapping relocs


Hi Alexandre,

> from  Alexandre Oliva  <aoliva@redhat.com>
> 
> 	* config/tc-d10v.c (write_2_short): Mark L reloc insn when
> 	L and R are swapped.

Approved, but...

>  	  if (opcode1->unit == IU)
> -	    insn = FM00 | (insn2 << 15) | insn1;
> +	    {
> +	      swapped = 1;
> +	      insn = FM00 | (insn2 << 15) | insn1;
> +	    }

It might be better (and less prone to bit rot in the future) if
instead of setting a 'swapped' flag in all of the places where
instruction swapping occurs, you alter the code that tests to see if
swapping has occurred:

> +	      /* A BFD_RELOC_D10V_10_PCREL_R relocation applied to the
> +                 instruction in the L container has to be adjusted to
> +                 BDF_RELOC_D10V_10_PCREL_L.  When processing the L
> +                 container, j == 0, unless we swapped the containers,
> +                 in which case the L instruction gets j == 1, i.e.,
> +                 the L container gets j == swapped.  */
> +	      if (fx->fix[i].reloc == BFD_RELOC_D10V_10_PCREL_R
> +		  && j == swapped)

Becomes:

        if (fx->fixpi].reloc == BFD_RELOC_D10V_10_PCREL_R
            && (j == (((insn & (0xFF << 15)) & insn2) == insn2)))

Cheers
        Nick


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