Skip to content

Commit

Permalink
elf: Fix statically linked executable entry point
Browse files Browse the repository at this point in the history
Statically linked executable may not have PT_INTERP present so we also
need to check for ET_EXEC object file type when looking up the entry
point.

Signed-off-by: Pekka Enberg <[email protected]>
  • Loading branch information
Pekka Enberg committed Nov 18, 2014
1 parent a2de1ca commit fa19f90
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions core/elf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <osv/stubbing.hh>
#include <sys/utsname.h>
#include <osv/demangle.hh>
#include "api/elf.h"

#include "arch.hh"

Expand Down Expand Up @@ -181,10 +182,10 @@ const char * object::symbol_name(const Elf64_Sym * sym) {
}

void* object::entry_point() const {
if (!_is_executable) {
return nullptr;
if (_is_executable || _ehdr.e_type == ET_EXEC) {
return _base + _ehdr.e_entry;
}
return _base + _ehdr.e_entry;
return nullptr;
}

file::file(program& prog, ::fileref f, std::string pathname)
Expand Down

0 comments on commit fa19f90

Please sign in to comment.