Browse Source

[librm] Ensure that inline code symbols are unique

Commit 6149e0a ("[librm] Provide symbols for inline code placed into
other sections") may cause build failures due to duplicate label names
if the compiler chooses to duplicate inline assembly code.

Fix by using the "%=" special format string to include a
guaranteed-unique number within the label name.

The "%=" will be expanded only if constraints exist for the inline
assembly.  This fix therefore requires that all REAL_CODE() fragments
use a (possibly empty) constraint list.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 6 years ago
parent
commit
bc85368cdd

+ 1
- 1
src/arch/x86/core/dumpregs.c View File

7
 		TEXT16_CODE ( ".globl dump_regs\n\t"
7
 		TEXT16_CODE ( ".globl dump_regs\n\t"
8
 			      "\ndump_regs:\n\t"
8
 			      "\ndump_regs:\n\t"
9
 			      VIRT_CALL ( _dump_regs )
9
 			      VIRT_CALL ( _dump_regs )
10
-			      "ret\n\t" ) );
10
+			      "ret\n\t" ) : );
11
 
11
 
12
 	printf ( "EAX=%08x EBX=%08x ECX=%08x EDX=%08x\n"
12
 	printf ( "EAX=%08x EBX=%08x ECX=%08x EDX=%08x\n"
13
 		 "ESI=%08x EDI=%08x EBP=%08x ESP=%08x\n"
13
 		 "ESI=%08x EDI=%08x EBP=%08x ESP=%08x\n"

+ 1
- 1
src/arch/x86/include/librm.h View File

255
 #endif
255
 #endif
256
 
256
 
257
 /* LINE_SYMBOL: declare a symbol for the current source code line */
257
 /* LINE_SYMBOL: declare a symbol for the current source code line */
258
-#define LINE_SYMBOL _S2 ( OBJECT ) "__line_" _S2 ( __LINE__ ) ":"
258
+#define LINE_SYMBOL _S2 ( OBJECT ) "__line_" _S2 ( __LINE__ ) "__%=:"
259
 
259
 
260
 /* TEXT16_CODE: declare a fragment of code that resides in .text16 */
260
 /* TEXT16_CODE: declare a fragment of code that resides in .text16 */
261
 #define TEXT16_CODE( asm_code_str )			\
261
 #define TEXT16_CODE( asm_code_str )			\

+ 2
- 2
src/arch/x86/interface/pcbios/bios_console.c View File

521
 	__asm__ __volatile__ (
521
 	__asm__ __volatile__ (
522
 		TEXT16_CODE ( "\nint16_wrapper:\n\t"
522
 		TEXT16_CODE ( "\nint16_wrapper:\n\t"
523
 			      "pushfw\n\t"
523
 			      "pushfw\n\t"
524
-			      "cmpb $0, %cs:bios_inject_lock\n\t"
524
+			      "cmpb $0, %%cs:bios_inject_lock\n\t"
525
 			      "jnz 1f\n\t"
525
 			      "jnz 1f\n\t"
526
 			      VIRT_CALL ( bios_inject )
526
 			      VIRT_CALL ( bios_inject )
527
 			      "\n1:\n\t"
527
 			      "\n1:\n\t"
528
 			      "popfw\n\t"
528
 			      "popfw\n\t"
529
-			      "ljmp *%cs:int16_vector\n\t" ) );
529
+			      "ljmp *%%cs:int16_vector\n\t" ) : );
530
 
530
 
531
 	/* Hook INT 16 */
531
 	/* Hook INT 16 */
532
 	hook_bios_interrupt ( 0x16, ( ( intptr_t ) int16_wrapper ),
532
 	hook_bios_interrupt ( 0x16, ( ( intptr_t ) int16_wrapper ),

+ 1
- 1
src/arch/x86/interface/pcbios/bios_reboot.c View File

48
 	put_real ( flag, BDA_SEG, BDA_REBOOT );
48
 	put_real ( flag, BDA_SEG, BDA_REBOOT );
49
 
49
 
50
 	/* Jump to system reset vector */
50
 	/* Jump to system reset vector */
51
-	__asm__ __volatile__ ( REAL_CODE ( "ljmp $0xf000, $0xfff0" ) );
51
+	__asm__ __volatile__ ( REAL_CODE ( "ljmp $0xf000, $0xfff0" ) : );
52
 }
52
 }
53
 
53
 
54
 /**
54
 /**

+ 3
- 3
src/arch/x86/interface/syslinux/comboot_call.c View File

663
 			      VIRT_CALL ( int20 )
663
 			      VIRT_CALL ( int20 )
664
 			      "clc\n\t"
664
 			      "clc\n\t"
665
 			      "call patch_cf\n\t"
665
 			      "call patch_cf\n\t"
666
-		              "iret\n\t" ) );
666
+		              "iret\n\t" ) : );
667
 
667
 
668
 	hook_bios_interrupt ( 0x20, ( intptr_t ) int20_wrapper, &int20_vector );
668
 	hook_bios_interrupt ( 0x20, ( intptr_t ) int20_wrapper, &int20_vector );
669
 
669
 
672
 			      VIRT_CALL ( int21 )
672
 			      VIRT_CALL ( int21 )
673
 			      "clc\n\t"
673
 			      "clc\n\t"
674
 			      "call patch_cf\n\t"
674
 			      "call patch_cf\n\t"
675
-		              "iret\n\t" ) );
675
+		              "iret\n\t" ) : );
676
 
676
 
677
 	hook_bios_interrupt ( 0x21, ( intptr_t ) int21_wrapper, &int21_vector );
677
 	hook_bios_interrupt ( 0x21, ( intptr_t ) int21_wrapper, &int21_vector );
678
 
678
 
681
 			      VIRT_CALL ( int22 )
681
 			      VIRT_CALL ( int22 )
682
 			      "clc\n\t"
682
 			      "clc\n\t"
683
 			      "call patch_cf\n\t"
683
 			      "call patch_cf\n\t"
684
-		              "iret\n\t" ) );
684
+		              "iret\n\t" ) : );
685
 
685
 
686
 	hook_bios_interrupt ( 0x22, ( intptr_t ) int22_wrapper, &int22_vector );
686
 	hook_bios_interrupt ( 0x22, ( intptr_t ) int22_wrapper, &int22_vector );
687
 }
687
 }

+ 1
- 1
src/arch/x86/transitions/librm_test.c View File

97
 	/* Profile complete real-mode call cycle */
97
 	/* Profile complete real-mode call cycle */
98
 	for ( i = 0 ; i < PROFILE_COUNT ; i++ ) {
98
 	for ( i = 0 ; i < PROFILE_COUNT ; i++ ) {
99
 		profile_start ( &real_call_profiler );
99
 		profile_start ( &real_call_profiler );
100
-		__asm__ __volatile__ ( REAL_CODE ( "" ) );
100
+		__asm__ __volatile__ ( REAL_CODE ( "" ) : );
101
 		profile_stop ( &real_call_profiler );
101
 		profile_stop ( &real_call_profiler );
102
 	}
102
 	}
103
 
103
 

Loading…
Cancel
Save