From 46ce47a98460cc5dba0cbfabce97cdd45f591021 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 29 Dec 2018 03:28:55 +0100 Subject: [PATCH] Use the entry point address from the ELF header instead of looking up _start. I love these kind of dumb gotcha moments. Turns out you can find the entry address right there in the header. :^) --- Kernel/ELFImage.h | 2 ++ Kernel/ELFLoader.h | 1 + Kernel/Process.cpp | 4 ++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Kernel/ELFImage.h b/Kernel/ELFImage.h index a4decc0ab35..5df7d939e81 100644 --- a/Kernel/ELFImage.h +++ b/Kernel/ELFImage.h @@ -155,6 +155,8 @@ public: bool is_executable() const { return header().e_type == ET_EXEC; } bool is_relocatable() const { return header().e_type == ET_REL; } + LinearAddress entry() const { return LinearAddress(header().e_entry); } + private: bool parseHeader(); const char* raw_data(unsigned offset) const; diff --git a/Kernel/ELFLoader.h b/Kernel/ELFLoader.h index b364ce7299c..8ae46280833 100644 --- a/Kernel/ELFLoader.h +++ b/Kernel/ELFLoader.h @@ -17,6 +17,7 @@ public: char* symbol_ptr(const char* name); bool allocate_section(LinearAddress, size_t, size_t alignment, bool is_readable, bool is_writable); bool map_section(LinearAddress, size_t, size_t alignment, size_t offset_in_image, bool is_readable, bool is_writable); + LinearAddress entry() const { return m_image.entry(); } private: bool layout(); diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index d904cf2d685..c5671e4435a 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -344,7 +344,7 @@ int Process::do_exec(const String& path, Vector&& arguments, Vectorm_fds[i].descriptor) continue; #ifdef FORK_DEBUG - dbgprintf("fork: cloning fd %u... (%p) istty? %u\n", i, fork_parent->m_fds[i].ptr(), fork_parent->m_fds[i]->isTTY()); + dbgprintf("fork: cloning fd %u... (%p) istty? %u\n", i, fork_parent->m_fds[i].descriptor.ptr(), fork_parent->m_fds[i].descriptor->is_tty()); #endif m_fds[i].descriptor = fork_parent->m_fds[i].descriptor->clone(); m_fds[i].flags = fork_parent->m_fds[i].flags;