Browse Source

[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 years ago
parent
commit
cba22d36b7

+ 5
- 3
src/arch/i386/drivers/net/undiload.c View File

103
 
103
 
104
 	/* Call loader */
104
 	/* Call loader */
105
 	undi_loader_entry = undirom->loader_entry;
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
 					   "pushw %%ax\n\t"
108
 					   "pushw %%ax\n\t"
108
 					   "lcall *undi_loader_entry\n\t"
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
 			       : "=a" ( exit )
112
 			       : "=a" ( exit )
111
 			       : "a" ( __from_data16 ( &undi_loader ) )
113
 			       : "a" ( __from_data16 ( &undi_loader ) )
112
-			       : "ebx", "ecx", "edx", "esi", "edi", "ebp" );
114
+			       : "ebx", "ecx", "edx", "esi", "edi" );
113
 
115
 
114
 	if ( exit != PXENV_EXIT_SUCCESS ) {
116
 	if ( exit != PXENV_EXIT_SUCCESS ) {
115
 		/* Clear entry point */
117
 		/* Clear entry point */

+ 5
- 4
src/arch/i386/firmware/pcbios/bios_console.c View File

167
 		return;
167
 		return;
168
 
168
 
169
 	/* Print character with attribute */
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
 					   /* Skip non-printable characters */
172
 					   /* Skip non-printable characters */
172
 					   "cmpb $0x20, %%al\n\t"
173
 					   "cmpb $0x20, %%al\n\t"
173
 					   "jb 1f\n\t"
174
 					   "jb 1f\n\t"
188
 					   "xorw %%bx, %%bx\n\t"
189
 					   "xorw %%bx, %%bx\n\t"
189
 					   "movb $0x0e, %%ah\n\t"
190
 					   "movb $0x0e, %%ah\n\t"
190
 					   "int $0x10\n\t"
191
 					   "int $0x10\n\t"
191
-					   "cli\n\t" )
192
+					   "cli\n\t"
193
+					   "popl %%ebp\n\t" /* gcc bug */ )
192
 			       : "=a" ( discard_a ), "=b" ( discard_b ),
194
 			       : "=a" ( discard_a ), "=b" ( discard_b ),
193
 			         "=c" ( discard_c )
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 View File

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

+ 4
- 3
src/arch/i386/image/elfboot.c View File

60
 
60
 
61
 	/* Jump to OS with flat physical addressing */
61
 	/* Jump to OS with flat physical addressing */
62
 	DBGC ( image, "ELF %p starting execution at %lx\n", image, entry );
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
 			       : : "D" ( entry )
66
 			       : : "D" ( entry )
65
-			       : "eax", "ebx", "ecx", "edx", "esi", "ebp",
66
-			         "memory" );
67
+			       : "eax", "ebx", "ecx", "edx", "esi", "memory" );
67
 
68
 
68
 	DBGC ( image, "ELF %p returned\n", image );
69
 	DBGC ( image, "ELF %p returned\n", image );
69
 
70
 

+ 10
- 6
src/arch/i386/image/nbi.c View File

248
 	       imgheader->execaddr.segoff.offset );
248
 	       imgheader->execaddr.segoff.offset );
249
 
249
 
250
 	__asm__ __volatile__ (
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
 			    "pushw %%bx\n\t"
253
 			    "pushw %%bx\n\t"
253
 			    "pushl %%esi\n\t"	/* location */
254
 			    "pushl %%esi\n\t"	/* location */
254
 			    "pushw %%cs\n\t"	/* lcall execaddr */
255
 			    "pushw %%cs\n\t"	/* lcall execaddr */
258
 			    "pushl %%edi\n\t"
259
 			    "pushl %%edi\n\t"
259
 			    "lret\n\t"
260
 			    "lret\n\t"
260
 			    "\n2:\n\t"
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
 		: "=a" ( rc ), "=D" ( discard_D ), "=S" ( discard_S ),
264
 		: "=a" ( rc ), "=D" ( discard_D ), "=S" ( discard_S ),
263
 		  "=b" ( discard_b )
265
 		  "=b" ( discard_b )
264
 		: "D" ( imgheader->execaddr.segoff ),
266
 		: "D" ( imgheader->execaddr.segoff ),
265
 		  "S" ( imgheader->location ),
267
 		  "S" ( imgheader->location ),
266
 		  "b" ( __from_data16 ( basemem_packet ) )
268
 		  "b" ( __from_data16 ( basemem_packet ) )
267
-		: "ecx", "edx", "ebp" );
269
+		: "ecx", "edx" );
268
 
270
 
269
 	return rc;
271
 	return rc;
270
 }
272
 }
288
 
290
 
289
 	/* Jump to OS with flat physical addressing */
291
 	/* Jump to OS with flat physical addressing */
290
 	__asm__ __volatile__ (
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
 			    "pushl %%esi\n\t" /* imgheader */
295
 			    "pushl %%esi\n\t" /* imgheader */
293
 			    "pushl %%eax\n\t" /* loaderinfo */
296
 			    "pushl %%eax\n\t" /* loaderinfo */
294
 			    "call *%%edi\n\t"
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
 		: "=a" ( rc ), "=D" ( discard_D ), "=S" ( discard_S ),
300
 		: "=a" ( rc ), "=D" ( discard_D ), "=S" ( discard_S ),
297
 		  "=b" ( discard_b )
301
 		  "=b" ( discard_b )
298
 		: "D" ( imgheader->execaddr.linear ),
302
 		: "D" ( imgheader->execaddr.linear ),
300
 			imgheader->location.offset ),
304
 			imgheader->location.offset ),
301
 		  "b" ( virt_to_phys ( basemem_packet ) ),
305
 		  "b" ( virt_to_phys ( basemem_packet ) ),
302
 		  "a" ( virt_to_phys ( &loaderinfo ) )
306
 		  "a" ( virt_to_phys ( &loaderinfo ) )
303
-		: "ecx", "edx", "ebp", "memory" );
307
+		: "ecx", "edx", "memory" );
304
 
308
 
305
 	return rc;
309
 	return rc;
306
 }
310
 }

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

143
 	/* Call real-mode entry point.  This calling convention will
143
 	/* Call real-mode entry point.  This calling convention will
144
 	 * work with both the !PXE and the PXENV+ entry points.
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
 					   "pushw %%di\n\t"
148
 					   "pushw %%di\n\t"
148
 					   "pushw %%bx\n\t"
149
 					   "pushw %%bx\n\t"
149
 					   "lcall *pxeparent_entry_point\n\t"
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
 			       : "=a" ( exit ), "=b" ( discard_b ),
153
 			       : "=a" ( exit ), "=b" ( discard_b ),
152
 			         "=D" ( discard_D )
154
 			         "=D" ( discard_D )
153
 			       : "b" ( function ),
155
 			       : "b" ( function ),
154
 			         "D" ( __from_data16 ( &pxeparent_params ) )
156
 			         "D" ( __from_data16 ( &pxeparent_params ) )
155
-			       : "ecx", "edx", "esi", "ebp" );
157
+			       : "ecx", "edx", "esi" );
156
 
158
 
157
 	/* Determine return status code based on PXENV_EXIT and
159
 	/* Determine return status code based on PXENV_EXIT and
158
 	 * PXENV_STATUS
160
 	 * PXENV_STATUS

Loading…
Cancel
Save