From a8601b4ac798a0be84fd8e541b8defba63f20e01 Mon Sep 17 00:00:00 2001 From: Liav A Date: Sat, 21 Oct 2023 13:17:20 +0300 Subject: [PATCH] DynamicLoader: Make heuristic for running directly actually correct When we run directly the dynamic loader, we shouldn't rely on the passed program path to be run, but rather on whether the main program fd number is not -1, because the kernel will set it to a non-negative number if it exists. To test that the heuristic is working correctly, the /usr/lib/Loader.so file can be copied to /tmp/Loader.so and then be invoked from that path. --- Userland/DynamicLoader/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/DynamicLoader/main.cpp b/Userland/DynamicLoader/main.cpp index 76865a7196..3d0d1a80ed 100644 --- a/Userland/DynamicLoader/main.cpp +++ b/Userland/DynamicLoader/main.cpp @@ -136,7 +136,7 @@ void _entry(int argc, char** argv, char** envp) } } - if (main_program_path == "/usr/lib/Loader.so"sv) { + if (main_program_fd == -1) { // We've been invoked directly as an executable rather than as the // ELF interpreter for some other binary. The second argv string should // be the path to the ELF executable, and if we don't have enough strings in argv