File: start%2Blibc.ha

package info (click to toggle)
hare 0.26.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,352 kB
  • sloc: asm: 1,374; makefile: 123; sh: 117; lisp: 101
file content (24 lines) | stat: -rw-r--r-- 816 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// SPDX-License-Identifier: MPL-2.0
// (c) Hare authors <https://harelang.org>

@symbol(".main") fn main() void;
@symbol("exit") fn c_exit(status: int) never;

@symbol("__libc_init_array_start") const init_start: [*]*fn() void;
@symbol("__libc_init_array_end") const init_end: [*]*fn() void;
@symbol("__fini_array_start") const fini_start: [*]*fn() void;
@symbol("__fini_array_end") const fini_end: [*]*fn() void;

export @symbol("main") fn start_ha(c_argc: int, c_argv: *[*]*u8) never = {
	argc = c_argc: size;
	argv = c_argv;
	envp = c_envp;
	// we deliberately prevent libc from running @init for us, in order to
	// be able to initialize argc/argv/envp beforehand. we can still get
	// away with just using libc for @fini though
	init();
	main();
	c_exit(0);
};

@symbol("environ") let c_envp: *[*]nullable *u8;