mirror of
https://github.com/darlinghq/darling.git
synced 2024-11-27 22:30:36 +00:00
Call exported exit(). Fixes #240
This commit is contained in:
parent
c02625fbb2
commit
91b2ff74d0
@ -97,19 +97,24 @@ int main(int argc, char** argv, char** envp)
|
||||
NativeObject* obj;
|
||||
typedef int (mainPtr)(int argc, char** argv, char** envp);
|
||||
mainPtr* main;
|
||||
typedef void (exitPtr)(int status);
|
||||
exitPtr* target_exit;
|
||||
|
||||
obj = new NativeObject(argv[1]);
|
||||
obj->load();
|
||||
NativeObject::setMainObject(obj);
|
||||
|
||||
main = (mainPtr*) obj->getExportedSymbol("main", false);
|
||||
target_exit = (exitPtr*) obj->getExportedSymbol("exit", false);
|
||||
|
||||
if (!main)
|
||||
throw std::runtime_error("No entry point found in Darling-native executable");
|
||||
if (!target_exit)
|
||||
target_exit = exit;
|
||||
|
||||
if (pretendArgv0 != nullptr)
|
||||
argv[1] = (char*) pretendArgv0;
|
||||
exit(main(argc-1, &argv[1], envp));
|
||||
target_exit(main(argc-1, &argv[1], envp));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user