Browse Source

[build] Work around bug in gcc >= 4.8

gcc 4.8 and 4.9 fail to compile pxe_call.c with the error "bp cannot
be used in asm here".  Other points in the codebase which use "ebp" in
the asm clobber list do not seem to be affected.

Unfortunately gcc provides no way to specify %ebp as an output
register, so we cannot use this as a workaround.  The only viable
solution is to explicitly push/pop %ebp within the asm itself.  This
is ugly for two reasons: firstly, it may be unnecessary; secondly, it
may cause gcc to generate invalid %esp-relative addresses if the asm
happens to use memory operands.  This specific block of asm uses no
memory operands and so will not generate invalid code.

Reported-by: Daniel P. Berrange <berrange@redhat.com>
Reported-by: Christian Hesse <list@eworm.de>
Originally-fixed-by: Christian Hesse <list@eworm.de>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 11 years ago
parent
commit
238050dfd4
1 changed files with 5 additions and 3 deletions
  1. 5
    3
      src/arch/i386/interface/pxe/pxe_call.c

+ 5
- 3
src/arch/i386/interface/pxe/pxe_call.c View File

271
 		DBG ( "Restarting NBP (%x)\n", jmp );
271
 		DBG ( "Restarting NBP (%x)\n", jmp );
272
 
272
 
273
 	/* Far call to PXE NBP */
273
 	/* Far call to PXE NBP */
274
-	__asm__ __volatile__ ( REAL_CODE ( "movw %%cx, %%es\n\t"
274
+	__asm__ __volatile__ ( REAL_CODE ( "pushl %%ebp\n\t" /* gcc bug */
275
+					   "movw %%cx, %%es\n\t"
275
 					   "pushw %%es\n\t"
276
 					   "pushw %%es\n\t"
276
 					   "pushw %%di\n\t"
277
 					   "pushw %%di\n\t"
277
 					   "sti\n\t"
278
 					   "sti\n\t"
278
 					   "lcall $0, $0x7c00\n\t"
279
 					   "lcall $0, $0x7c00\n\t"
279
-					   "addw $4, %%sp\n\t" )
280
+					   "popl %%ebp\n\t" /* discard */
281
+					   "popl %%ebp\n\t" /* gcc bug */ )
280
 			       : "=a" ( status ), "=b" ( discard_b ),
282
 			       : "=a" ( status ), "=b" ( discard_b ),
281
 				 "=c" ( discard_c ), "=d" ( discard_d ),
283
 				 "=c" ( discard_c ), "=d" ( discard_d ),
282
 				 "=D" ( discard_D )
284
 				 "=D" ( discard_D )
284
 			         "c" ( rm_cs ),
286
 			         "c" ( rm_cs ),
285
 			         "d" ( virt_to_phys ( &pxenv ) ),
287
 			         "d" ( virt_to_phys ( &pxenv ) ),
286
 				 "D" ( __from_text16 ( &ppxe ) )
288
 				 "D" ( __from_text16 ( &ppxe ) )
287
-			       : "esi", "ebp", "memory" );
289
+			       : "esi", "memory" );
288
 	if ( status )
290
 	if ( status )
289
 		return -EPXENBP ( status );
291
 		return -EPXENBP ( status );
290
 
292
 

Loading…
Cancel
Save