2023-07-22 14:30:04 +00:00
|
|
|
|
2023-07-22 15:23:39 +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 15:23:39 +00:00
|
|
|
}
|
|
|
|
|
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),
|
2023-07-23 07:19:53 +00:00
|
|
|
void (*dl_fini)(void),
|
2023-07-22 14:30:04 +00:00
|
|
|
void *stack_end
|
|
|
|
) {
|
2023-07-23 07:19:53 +00:00
|
|
|
// 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();
|
2023-07-23 07:19:53 +00:00
|
|
|
// glibc bug
|
|
|
|
dl_fini();
|
2023-07-22 14:30:04 +00:00
|
|
|
syscall_exit(0);
|
|
|
|
}
|