Bladeren bron

[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 jaren geleden
bovenliggende
commit
238050dfd4
1 gewijzigde bestanden met toevoegingen van 5 en 3 verwijderingen
  1. 5
    3
      src/arch/i386/interface/pxe/pxe_call.c

+ 5
- 3
src/arch/i386/interface/pxe/pxe_call.c Bestand weergeven

@@ -271,12 +271,14 @@ int pxe_start_nbp ( void ) {
271 271
 		DBG ( "Restarting NBP (%x)\n", jmp );
272 272
 
273 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 276
 					   "pushw %%es\n\t"
276 277
 					   "pushw %%di\n\t"
277 278
 					   "sti\n\t"
278 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 282
 			       : "=a" ( status ), "=b" ( discard_b ),
281 283
 				 "=c" ( discard_c ), "=d" ( discard_d ),
282 284
 				 "=D" ( discard_D )
@@ -284,7 +286,7 @@ int pxe_start_nbp ( void ) {
284 286
 			         "c" ( rm_cs ),
285 287
 			         "d" ( virt_to_phys ( &pxenv ) ),
286 288
 				 "D" ( __from_text16 ( &ppxe ) )
287
-			       : "esi", "ebp", "memory" );
289
+			       : "esi", "memory" );
288 290
 	if ( status )
289 291
 		return -EPXENBP ( status );
290 292
 

Laden…
Annuleren
Opslaan