mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 14:35:07 +00:00
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. :^)
This commit is contained in:
parent
ab72666f48
commit
46ce47a984
3 changed files with 5 additions and 2 deletions
|
@ -155,6 +155,8 @@ public:
|
||||||
bool is_executable() const { return header().e_type == ET_EXEC; }
|
bool is_executable() const { return header().e_type == ET_EXEC; }
|
||||||
bool is_relocatable() const { return header().e_type == ET_REL; }
|
bool is_relocatable() const { return header().e_type == ET_REL; }
|
||||||
|
|
||||||
|
LinearAddress entry() const { return LinearAddress(header().e_entry); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool parseHeader();
|
bool parseHeader();
|
||||||
const char* raw_data(unsigned offset) const;
|
const char* raw_data(unsigned offset) const;
|
||||||
|
|
|
@ -17,6 +17,7 @@ public:
|
||||||
char* symbol_ptr(const char* name);
|
char* symbol_ptr(const char* name);
|
||||||
bool allocate_section(LinearAddress, size_t, size_t alignment, bool is_readable, bool is_writable);
|
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);
|
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:
|
private:
|
||||||
bool layout();
|
bool layout();
|
||||||
|
|
|
@ -344,7 +344,7 @@ int Process::do_exec(const String& path, Vector<String>&& arguments, Vector<Stri
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
entry_eip = (dword)loader.symbol_ptr("_start");
|
entry_eip = loader.entry().get();
|
||||||
if (!entry_eip) {
|
if (!entry_eip) {
|
||||||
m_page_directory = old_page_directory;
|
m_page_directory = old_page_directory;
|
||||||
MM.enter_process_paging_scope(*this);
|
MM.enter_process_paging_scope(*this);
|
||||||
|
@ -606,7 +606,7 @@ Process::Process(String&& name, uid_t uid, gid_t gid, pid_t ppid, RingLevel ring
|
||||||
if (!fork_parent->m_fds[i].descriptor)
|
if (!fork_parent->m_fds[i].descriptor)
|
||||||
continue;
|
continue;
|
||||||
#ifdef FORK_DEBUG
|
#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
|
#endif
|
||||||
m_fds[i].descriptor = fork_parent->m_fds[i].descriptor->clone();
|
m_fds[i].descriptor = fork_parent->m_fds[i].descriptor->clone();
|
||||||
m_fds[i].flags = fork_parent->m_fds[i].flags;
|
m_fds[i].flags = fork_parent->m_fds[i].flags;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue