Search notes:

include/linux/linkage.h

Assembler annotations (SYM_…)

SYM_FUNC_*

SYM_FUNC_* macros annotate functions with standard C calling conventions.
objtool can then ensure that such marked functions conform to the expected rules and annotate these functions with debugging information like ORC data automatically.

SYM_FUNC_ALIAS

SYM_FUNC_ALIAS defines a global alias for an existing function.
An example of SYM_FUNC_ALIAS being used is efi_stub_entry which is an alias for efi64_stub_entry (arch/x86/boot/compressed/head_64.S) and efi32_stub_entry (arch/x86/boot/compressed/head_32.S).
That is: if the kernel is built with CONFIG_X86_64, the alias efi_stub_entry is in fact efi64_stub_entry, if built with CONFIG_X86_32, the alias is in fact efi32_stub_entry.
Update: These aliases were removed with commit df9215f15 on 2023-08-07.

SYM_CODE_*

SYM_CODE_* annotes functions with a special stack, for example
  • interrupt handlers
  • trampolines
  • startup functions

SYM_DATA_*

SYM_DATA_* marks data in .data (not .text) sections so that the tools don't treat the bytes as instructions or assign debugging information to them.

See also

Documentation/core-api/asm-annotations.rst.

asmlinkage

asmlinkage is defined to be CPP_ASMLINKAGE:
#define asmlinkage CPP_ASMLINKAGE
asmlinkage is used (among others?) for syscall function prototypes and implementations (such as for example start_kernel).
CPP_ASMLINKAGE is defined to be nothing in the case C (and to be extern "C") in the case of C++:
#ifdef __cplusplus
#define CPP_ASMLINKAGE extern "C"
#else
#define CPP_ASMLINKAGE
#endif
I am really not sure if C++ is ever used when compiling the Kernel?
See also arch/x86/include/asm/linkage.h

Show how macros are resolved

The following shell command shows how uses of certain macros in linkage.h are resolved:
echo '
#include <linux/linkage.h>

SYM_FUNC_START(sym_func_start)
SYM_FUNC_START_NOALIGN(sym_func_start_noalign)
SYM_FUNC_START_LOCAL(sym_func_start_local)
SYM_FUNC_START_LOCAL_NOALIGN(sym_func_start_local_noalign)
SYM_FUNC_START_WEAK(sym_func_start_weak)
SYM_FUNC_START_WEAK_NOALIGN(sym_func_start_weak_noalign)

SYM_FUNC_ALIAS(sym_func_alias_alias, sym_func_alias_name)
SYM_FUNC_ALIAS_LOCAL(sym_func_alias_local_alias, sym_func_alias_local_name)

SYM_FUNC_END(sym_func_end)

--

SYM_CODE_START(sym_code_start)
SYM_CODE_START_LOCAL(sym_code_start_local)
SYM_CODE_END(sym_code_end)

--

SYM_DATA_START(sym_data_start)
SYM_DATA_END(sym_data_end)

--
SYM_INNER_LABEL(sym_inner_label, SYM_L_GLOBAL)

' | gcc -E -P -x c -                           \
    -nostdinc                                  \
   -I./arch/x86/include                        \
   -I./arch/x86/include/generated              \
   -I./include                                 \
   -I./arch/x86/include/uapi                   \
   -I./arch/x86/include/generated/uapi         \
   -I./include/uapi                            \
   -I./include/generated/uapi                  \
   -include ./include/linux/compiler-version.h \
   -include ./include/linux/kconfig.h          \
   -include ./include/linux/hidden.h           \
   -D__KERNEL__                                \
   -D__DISABLE_EXPORTS                         \
   -D__ASSEMBLY__   
When run, it prints
#pragma GCC visibility push(hidden)
.globl sym_func_start ; .balign 16, 0x90; ; sym_func_start:
.globl sym_func_start_noalign ; ; sym_func_start_noalign:
 ; .balign 16, 0x90; ; sym_func_start_local:
 ; ; sym_func_start_local_noalign:
.weak sym_func_start_weak ; .balign 16, 0x90; ; sym_func_start_weak:
.weak sym_func_start_weak_noalign ; ; sym_func_start_weak_noalign:
.globl sym_func_alias_alias ; .set sym_func_alias_alias, sym_func_alias_name ;
 ; .set sym_func_alias_local_alias, sym_func_alias_local_name ;
.type sym_func_end STT_FUNC ; .set .L__sym_size_sym_func_end, .-sym_func_end ; .size sym_func_end, .L__sym_size_sym_func_end
--
.globl sym_code_start ; .balign 16, 0x90; ; sym_code_start:
 ; .balign 16, 0x90; ; sym_code_start_local:
.type sym_code_end STT_NOTYPE ; .set .L__sym_size_sym_code_end, .-sym_code_end ; .size sym_code_end, .L__sym_size_sym_code_end
--
.globl sym_data_start ; ; sym_data_start:
.type sym_data_end STT_OBJECT ; .set .L__sym_size_sym_data_end, .-sym_data_end ; .size sym_data_end, .L__sym_size_sym_data_end
--
.type sym_inner_label STT_NOTYPE ; .globl sym_inner_label ; ; sym_inner_label:

Index