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]

Re: GAS i386 jmp generator .arch compliance


On Mon, Feb 12, 2001 at 10:07:21AM +1100, Alan Modra wrote:
> On Sun, 11 Feb 2001, Jan Hubicka wrote:
> 
> > ----- Forwarded message from Jan Kratochvil <short@ucw.cz> -----
> >
> > Unfortunately GAS still silently produces 32-bit conditional jumps which are
> > available only on 386 and higher - the attached simple patch fixes this
> > behaviour and gives proper warnings in such case.
> > 
> > suggested commit msg:
> > 		32-bit conditional jumps availability checked by .arch mode
...
> >      case ENCODE_RELAX_STATE (COND_JUMP, BIG):
> > +      warn_long_jump (fragP);
> >        extension = 5;		/* 2 opcode + 4 displacement  */
> >        opcode[1] = opcode[0] + 0x10;
> >        opcode[0] = TWO_BYTE_OPCODE_ESCAPE;
> 
> Is the above needed?  I think you won't generate `BIG' jumps in 16 bit
> mode, but it's a while since I added this code.

  Despite ".code16" modifier used latest GAS still produces 6-byte long
conditional jumps (0x0F 0x8? <32-bit offset>) - AFD debugger for DOS has a bit
problems with disassembling of such jumps so I really know what I'm saying.
:-)

> Also, can I ask that you do a little more work here?  It would be nice if
> instead of a warning in 8086 mode, we turned
> 
>  jcond too_far
> 
> into
> 
>  jncond .+5
>  jmp too_far
...
> Alan Modra

  Although I may surprise you that I've even thought about such automatic
translation it would be very big misfeature for my current purposes: As I
assemble also DOS 512-byte first-stage loader, I'm really glad of every byte
saved (so the only thing I want to hear is the error message, no
semi-inteligence from machine).  Such suggested autogenerated jumps would cost
additional 3 bytes for each such case while I'm usually successfuly saving such
byte by using already existing far jump in some code around (or some other
short conditional jump with acceptable condition code etc.).

  BTW I have shortly thought about automatic search for latest jump for the
same target but this optimization is too dangerous to be possible - my other
code moves its code parts around of the memory and such 'near' similiear jump
can cease to be very easily (and consequential jump would then crash, of
course).

  I would implement such autotranslation only in the case if someone suggest me
'how to disable it' - either from command-line or by some keyword. I don't
think that some completely new keyword would be welcome for such detail but
which existing switch functionality could be misused?



						Lace


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