hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit bb37ab76b7ed43cc6c67711453283c32aabe2e02
parent 92afe81232ffca34df036cc8d0712b3bad8fecee
Author: Ember Sawady <ecs@d2evs.net>
Date:   Wed,  6 Sep 2023 19:13:45 +0000

rt: run @fini functions in reverse order

they're topologically sorted in the binary, so running them in reverse
ensures that @finis for a module run before the ones for their
dependencies

Fixes: https://todo.sr.ht/~sircmpwn/hare/616
Signed-off-by: Ember Sawady <ecs@d2evs.net>

Diffstat:
Mrt/start+libc.ha | 4++--
Mrt/start+test+libc.ha | 4++--
Mrt/start+test.ha | 4++--
Mrt/start.ha | 4++--
4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/rt/start+libc.ha b/rt/start+libc.ha @@ -22,8 +22,8 @@ export fn init() void = { export fn fini() void = { const nfini = (&fini_end: uintptr - &fini_start: uintptr): size / size(*fn() void); - for (let i = 0z; i < nfini; i += 1) { - fini_start[i](); + for (let i = nfini; i > 0; i -= 1) { + fini_start[i - 1](); }; }; diff --git a/rt/start+test+libc.ha b/rt/start+test+libc.ha @@ -21,8 +21,8 @@ export fn init() void = { export fn fini() void = { const nfini = (&fini_end: uintptr - &fini_start: uintptr): size / size(*fn() void); - for (let i = 0z; i < nfini; i += 1) { - fini_start[i](); + for (let i = nfini; i > 0; i -= 1) { + fini_start[i - 1](); }; }; diff --git a/rt/start+test.ha b/rt/start+test.ha @@ -21,8 +21,8 @@ export fn init() void = { export fn fini() void = { const nfini = (&fini_end: uintptr - &fini_start: uintptr): size / size(*fn() void); - for (let i = 0z; i < nfini; i += 1) { - fini_start[i](); + for (let i = nfini; i > 0; i -= 1) { + fini_start[i - 1](); }; }; diff --git a/rt/start.ha b/rt/start.ha @@ -22,8 +22,8 @@ export fn init() void = { export fn fini() void = { const nfini = (&fini_end: uintptr - &fini_start: uintptr): size / size(*fn() void); - for (let i = 0z; i < nfini; i += 1) { - fini_start[i](); + for (let i = nfini; i > 0; i -= 1) { + fini_start[i - 1](); }; };