Browse Source

[build] Allow assembler section type character to vary by architecture

On some architectures (such as ARM) the "@" character is used as a
comment delimiter.  A section type argument such as "@progbits"
therefore becomes "%progbits".

This is further complicated by the fact that the "%" character has
special meaning for inline assembly when input or output operands are
used, in which cases "@progbits" becomes "%%progbits".

Allow the section type character(s) to be defined via Makefile
variables.

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

+ 6
- 1
src/Makefile.housekeeping View File

@@ -491,6 +491,11 @@ LDFLAGS		+= -static
491 491
 #
492 492
 CFLAGS		+= -include include/compiler.h
493 493
 
494
+# The section type character (e.g. "@" in "@progbits") varies by
495
+# architecture.
496
+#
497
+CFLAGS		+= -DASM_TCHAR='$(ASM_TCHAR)' -DASM_TCHAR_OPS='$(ASM_TCHAR_OPS)'
498
+
494 499
 # CFLAGS for specific object types
495 500
 #
496 501
 CFLAGS_c	+=
@@ -896,7 +901,7 @@ endif
896 901
 # Device ID tables (using IDs from ROM definition file)
897 902
 #
898 903
 define obj_pci_id_asm
899
-	.section ".pci_devlist.$(1)", "a", @progbits
904
+	.section ".pci_devlist.$(1)", "a", $(ASM_TCHAR)progbits
900 905
 	.globl pci_devlist_$(1)
901 906
 pci_devlist_$(1):
902 907
 	.short ( 0x$(1) & 0xffff )

+ 5
- 0
src/arch/x86/Makefile View File

@@ -1,3 +1,8 @@
1
+# Assembler section type character
2
+#
3
+ASM_TCHAR	:= @
4
+ASM_TCHAR_OPS	:= @
5
+
1 6
 # Include common x86 headers
2 7
 #
3 8
 INCDIRS		+= arch/x86/include

+ 1
- 1
src/crypto/certstore.c View File

@@ -45,7 +45,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
45 45
 #define CERT( _index, _path )						\
46 46
 	extern char stored_cert_ ## _index ## _data[];			\
47 47
 	extern char stored_cert_ ## _index ## _len[];			\
48
-	__asm__ ( ".section \".rodata\", \"a\", @progbits\n\t"		\
48
+	__asm__ ( ".section \".rodata\", \"a\", " PROGBITS "\n\t"	\
49 49
 		  "\nstored_cert_" #_index "_data:\n\t"			\
50 50
 		  ".incbin \"" _path "\"\n\t"				\
51 51
 		  "\nstored_cert_" #_index "_end:\n\t"			\

+ 1
- 1
src/crypto/privkey.c View File

@@ -54,7 +54,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
54 54
 /* Raw private key data */
55 55
 extern char private_key_data[];
56 56
 extern char private_key_len[];
57
-__asm__ ( ".section \".rodata\", \"a\", @progbits\n\t"
57
+__asm__ ( ".section \".rodata\", \"a\", " PROGBITS "\n\t"
58 58
 	  "\nprivate_key_data:\n\t"
59 59
 #ifdef PRIVATE_KEY
60 60
 	  ".incbin \"" PRIVATE_KEY "\"\n\t"

+ 1
- 1
src/image/embedded.c View File

@@ -18,7 +18,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
18 18
 #define EMBED( _index, _path, _name )					\
19 19
 	extern char embedded_image_ ## _index ## _data[];		\
20 20
 	extern char embedded_image_ ## _index ## _len[];		\
21
-	__asm__ ( ".section \".rodata\", \"a\", @progbits\n\t"		\
21
+	__asm__ ( ".section \".rodata\", \"a\", " PROGBITS "\n\t"	\
22 22
 		  "\nembedded_image_" #_index "_data:\n\t"		\
23 23
 		  ".incbin \"" _path "\"\n\t"				\
24 24
 		  "\nembedded_image_" #_index "_end:\n\t"		\

+ 14
- 3
src/include/compiler.h View File

@@ -52,6 +52,17 @@
52 52
 /** Stringify expanded argument */
53 53
 #define _S2( x ) _S1 ( x )
54 54
 
55
+/* Assembler section types */
56
+#ifdef ASSEMBLY
57
+#define PROGBITS _C2 ( ASM_TCHAR, progbits )
58
+#define NOBITS _C2 ( ASM_TCHAR, nobits )
59
+#else
60
+#define PROGBITS_OPS _S2 ( ASM_TCHAR_OPS ) "progbits"
61
+#define PROGBITS _S2 ( ASM_TCHAR ) "progbits"
62
+#define NOBITS_OPS _S2 ( ASM_TCHAR_OPS ) "nobits"
63
+#define NOBITS _S2 ( ASM_TCHAR ) "nobits"
64
+#endif
65
+
55 66
 /**
56 67
  * @defgroup symmacros Macros to provide or require explicit symbols
57 68
  * @{
@@ -64,7 +75,7 @@
64 75
  */
65 76
 #ifdef ASSEMBLY
66 77
 #define PROVIDE_SYMBOL( symbol )				\
67
-	.section ".provided", "a", @nobits ;			\
78
+	.section ".provided", "a", NOBITS ;			\
68 79
 	.hidden symbol ;					\
69 80
 	.globl	symbol ;					\
70 81
 	symbol: ;						\
@@ -139,14 +150,14 @@
139 150
  */
140 151
 #ifdef ASSEMBLY
141 152
 #define PROVIDE_REQUIRING_SYMBOL()				\
142
-	.section ".tbl.requiring_symbols", "a", @progbits ;	\
153
+	.section ".tbl.requiring_symbols", "a", PROGBITS ;	\
143 154
 	__requiring_symbol__:	.byte 0 ;			\
144 155
 	.size __requiring_symbol__, . - __requiring_symbol__ ;	\
145 156
 	.previous
146 157
 #else
147 158
 #define PROVIDE_REQUIRING_SYMBOL()				\
148 159
 	__asm__ ( ".section \".tbl.requiring_symbols\", "	\
149
-		  "         \"a\", @progbits\n"			\
160
+		  "         \"a\", " PROGBITS "\n"		\
150 161
 		  "__requiring_symbol__:\t.byte 0\n"		\
151 162
 		  ".size __requiring_symbol__, "		\
152 163
 		  "      . - __requiring_symbol__\n"		\

+ 1
- 1
src/include/errno.h View File

@@ -258,7 +258,7 @@ static inline void eplatform_discard ( int dummy __unused, ... ) {}
258 258
  * @ret error		Error
259 259
  */
260 260
 #define __einfo_error( einfo ) ( {					\
261
-	__asm__ ( ".section \".einfo\", \"\", @progbits\n\t"		\
261
+	__asm__ ( ".section \".einfo\", \"\", " PROGBITS_OPS "\n\t"	\
262 262
 		  ".align 8\n\t"					\
263 263
 		  "\n1:\n\t"						\
264 264
 		  ".long ( 4f - 1b )\n\t"				\

Loading…
Cancel
Save