| 1 |
// SPDX-License-Identifier: MPL-2.0 |
| 2 |
// (c) Hare authors <https://harelang.org> |
| 3 |
|
| 4 |
@symbol(".main") fn main() void; |
| 5 |
@symbol("exit") fn c_exit(status: int) never; |
| 6 |
|
| 7 |
@symbol("__libc_init_array_start") const init_start: [*]*fn() void; |
| 8 |
@symbol("__libc_init_array_end") const init_end: [*]*fn() void; |
| 9 |
@symbol("__fini_array_start") const fini_start: [*]*fn() void; |
| 10 |
@symbol("__fini_array_end") const fini_end: [*]*fn() void; |
| 11 |
|
| 12 |
export @symbol("main") fn start_ha(c_argc: int, c_argv: *[*]*u8) never = { |
| 13 |
argc = c_argc: size; |
| 14 |
argv = c_argv; |
| 15 |
envp = c_envp; |
| 16 |
// we deliberately prevent libc from running @init for us, in order to |
| 17 |
// be able to initialize argc/argv/envp beforehand. we can still get |
| 18 |
// away with just using libc for @fini though |
| 19 |
init(); |
| 20 |
main(); |
| 21 |
c_exit(0); |
| 22 |
}; |
| 23 |
|
| 24 |
@symbol("environ") let c_envp: *[*]nullable *u8; |