瀏覽代碼

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.
Liav A 1 年之前
父節點
當前提交
a8601b4ac7
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      Userland/DynamicLoader/main.cpp

+ 1 - 1
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
         // We've been invoked directly as an executable rather than as the
         // ELF interpreter for some other binary. The second argv string should
         // 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
         // be the path to the ELF executable, and if we don't have enough strings in argv