Last active
January 16, 2024 02:52
-
-
Save user21944/e978482f7822f4bce8c543372ca6048d to your computer and use it in GitHub Desktop.
small and efficient c startup code (crt0) and standard library, lightweight replacement for libc suitible for arch linux users around the world
This file contains 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
#ifndef CRT_H_ | |
#define CRT_H_ | |
/*int main(const int argc, const char* const argv[]);*/ | |
_Noreturn void main(void); | |
void* syscall3(void* arg1, void* arg2, void* arg3, int number); | |
#endif |
This file contains 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
.text | |
.global _start, syscall3 | |
_start: | |
xorl %ebp, %ebp | |
/* popq %rdi | |
* movq %rsp, %rsi */ | |
/* call main */ | |
jmp main | |
/* movl %eax, %edi | |
* movl $60, %eax | |
* syscall */ | |
syscall3: | |
movl %ecx, %eax | |
syscall | |
ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
x86_64 sysv abi document says that
rsp
is guaranteed to be 16-byte aligned at program startup, so there is no need to manually align it