Home > database >  single back slash and double back slash in #define statement, and what is the starting .L for singal
single back slash and double back slash in #define statement, and what is the starting .L for singal

Time:02-17

This is a code from linux 5.4.21.

==== ./arch/arm64/include/asm/sysreg.h

#define __DEFINE_MRS_MSR_S_REGNUM               \
"   .irp    num,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30\n" \
"   .equ    .L__reg_num_x\\num, \\num\n"            \
"   .endr\n"                        \
"   .equ    .L__reg_num_xzr, 31\n"

In __DEFINE_MRS_MSR_S_REGNUM, I understand .irp and .equ directive. But why does it use \\num instead of \num? I guess it's for escaping before special characters because \ is a special character and the preprecessor makes it .L__reg_num_x\num, \num. But why is \n using single back-slash then? Is it specially processed during preprocessing?
And another question is : what is that .L in front of symbol name in .equ statements? Does it have any special meaning, or is it just to express it's a long value?

CodePudding user response:

.L is a file-local label, no visible in the symbol table. https://sourceware.org/binutils/docs/as/L.html.

As for the \num after the C preprocessor is done expanding it, again read the GAS manual: https://sourceware.org/binutils/docs/as/Irp.html .irp takes a parameter name to be expanded inside the macro. GAS macros in general use \name for .macro as well.

  • Related