Browse Source

[librm] Provide symbols for inline code placed into other sections

Provide symbols constructed from the object name and line number for
code fragments placed into alternative sections, such as inline
REAL_CODE() assembly placed into .text16.  This simplifies the
debugging task of finding the source code corresponding to a given
instruction pointer.

Note that we cannot use __FUNCTION__ since it is not a preprocessor
macro and so cannot be concatenated with string literals.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 6 years ago
parent
commit
6149e0af3c
1 changed files with 5 additions and 0 deletions
  1. 5
    0
      src/arch/x86/include/librm.h

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

254
 #define CODE_DEFAULT ".code32"
254
 #define CODE_DEFAULT ".code32"
255
 #endif
255
 #endif
256
 
256
 
257
+/* LINE_SYMBOL: declare a symbol for the current source code line */
258
+#define LINE_SYMBOL _S2 ( OBJECT ) "__line_" _S2 ( __LINE__ ) ":"
259
+
257
 /* TEXT16_CODE: declare a fragment of code that resides in .text16 */
260
 /* TEXT16_CODE: declare a fragment of code that resides in .text16 */
258
 #define TEXT16_CODE( asm_code_str )			\
261
 #define TEXT16_CODE( asm_code_str )			\
259
 	".section \".text16\", \"ax\", @progbits\n\t"	\
262
 	".section \".text16\", \"ax\", @progbits\n\t"	\
263
+	"\n" LINE_SYMBOL "\n\t"				\
260
 	".code16\n\t"					\
264
 	".code16\n\t"					\
261
 	asm_code_str "\n\t"				\
265
 	asm_code_str "\n\t"				\
262
 	CODE_DEFAULT "\n\t"				\
266
 	CODE_DEFAULT "\n\t"				\
276
 	"push $1f\n\t"					\
280
 	"push $1f\n\t"					\
277
 	"call phys_call\n\t"				\
281
 	"call phys_call\n\t"				\
278
 	".section \".text.phys\", \"ax\", @progbits\n\t"\
282
 	".section \".text.phys\", \"ax\", @progbits\n\t"\
283
+	"\n" LINE_SYMBOL "\n\t"				\
279
 	".code32\n\t"					\
284
 	".code32\n\t"					\
280
 	"\n1:\n\t"					\
285
 	"\n1:\n\t"					\
281
 	asm_code_str					\
286
 	asm_code_str					\

Loading…
Cancel
Save