Created
December 11, 2022 06:21
-
-
Save daig/1c861826b3c9f1a7e477983c0d723737 to your computer and use it in GitHub Desktop.
Start file for freestanding c++
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://blogs.oracle.com/linux/post/hello-from-a-libc-free-world-part-1 | |
// entry code for compiling with `-nostdlib` : | |
// `gcc -nostdlib -c -fno-no-stack-protector -fno-exceptions -fno-asynchronous-unwind-tables hello.c` // compile without linking | |
// `gcc -nostdlib -c stubstart.S` // compile the entry code | |
// `ld stubstart.o hello.o -o hello` // link the entry code and the compiled code | |
.global _start //global entry point for the program. | |
_start: call main //enter the main function | |
movl $1, %eax // put 1, the syscall number for SYS_exit | |
xorl %ebx, %ebx // put 0, the exit code for success (argument to SYS_exit) | |
int $0x80 // call the kernel interrupt to exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment