ciabatta/src/linux/entry.c

30 lines
677 B
C
Raw Normal View History

2023-07-22 14:30:04 +00:00
2023-07-23 07:28:04 +00:00
static char stack_chk_fail_msg[] =
"Stack check failed. "
"You've got a stack corruption somewhere. "
"Sorry these guys didn't tell me where\n";
void __stack_chk_fail(void) {
syscall_write(STDERR_FILENO, stack_chk_fail_msg, sizeof stack_chk_fail_msg);
syscall_exit(1);
}
2023-07-22 14:30:04 +00:00
void __libc_start_main(
int (*main)(int, char**, char**),
int argc, char **argv,
int (*init)(int, char**, char**),
void (*fini)(void),
void (*dl_fini)(void),
2023-07-22 14:30:04 +00:00
void *stack_end
) {
// Get the envp
2023-07-22 16:28:16 +00:00
char **envp = argv + (argc + 1);
init(argc, argv, envp);
main(argc, argv, envp);
fini();
// glibc bug
dl_fini();
2023-07-22 14:30:04 +00:00
syscall_exit(0);
}