This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


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

Re: Bad generation of jmp r/m32 with offset


Joseph Kain <joseph@3dfx.com> said:
> Here is a description of the bug.  gcc 2.95.2 produces the wrong asm for
> the dispatch function.  The dispatch function looks like this:
> 	void
> 	dispatch (int *i)
> 	{	
> 	  /* Pop frame pointer */
> 	  asm ( "pop %ebp");
> 	  asm ( "jmp %0"
> 		: /* no outputs */
> 		: "m" (info.context->procs.test)
> 		);
> 	}

This is broken. gcc is allowed to move the asm()s around, as there is no
explicit dependency. Also, %ebp is off-limits.

[...]

> With GNU as version 2.9.1 (BFD 2.9.1.0.24) the following warning is issued
> for 
> the jump instruction. 
> 	Warning: warning: missing prefix `*' in absolute indirect address, 
> 	maybe misassembled!
> However it correctly assembles the jump as
> 	FF6004	(JMP r/m32)

Right. You should have written something more like:

	void
	dispatch (int *i)
	{	
	  /* Pop frame pointer */
	  asm ( "pop %ebp
	         jmp *%0"
		: /* no outputs */
		: "m" (info.context->procs.test)
		);
	}

OTOH, AFAIU this is just doing the same as:

  #define dispatch(unused) (info.context->procs.test)()

> GNU as version 2.9.5 (BFD 2.9.5.0.22) issues no warning but instead
> assembles
> the jump incorectly as:
> 	FF6804	(JMP FAR mem)
> 
> Although it is the behavior of the assembler that has changed I
> believe this is a bug in gcc as it is emiting the wrong assembly. 

gcc is just emiting what you gave it in the asm(), it does not look at
what is in there, except for interpolating %<digit>s. You did not supply
the missing '*'. 

PS: Repeating the same in HTML and as tar.bz2 isn't useful.
-- 
Dr. Horst H. von Brand                       mailto:vonbrand@inf.utfsm.cl
Departamento de Informatica                     Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria              +56 32 654239
Casilla 110-V, Valparaiso, Chile                Fax:  +56 32 797513

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