Skip to content

Commit

Permalink
Merge pull request #969 from 48cf/dlapi-entry-managarm-sysdep
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennisbonke authored Jan 24, 2024
2 parents b480939 + 941a021 commit 2f1f7d6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions sysdeps/managarm/generic/entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
void __mlibc_initLocale();

extern "C" uintptr_t *__dlapi_entrystack();
extern "C" void __dlapi_enter(uintptr_t *);

// declared in posix-pipe.hpp
thread_local Queue globalQueue;
Expand Down Expand Up @@ -124,8 +125,8 @@ LibraryGuard::LibraryGuard() {
__mlibc_stack_data.envp);
}

extern "C" void __mlibc_entry(int (*main_fn)(int argc, char *argv[], char *env[])) {
// TODO: call __dlapi_enter, otherwise static builds will break (see Linux sysdeps)
extern "C" void __mlibc_entry(uintptr_t *entry_stack, int (*main_fn)(int argc, char *argv[], char *env[])) {
__dlapi_enter(entry_stack);
auto result = main_fn(__mlibc_stack_data.argc, __mlibc_stack_data.argv, environ);
exit(result);
}
3 changes: 2 additions & 1 deletion sysdeps/managarm/x86_64/crt-src/Scrt1.S
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
.section .text
.global _start
_start:
lea main(%rip), %rdi
mov %rsp, %rdi
lea main(%rip), %rsi
call __mlibc_entry
.section .note.GNU-stack,"",%progbits

3 changes: 2 additions & 1 deletion sysdeps/managarm/x86_64/crt-src/crt0.S
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
.section .text
.global _start
_start:
mov $main, %rdi
mov %rsp, %rdi
mov $main, %rsi
call __mlibc_entry

.section .note.GNU-stack,"",%progbits
Expand Down

0 comments on commit 2f1f7d6

Please sign in to comment.