These macros include _ init, _ initdata, _ initfunc (), asmlinkage, entry (), and fastcall. They are defined mainly in include \ Linux \ linkage. h and include \ asm-i386 \ init. h and some other. H files.
1) _ init location: Include \ asm-i386 \ init. h
Definition: # DEFINE _ init _ attribute _ (_ Section _ (". Text. init ")))
Note: This identifier is put together with the function declaration, indicating that the GCC compiler needs to put this function during compilation. text. init section, which is released after kernel initialization.
Example: asmlinkage void _ init start_kernel (void ){...}
2) _ initdata
Location: Include \ asm-i386 \ init. h
Definition: # DEFINE _ initdata _ attribute _ (_ Section _ (". Data. init ")))
Note: This identifier is put together with the variable declaration, indicating that the GCC compiler needs to place this variable during compilation. data. init section, which is released after kernel initialization.
Example: static struct kernel_param raw_params [] _ initdata = {....}
3) _ initfunc ()
Location: Include \ asm-i386 \ init. h
Definition: # DEFINE _ initfunc (_ arginit )\
_ Arginit _ Init ;\
_ Arginit
Note: This macro is used to define a _ init function.
Example: _ initfunc (void mem_init (unsigned long start_mem, unsigned long e
Nd_mem )){....}
4) asmlinkage
Location: Include \ Linux \ linkage. h
Definition: # define asmlinkage cpp_asmlinkage _ attribute _ (regparm (0 )))
Note: The flag is put together with the function declaration, which tells the GCC compiler that the function does not need to pass parameters through any registers. The parameters are only transmitted through stacks.
Example: asmlinkage void _ init start_kernel (void ){...}
5) entry ()
Location: Include \ Linux \ linkage. h
Definition: # define entry (name )\
. Globl symbol_name (name );\
Align ;\
Symbol_name_label (name)
Note: declare the name as global, alignment, and define it as a label.
Example: entry (swapper_pg_dir)
. Long 0x00102007
. Fill _ USER_PGD_PTRS-1
/* Default: 767 entries */
. Long 0x00102007
/* Default: 255 entries */
. Fill _ KERNEL_PGD_PTRS-1
Equivalent
. Globl swapper_pg_dir
. Align 16, 0x90
/* If iworkflow */
Swapper_pg_dir:
. Long 0x00102007
. Fill _ USER_PGD_PTRS-1
/* Default: 767 entries */
. Long 0x00102007
/* Default: 255 entries */
. Fill _ KERNEL_PGD_PTRS-1
6) fastcall ()
Location: Include \ Linux \ kernel. h
Definition: # define fastcall (x) X _ attribute _ (regparm (3 )))
Note: This identifier is put together with the function declaration. The attribute declaration with regparm (3) tells the GCC compiler that this function can pass up to three parameters through registers, the three registers are eax, EDX, and ECx in sequence. More parameters are passed through the stack. In this way, some inbound and outbound stack operations can be reduced, so calling is faster.
Example: extern void fastcall (_ switch_to (struct task_struct * Prev, struct t
Ask_struct * Next ));
In this example, Prev will pass through eax and next through edX
7) _ sched
Exists in the kernel/sched. h file
Attach to any functions which shoshould be ignored in wchan output
# DEFINE _ sched _ attribute _ (_ Section _ (". sched. Text ")))