Skip to content

Commit

Permalink
exec: Fix entrypoint address calculation.
Browse files Browse the repository at this point in the history
  • Loading branch information
wishstudio committed Feb 6, 2015
1 parent be5b5ee commit ff94dbf
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/syscall/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,12 @@ static void run(struct binfmt *binary, int argc, char *argv[], int env_size, cha
PTR(argc);

/* Call executable entrypoint */
size_t entrypoint = interpreter? interpreter->load_base + interpreter->eh.e_entry: executable->load_base + executable->eh.e_entry;
size_t entrypoint;
struct elf_header *start = interpreter? interpreter: executable;
if (start->eh.e_type == ET_DYN)
entrypoint = start->load_base + start->eh.e_entry;
else
entrypoint = start->eh.e_entry;
log_info("Entrypoint: %p\n", entrypoint);

/* TODO: The current way isn't bullet-proof
Expand Down

0 comments on commit ff94dbf

Please sign in to comment.