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 Tue, Feb 13, 2001 at 12:44:40PM +1100, Alan Modra wrote:
> On Tue, 13 Feb 2001, Jan Kratochvil wrote:
> 
> > But I'm writing this mail as I think that your patch has small mistake:
> > When I compile attached "test16.S", it will warn me that "long jump required"
> > but is is a normal regular jump available from 8086 days. The warning message
> > is just moved to the 'right place' - do you agree? I was unable to prevent the
> > warning when long (16-bit) call just had to be used to cope with the range.
> 
> Thanks for testing it.  I did intend that "nojumps" would warn about all
> short to long jump promotion.

  OK but there MUST be ANY way how to write 16-bit (or 32-bit) unconditional
jump when I'm aware during coding that it really will be 'long' (=BIG) jump.
(This sentence expresses the summary of the whole rest of this mail.)

> I was trying to make a hack for .arch i8086
> useful in other modes too.  Maybe that's not such a good idea.
> 
> As it stands, "nojumps" does two things:
> a) warns about jump promotion within a single file.
> b) leaves branches to external symbols as short branches.
> 
> Your patch will change a) to just warn about a particular type of jump
> promotion.  In looking at the larger picture, is that reasonable?

Although it is a change of current GAS behaviour, I would accept even the more
explicit writing of jump sizes. But I need to know the only simple single
thing: HOW I can modify the supplied "test16.S" to NOT to produce the warning?
Yes, I'm aware that it should be 16-bit jump but how to write it in the source
file (to produce the same byte sequence E9 D2 04 as it is produced with the
warning)?

I've scanned through the info documentation for GAS but I haven't found such
way to direct write 0xE9 instruction (moreover such opcode is even MISSING in
the table "include/opcode/i386.h"). It implies that such opcode 0xE9 can be
produced only from 3 places:

* md_create_long_jump() - it is called only on "broken word" processing, not
		usable for this problem of plain in-code intra-segment jump

* md_estimate_size_before_relax() - only the part where the jump target is
		'external' (=different segment) AND it MUST be in
		".arch ,jumps" mode (I want 0xE9 for plain intra-segment jump
		AND I can use ",nojumps" mode when I'm doing 16-bit
		unconditional jump)

* md_convert_frag() - 0xE9 is always wrapped in "long jump required" warning

I really don't want a bunch of unavoidable warnings on each compilation.  :-(

> Hmm, how about changing a) and b) to just effect all _conditional_
> braches.  Does that sound OK to you?

  Yes, that would fix it:
  
(a) point should be the one attached to this mail as "tc-i386.c-modra1-fix.diff"
    (sent to you in the previous private mail), I think.

(b) You patch has disabled promotion to 16-bit of jumps to external symbols.
    OK, this may be acceptable (so that the programmer MUST know that the jump
    will be BIG). But as I don't know about any way how to authoritatively
    specify that the jump should be BIG, you have in fact disabled ANY chance
    how to produce "RELOCATION RECORD" in ",nojumps" (=non-promoting) mode.
    Moreover it will even don't produce any warning that it ignored the
    relocation requirement for short jump (such 1-byte relative relocation
    isn't probably even producable in common object file formats but I'm just
    guessing).


				Lace, amazed how simple jump can be complex
	.arch	i8086,nojumps
	.code16
	.text
	.globl	_start
_start:
	jmp	here
	.space 1234
here:
	.arch	i8086,nojumps
	.code16
	.text
	.extern	somewhere
	.globl	_start
_start:
	jmp	somewhere
--- tc-i386.c-modra1	Tue Feb 13 00:16:47 2001
+++ tc-i386.c	Tue Feb 13 00:27:10 2001
@@ -4049,9 +4049,6 @@
     }
   else
     {
-      if (no_jump_promotion)
-	as_warn_where (fragP->fr_file, fragP->fr_line, _("long jump required"));
-
       switch (fragP->fr_subtype)
 	{
 	case ENCODE_RELAX_STATE (UNCOND_JUMP, BIG):
@@ -4082,6 +4079,8 @@
 	  break;
 
 	case ENCODE_RELAX_STATE (COND_JUMP86, BIG16):
+	  if (no_jump_promotion)
+	    as_warn_where (fragP->fr_file, fragP->fr_line, _("long jump required"));
 	  extension = 4;
 	  opcode[0] ^= 1;
 	  opcode[1] = 3;

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