mirror of
https://github.com/xcat2/xNBA.git
synced 2024-11-22 01:21:45 +00:00
[build] Work around bug in gcc >= 4.8
Commit 238050d
("[build] Work around bug in gcc >= 4.8") works around
one instance of a bug in recent versions of gcc, in which "ebp" cannot
be specified within an asm clobber list.
Some versions of gcc seem to exhibit the same bug on other points in
the codebase. Fix by changing all instances of "ebp" in a clobber
list to use the push/pop %ebp workaround instead.
Originally-implemented-by: Víctor Román Archidona <contacto@victor-roman.es>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
parent
a9fa0d5f2b
commit
cba22d36b7
@ -103,13 +103,15 @@ int undi_load ( struct undi_device *undi, struct undi_rom *undirom ) {
|
||||
|
||||
/* Call loader */
|
||||
undi_loader_entry = undirom->loader_entry;
|
||||
__asm__ __volatile__ ( REAL_CODE ( "pushw %%ds\n\t"
|
||||
__asm__ __volatile__ ( REAL_CODE ( "pushl %%ebp\n\t" /* gcc bug */
|
||||
"pushw %%ds\n\t"
|
||||
"pushw %%ax\n\t"
|
||||
"lcall *undi_loader_entry\n\t"
|
||||
"addw $4, %%sp\n\t" )
|
||||
"popl %%ebp\n\t" /* discard */
|
||||
"popl %%ebp\n\t" /* gcc bug */ )
|
||||
: "=a" ( exit )
|
||||
: "a" ( __from_data16 ( &undi_loader ) )
|
||||
: "ebx", "ecx", "edx", "esi", "edi", "ebp" );
|
||||
: "ebx", "ecx", "edx", "esi", "edi" );
|
||||
|
||||
if ( exit != PXENV_EXIT_SUCCESS ) {
|
||||
/* Clear entry point */
|
||||
|
@ -167,7 +167,8 @@ static void bios_putchar ( int character ) {
|
||||
return;
|
||||
|
||||
/* Print character with attribute */
|
||||
__asm__ __volatile__ ( REAL_CODE ( "sti\n\t"
|
||||
__asm__ __volatile__ ( REAL_CODE ( "pushl %%ebp\n\t" /* gcc bug */
|
||||
"sti\n\t"
|
||||
/* Skip non-printable characters */
|
||||
"cmpb $0x20, %%al\n\t"
|
||||
"jb 1f\n\t"
|
||||
@ -188,11 +189,11 @@ static void bios_putchar ( int character ) {
|
||||
"xorw %%bx, %%bx\n\t"
|
||||
"movb $0x0e, %%ah\n\t"
|
||||
"int $0x10\n\t"
|
||||
"cli\n\t" )
|
||||
"cli\n\t"
|
||||
"popl %%ebp\n\t" /* gcc bug */ )
|
||||
: "=a" ( discard_a ), "=b" ( discard_b ),
|
||||
"=c" ( discard_c )
|
||||
: "a" ( character ), "b" ( bios_attr )
|
||||
: "ebp" );
|
||||
: "a" ( character ), "b" ( bios_attr ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -80,6 +80,8 @@ int call_bootsector ( unsigned int segment, unsigned int offset,
|
||||
"movw %%ss, %%ax\n\t"
|
||||
"movw %%ax, %%cs:saved_ss\n\t"
|
||||
"movw %%sp, %%cs:saved_sp\n\t"
|
||||
/* Save frame pointer (gcc bug) */
|
||||
"movl %%ebp, %%cs:saved_ebp\n\t"
|
||||
/* Prepare jump to boot sector */
|
||||
"pushw %%bx\n\t"
|
||||
"pushw %%di\n\t"
|
||||
@ -99,11 +101,14 @@ int call_bootsector ( unsigned int segment, unsigned int offset,
|
||||
"sti\n\t"
|
||||
"lret\n\t"
|
||||
/* Preserved variables */
|
||||
"\nsaved_ebp: .long 0\n\t"
|
||||
"\nsaved_ss: .word 0\n\t"
|
||||
"\nsaved_sp: .word 0\n\t"
|
||||
"\nsaved_retaddr: .word 0\n\t"
|
||||
/* Boot failure return point */
|
||||
"\nbootsector_exec_fail:\n\t"
|
||||
/* Restore frame pointer (gcc bug) */
|
||||
"movl %%cs:saved_ebp, %%ebp\n\t"
|
||||
/* Restore stack pointer */
|
||||
"movw %%cs:saved_ss, %%ax\n\t"
|
||||
"movw %%ax, %%ss\n\t"
|
||||
@ -114,7 +119,7 @@ int call_bootsector ( unsigned int segment, unsigned int offset,
|
||||
"=d" ( discard_d )
|
||||
: "b" ( segment ), "D" ( offset ),
|
||||
"d" ( drive )
|
||||
: "eax", "ecx", "esi", "ebp" );
|
||||
: "eax", "ecx", "esi" );
|
||||
|
||||
DBG ( "Booted disk returned via INT 18 or 19\n" );
|
||||
|
||||
|
@ -60,10 +60,11 @@ static int elfboot_exec ( struct image *image ) {
|
||||
|
||||
/* Jump to OS with flat physical addressing */
|
||||
DBGC ( image, "ELF %p starting execution at %lx\n", image, entry );
|
||||
__asm__ __volatile__ ( PHYS_CODE ( "call *%%edi\n\t" )
|
||||
__asm__ __volatile__ ( PHYS_CODE ( "pushl %%ebp\n\t" /* gcc bug */
|
||||
"call *%%edi\n\t"
|
||||
"popl %%ebp\n\t" /* gcc bug */ )
|
||||
: : "D" ( entry )
|
||||
: "eax", "ebx", "ecx", "edx", "esi", "ebp",
|
||||
"memory" );
|
||||
: "eax", "ebx", "ecx", "edx", "esi", "memory" );
|
||||
|
||||
DBGC ( image, "ELF %p returned\n", image );
|
||||
|
||||
|
@ -248,7 +248,8 @@ static int nbi_boot16 ( struct image *image, struct imgheader *imgheader ) {
|
||||
imgheader->execaddr.segoff.offset );
|
||||
|
||||
__asm__ __volatile__ (
|
||||
REAL_CODE ( "pushw %%ds\n\t" /* far pointer to bootp data */
|
||||
REAL_CODE ( "pushl %%ebp\n\t" /* gcc bug */
|
||||
"pushw %%ds\n\t" /* far pointer to bootp data */
|
||||
"pushw %%bx\n\t"
|
||||
"pushl %%esi\n\t" /* location */
|
||||
"pushw %%cs\n\t" /* lcall execaddr */
|
||||
@ -258,13 +259,14 @@ static int nbi_boot16 ( struct image *image, struct imgheader *imgheader ) {
|
||||
"pushl %%edi\n\t"
|
||||
"lret\n\t"
|
||||
"\n2:\n\t"
|
||||
"addw $8,%%sp\n\t" /* clean up stack */ )
|
||||
"addw $8,%%sp\n\t" /* clean up stack */
|
||||
"popl %%ebp\n\t" /* gcc bug */ )
|
||||
: "=a" ( rc ), "=D" ( discard_D ), "=S" ( discard_S ),
|
||||
"=b" ( discard_b )
|
||||
: "D" ( imgheader->execaddr.segoff ),
|
||||
"S" ( imgheader->location ),
|
||||
"b" ( __from_data16 ( basemem_packet ) )
|
||||
: "ecx", "edx", "ebp" );
|
||||
: "ecx", "edx" );
|
||||
|
||||
return rc;
|
||||
}
|
||||
@ -288,11 +290,13 @@ static int nbi_boot32 ( struct image *image, struct imgheader *imgheader ) {
|
||||
|
||||
/* Jump to OS with flat physical addressing */
|
||||
__asm__ __volatile__ (
|
||||
PHYS_CODE ( "pushl %%ebx\n\t" /* bootp data */
|
||||
PHYS_CODE ( "pushl %%ebp\n\t" /* gcc bug */
|
||||
"pushl %%ebx\n\t" /* bootp data */
|
||||
"pushl %%esi\n\t" /* imgheader */
|
||||
"pushl %%eax\n\t" /* loaderinfo */
|
||||
"call *%%edi\n\t"
|
||||
"addl $12, %%esp\n\t" /* clean up stack */ )
|
||||
"addl $12, %%esp\n\t" /* clean up stack */
|
||||
"popl %%ebp\n\t" /* gcc bug */ )
|
||||
: "=a" ( rc ), "=D" ( discard_D ), "=S" ( discard_S ),
|
||||
"=b" ( discard_b )
|
||||
: "D" ( imgheader->execaddr.linear ),
|
||||
@ -300,7 +304,7 @@ static int nbi_boot32 ( struct image *image, struct imgheader *imgheader ) {
|
||||
imgheader->location.offset ),
|
||||
"b" ( virt_to_phys ( basemem_packet ) ),
|
||||
"a" ( virt_to_phys ( &loaderinfo ) )
|
||||
: "ecx", "edx", "ebp", "memory" );
|
||||
: "ecx", "edx", "memory" );
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
@ -143,16 +143,18 @@ int pxeparent_call ( SEGOFF16_t entry, unsigned int function,
|
||||
/* Call real-mode entry point. This calling convention will
|
||||
* work with both the !PXE and the PXENV+ entry points.
|
||||
*/
|
||||
__asm__ __volatile__ ( REAL_CODE ( "pushw %%es\n\t"
|
||||
__asm__ __volatile__ ( REAL_CODE ( "pushl %%ebp\n\t" /* gcc bug */
|
||||
"pushw %%es\n\t"
|
||||
"pushw %%di\n\t"
|
||||
"pushw %%bx\n\t"
|
||||
"lcall *pxeparent_entry_point\n\t"
|
||||
"addw $6, %%sp\n\t" )
|
||||
"addw $6, %%sp\n\t"
|
||||
"popl %%ebp\n\t" /* gcc bug */ )
|
||||
: "=a" ( exit ), "=b" ( discard_b ),
|
||||
"=D" ( discard_D )
|
||||
: "b" ( function ),
|
||||
"D" ( __from_data16 ( &pxeparent_params ) )
|
||||
: "ecx", "edx", "esi", "ebp" );
|
||||
: "ecx", "edx", "esi" );
|
||||
|
||||
/* Determine return status code based on PXENV_EXIT and
|
||||
* PXENV_STATUS
|
||||
|
Loading…
Reference in New Issue
Block a user