1,885
edits
Changes
Syscalls
,→Using the syscall macro definitions in asm code
The syscall macros can be used in a C program if that program is processed by the C preprocessor (cpp). The extension <code>,S</code> is used to designate an assembler source file that must be processed by cpp.
There are two ways to do thisfor a pure assembler source file:
1. Invoke cpp explicitly:
{{Admon/important|Initialization Code and Entry Point|When the assembler is invoked through gcc, C initialization code is inserted into the binary, which increases its size. This initialization will look for the entry point <code>main</code> instead of <code>_start</code>.}}
Using either of these approaches, you can use the <code>__NR_''xxxx''</code> macros in your assembler code:
#include <asm/unistd.h
...
mov $__NR_write,%rax