ld.so: Stop leaking low heap to init functions

This commit is contained in:
K. Lange 2021-07-06 16:56:19 +09:00
parent 5ff17bea77
commit 0b3aef22f4

View File

@ -917,6 +917,12 @@ nope:
end_addr++;
}
/* Move heap start (kind of like a weird sbrk) */
{
char * args[] = {(char*)end_addr};
sysfunc(TOARU_SYS_FUNC_SETHEAP, args);
}
/* Call constructors for loaded dependencies */
char * ld_no_ctors = getenv("LD_DISABLE_CTORS");
if (ld_no_ctors && (!strcmp(ld_no_ctors,"1") || !strcmp(ld_no_ctors,"yes"))) {
@ -953,12 +959,6 @@ nope:
main_obj->loaded = 1;
/* Move heap start (kind of like a weird sbrk) */
{
char * args[] = {(char*)end_addr};
sysfunc(TOARU_SYS_FUNC_SETHEAP, args);
}
/* Set heap functions for later usage */
if (hashmap_has(dumb_symbol_table, "malloc")) _malloc = hashmap_get(dumb_symbol_table, "malloc");
if (hashmap_has(dumb_symbol_table, "free")) _free = hashmap_get(dumb_symbol_table, "free");