/* SPDX-License-Identifier: LGPL-2.1 OR MIT */ /* * x86 specific definitions for NOLIBC (both 32- and 64-bit) * Copyright (C) 2017-2025 Willy Tarreau <w@1wt.eu>
*/
/* Syscalls for i386 : * - mostly similar to x86_64 * - registers are 32-bit * - syscall number is passed in eax * - arguments are in ebx, ecx, edx, esi, edi, ebp respectively * - all registers are preserved (except eax of course) * - the system call is performed by calling int $0x80 * - syscall return comes in eax * - the arguments are cast to long and assigned into the target registers * which are then simply passed as registers to the asm code, so that we * don't have to experience issues with register constraints. * - the syscall number is always specified last in order to allow to force * some registers before (gcc refuses a %-register at the last position). * * Also, i386 supports the old_select syscall if newselect is not available
*/ #define __ARCH_WANT_SYS_OLD_SELECT
/* startup code */ /* * i386 System V ABI mandates: * 1) last pushed argument must be 16-byte aligned. * 2) The deepest stack frame should be set to zero *
*/ void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protector _start(void)
{
__asm__ volatile ( "xor %ebp, %ebp\n"/* zero the stack frame */ "mov %esp, %eax\n"/* save stack pointer to %eax, as arg1 of _start_c */ "sub $12, %esp\n"/* sub 12 to keep it aligned after the push %eax */ "push %eax\n"/* push arg1 on stack to support plain stack modes too */ "call _start_c\n"/* transfer to c runtime */ "hlt\n"/* ensure it does not return */
);
__nolibc_entrypoint_epilogue();
}
#else/* !defined(__x86_64__) */
/* Syscalls for x86_64 : * - registers are 64-bit * - syscall number is passed in rax * - arguments are in rdi, rsi, rdx, r10, r8, r9 respectively * - the system call is performed by calling the syscall instruction * - syscall return comes in rax * - rcx and r11 are clobbered, others are preserved. * - the arguments are cast to long and assigned into the target registers * which are then simply passed as registers to the asm code, so that we * don't have to experience issues with register constraints. * - the syscall number is always specified last in order to allow to force * some registers before (gcc refuses a %-register at the last position). * - see also x86-64 ABI section A.2 AMD64 Linux Kernel Conventions, A.2.1 * Calling Conventions. * * Link x86-64 ABI: https://gitlab.com/x86-psABIs/x86-64-ABI/-/wikis/home *
*/
/* startup code */ /* * x86-64 System V ABI mandates: * 1) %rsp must be 16-byte aligned right before the function call. * 2) The deepest stack frame should be zero (the %rbp). *
*/ void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protector _start(void)
{
__asm__ volatile ( "xor %ebp, %ebp\n"/* zero the stack frame */ "mov %rsp, %rdi\n"/* save stack pointer to %rdi, as arg1 of _start_c */ "call _start_c\n"/* transfer to c runtime */ "hlt\n"/* ensure it does not return */
);
__nolibc_entrypoint_epilogue();
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.