Bladeren bron

[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>
tags/v1.20.1
Michael Brown 10 jaren geleden
bovenliggende
commit
cba22d36b7

+ 5
- 3
src/arch/i386/drivers/net/undiload.c Bestand weergeven

@@ -103,13 +103,15 @@ int undi_load ( struct undi_device *undi, struct undi_rom *undirom ) {
103 103
 
104 104
 	/* Call loader */
105 105
 	undi_loader_entry = undirom->loader_entry;
106
-	__asm__ __volatile__ ( REAL_CODE ( "pushw %%ds\n\t"
106
+	__asm__ __volatile__ ( REAL_CODE ( "pushl %%ebp\n\t" /* gcc bug */
107
+					   "pushw %%ds\n\t"
107 108
 					   "pushw %%ax\n\t"
108 109
 					   "lcall *undi_loader_entry\n\t"
109
-					   "addw $4, %%sp\n\t" )
110
+					   "popl %%ebp\n\t" /* discard */
111
+					   "popl %%ebp\n\t" /* gcc bug */ )
110 112
 			       : "=a" ( exit )
111 113
 			       : "a" ( __from_data16 ( &undi_loader ) )
112
-			       : "ebx", "ecx", "edx", "esi", "edi", "ebp" );
114
+			       : "ebx", "ecx", "edx", "esi", "edi" );
113 115
 
114 116
 	if ( exit != PXENV_EXIT_SUCCESS ) {
115 117
 		/* Clear entry point */

+ 5
- 4
src/arch/i386/firmware/pcbios/bios_console.c Bestand weergeven

@@ -167,7 +167,8 @@ static void bios_putchar ( int character ) {
167 167
 		return;
168 168
 
169 169
 	/* Print character with attribute */
170
-	__asm__ __volatile__ ( REAL_CODE ( "sti\n\t"
170
+	__asm__ __volatile__ ( REAL_CODE ( "pushl %%ebp\n\t" /* gcc bug */
171
+					   "sti\n\t"
171 172
 					   /* Skip non-printable characters */
172 173
 					   "cmpb $0x20, %%al\n\t"
173 174
 					   "jb 1f\n\t"
@@ -188,11 +189,11 @@ static void bios_putchar ( int character ) {
188 189
 					   "xorw %%bx, %%bx\n\t"
189 190
 					   "movb $0x0e, %%ah\n\t"
190 191
 					   "int $0x10\n\t"
191
-					   "cli\n\t" )
192
+					   "cli\n\t"
193
+					   "popl %%ebp\n\t" /* gcc bug */ )
192 194
 			       : "=a" ( discard_a ), "=b" ( discard_b ),
193 195
 			         "=c" ( discard_c )
194
-			       : "a" ( character ), "b" ( bios_attr )
195
-			       : "ebp" );
196
+			       : "a" ( character ), "b" ( bios_attr ) );
196 197
 }
197 198
 
198 199
 /**

+ 6
- 1
src/arch/i386/image/bootsector.c Bestand weergeven

@@ -80,6 +80,8 @@ int call_bootsector ( unsigned int segment, unsigned int offset,
80 80
 					   "movw %%ss, %%ax\n\t"
81 81
 					   "movw %%ax, %%cs:saved_ss\n\t"
82 82
 					   "movw %%sp, %%cs:saved_sp\n\t"
83
+					   /* Save frame pointer (gcc bug) */
84
+					   "movl %%ebp, %%cs:saved_ebp\n\t"
83 85
 					   /* Prepare jump to boot sector */
84 86
 					   "pushw %%bx\n\t"
85 87
 					   "pushw %%di\n\t"
@@ -99,11 +101,14 @@ int call_bootsector ( unsigned int segment, unsigned int offset,
99 101
 					   "sti\n\t"
100 102
 					   "lret\n\t"
101 103
 					   /* Preserved variables */
104
+					   "\nsaved_ebp: .long 0\n\t"
102 105
 					   "\nsaved_ss: .word 0\n\t"
103 106
 					   "\nsaved_sp: .word 0\n\t"
104 107
 					   "\nsaved_retaddr: .word 0\n\t"
105 108
 					   /* Boot failure return point */
106 109
 					   "\nbootsector_exec_fail:\n\t"
110
+					   /* Restore frame pointer (gcc bug) */
111
+					   "movl %%cs:saved_ebp, %%ebp\n\t"
107 112
 					   /* Restore stack pointer */
108 113
 					   "movw %%cs:saved_ss, %%ax\n\t"
109 114
 					   "movw %%ax, %%ss\n\t"
@@ -114,7 +119,7 @@ int call_bootsector ( unsigned int segment, unsigned int offset,
114 119
 			         "=d" ( discard_d )
115 120
 			       : "b" ( segment ), "D" ( offset ),
116 121
 			         "d" ( drive )
117
-			       : "eax", "ecx", "esi", "ebp" );
122
+			       : "eax", "ecx", "esi" );
118 123
 
119 124
 	DBG ( "Booted disk returned via INT 18 or 19\n" );
120 125
 

+ 4
- 3
src/arch/i386/image/elfboot.c Bestand weergeven

@@ -60,10 +60,11 @@ static int elfboot_exec ( struct image *image ) {
60 60
 
61 61
 	/* Jump to OS with flat physical addressing */
62 62
 	DBGC ( image, "ELF %p starting execution at %lx\n", image, entry );
63
-	__asm__ __volatile__ ( PHYS_CODE ( "call *%%edi\n\t" )
63
+	__asm__ __volatile__ ( PHYS_CODE ( "pushl %%ebp\n\t" /* gcc bug */
64
+					   "call *%%edi\n\t"
65
+					   "popl %%ebp\n\t" /* gcc bug */ )
64 66
 			       : : "D" ( entry )
65
-			       : "eax", "ebx", "ecx", "edx", "esi", "ebp",
66
-			         "memory" );
67
+			       : "eax", "ebx", "ecx", "edx", "esi", "memory" );
67 68
 
68 69
 	DBGC ( image, "ELF %p returned\n", image );
69 70
 

+ 10
- 6
src/arch/i386/image/nbi.c Bestand weergeven

@@ -248,7 +248,8 @@ static int nbi_boot16 ( struct image *image, struct imgheader *imgheader ) {
248 248
 	       imgheader->execaddr.segoff.offset );
249 249
 
250 250
 	__asm__ __volatile__ (
251
-		REAL_CODE ( "pushw %%ds\n\t"	/* far pointer to bootp data */
251
+		REAL_CODE ( "pushl %%ebp\n\t"	/* gcc bug */
252
+			    "pushw %%ds\n\t"	/* far pointer to bootp data */
252 253
 			    "pushw %%bx\n\t"
253 254
 			    "pushl %%esi\n\t"	/* location */
254 255
 			    "pushw %%cs\n\t"	/* lcall execaddr */
@@ -258,13 +259,14 @@ static int nbi_boot16 ( struct image *image, struct imgheader *imgheader ) {
258 259
 			    "pushl %%edi\n\t"
259 260
 			    "lret\n\t"
260 261
 			    "\n2:\n\t"
261
-			    "addw $8,%%sp\n\t"	/* clean up stack */ )
262
+			    "addw $8,%%sp\n\t"	/* clean up stack */
263
+			    "popl %%ebp\n\t"	/* gcc bug */ )
262 264
 		: "=a" ( rc ), "=D" ( discard_D ), "=S" ( discard_S ),
263 265
 		  "=b" ( discard_b )
264 266
 		: "D" ( imgheader->execaddr.segoff ),
265 267
 		  "S" ( imgheader->location ),
266 268
 		  "b" ( __from_data16 ( basemem_packet ) )
267
-		: "ecx", "edx", "ebp" );
269
+		: "ecx", "edx" );
268 270
 
269 271
 	return rc;
270 272
 }
@@ -288,11 +290,13 @@ static int nbi_boot32 ( struct image *image, struct imgheader *imgheader ) {
288 290
 
289 291
 	/* Jump to OS with flat physical addressing */
290 292
 	__asm__ __volatile__ (
291
-		PHYS_CODE ( "pushl %%ebx\n\t" /* bootp data */
293
+		PHYS_CODE ( "pushl %%ebp\n\t" /* gcc bug */
294
+			    "pushl %%ebx\n\t" /* bootp data */
292 295
 			    "pushl %%esi\n\t" /* imgheader */
293 296
 			    "pushl %%eax\n\t" /* loaderinfo */
294 297
 			    "call *%%edi\n\t"
295
-			    "addl $12, %%esp\n\t" /* clean up stack */ )
298
+			    "addl $12, %%esp\n\t" /* clean up stack */
299
+			    "popl %%ebp\n\t" /* gcc bug */ )
296 300
 		: "=a" ( rc ), "=D" ( discard_D ), "=S" ( discard_S ),
297 301
 		  "=b" ( discard_b )
298 302
 		: "D" ( imgheader->execaddr.linear ),
@@ -300,7 +304,7 @@ static int nbi_boot32 ( struct image *image, struct imgheader *imgheader ) {
300 304
 			imgheader->location.offset ),
301 305
 		  "b" ( virt_to_phys ( basemem_packet ) ),
302 306
 		  "a" ( virt_to_phys ( &loaderinfo ) )
303
-		: "ecx", "edx", "ebp", "memory" );
307
+		: "ecx", "edx", "memory" );
304 308
 
305 309
 	return rc;
306 310
 }

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

@@ -143,16 +143,18 @@ int pxeparent_call ( SEGOFF16_t entry, unsigned int function,
143 143
 	/* Call real-mode entry point.  This calling convention will
144 144
 	 * work with both the !PXE and the PXENV+ entry points.
145 145
 	 */
146
-	__asm__ __volatile__ ( REAL_CODE ( "pushw %%es\n\t"
146
+	__asm__ __volatile__ ( REAL_CODE ( "pushl %%ebp\n\t" /* gcc bug */
147
+					   "pushw %%es\n\t"
147 148
 					   "pushw %%di\n\t"
148 149
 					   "pushw %%bx\n\t"
149 150
 					   "lcall *pxeparent_entry_point\n\t"
150
-					   "addw $6, %%sp\n\t" )
151
+					   "addw $6, %%sp\n\t"
152
+					   "popl %%ebp\n\t" /* gcc bug */ )
151 153
 			       : "=a" ( exit ), "=b" ( discard_b ),
152 154
 			         "=D" ( discard_D )
153 155
 			       : "b" ( function ),
154 156
 			         "D" ( __from_data16 ( &pxeparent_params ) )
155
-			       : "ecx", "edx", "esi", "ebp" );
157
+			       : "ecx", "edx", "esi" );
156 158
 
157 159
 	/* Determine return status code based on PXENV_EXIT and
158 160
 	 * PXENV_STATUS

Laden…
Annuleren
Opslaan