~sircmpwn/hare-linux

547815edea6a01e71b5350c0c205634c46d59c1e — Alexey Yerin 2 years ago 580df28
+libc: fix regressions caused by unique @init names

Since 7f428e7@harec[0], @init and @fini functions will have generated
names and as such not work when called directly, which is what
rt::start_linux on +libc did.

This also fixes a possible issue in os:: and linux::, which relied on
local @init names sorted alphabetically to call rt::start_linux. Not
all libc implementations might do so and cause unexpected problems.

[0]: https://git.sr.ht/~sircmpwn/harec/commit/7f428e7c869bef3d52d12ccdaf8d7002d4fae9e9
Fixes: https://todo.sr.ht/~sircmpwn/hare/566

Signed-off-by: Alexey Yerin <yyp@disroot.org>
2 files changed, 12 insertions(+), 5 deletions(-)

D +libc.ha
A start+libc.ha
D +libc.ha => +libc.ha +0 -5
@@ 1,5 0,0 @@
use rt;

@init fn ensure_rt_init() void = {
	rt::start_linux();
};

A start+libc.ha => start+libc.ha +12 -0
@@ 0,0 1,12 @@
use rt;
use format::elf;

@init fn init_linux() void = {
	rt::start_linux();

	let i = 0;
	for (rt::envp[i] != null) {
		i += 1;
	};
	auxv = &rt::envp[i + 1]: *[*]elf::auxv64;
};