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
 #
491
 #
492
 CFLAGS		+= -include include/compiler.h
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
 # CFLAGS for specific object types
499
 # CFLAGS for specific object types
495
 #
500
 #
496
 CFLAGS_c	+=
501
 CFLAGS_c	+=
896
 # Device ID tables (using IDs from ROM definition file)
901
 # Device ID tables (using IDs from ROM definition file)
897
 #
902
 #
898
 define obj_pci_id_asm
903
 define obj_pci_id_asm
899
-	.section ".pci_devlist.$(1)", "a", @progbits
904
+	.section ".pci_devlist.$(1)", "a", $(ASM_TCHAR)progbits
900
 	.globl pci_devlist_$(1)
905
 	.globl pci_devlist_$(1)
901
 pci_devlist_$(1):
906
 pci_devlist_$(1):
902
 	.short ( 0x$(1) & 0xffff )
907
 	.short ( 0x$(1) & 0xffff )

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

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

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

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

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

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

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

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

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

52
 /** Stringify expanded argument */
52
 /** Stringify expanded argument */
53
 #define _S2( x ) _S1 ( x )
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
  * @defgroup symmacros Macros to provide or require explicit symbols
67
  * @defgroup symmacros Macros to provide or require explicit symbols
57
  * @{
68
  * @{
64
  */
75
  */
65
 #ifdef ASSEMBLY
76
 #ifdef ASSEMBLY
66
 #define PROVIDE_SYMBOL( symbol )				\
77
 #define PROVIDE_SYMBOL( symbol )				\
67
-	.section ".provided", "a", @nobits ;			\
78
+	.section ".provided", "a", NOBITS ;			\
68
 	.hidden symbol ;					\
79
 	.hidden symbol ;					\
69
 	.globl	symbol ;					\
80
 	.globl	symbol ;					\
70
 	symbol: ;						\
81
 	symbol: ;						\
139
  */
150
  */
140
 #ifdef ASSEMBLY
151
 #ifdef ASSEMBLY
141
 #define PROVIDE_REQUIRING_SYMBOL()				\
152
 #define PROVIDE_REQUIRING_SYMBOL()				\
142
-	.section ".tbl.requiring_symbols", "a", @progbits ;	\
153
+	.section ".tbl.requiring_symbols", "a", PROGBITS ;	\
143
 	__requiring_symbol__:	.byte 0 ;			\
154
 	__requiring_symbol__:	.byte 0 ;			\
144
 	.size __requiring_symbol__, . - __requiring_symbol__ ;	\
155
 	.size __requiring_symbol__, . - __requiring_symbol__ ;	\
145
 	.previous
156
 	.previous
146
 #else
157
 #else
147
 #define PROVIDE_REQUIRING_SYMBOL()				\
158
 #define PROVIDE_REQUIRING_SYMBOL()				\
148
 	__asm__ ( ".section \".tbl.requiring_symbols\", "	\
159
 	__asm__ ( ".section \".tbl.requiring_symbols\", "	\
149
-		  "         \"a\", @progbits\n"			\
160
+		  "         \"a\", " PROGBITS "\n"		\
150
 		  "__requiring_symbol__:\t.byte 0\n"		\
161
 		  "__requiring_symbol__:\t.byte 0\n"		\
151
 		  ".size __requiring_symbol__, "		\
162
 		  ".size __requiring_symbol__, "		\
152
 		  "      . - __requiring_symbol__\n"		\
163
 		  "      . - __requiring_symbol__\n"		\

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

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

Loading…
Cancel
Save