aboutsummaryrefslogtreecommitdiff
path: root/qtmips_machine/programloader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qtmips_machine/programloader.cpp')
-rw-r--r--qtmips_machine/programloader.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/qtmips_machine/programloader.cpp b/qtmips_machine/programloader.cpp
index 5a907c8..7722774 100644
--- a/qtmips_machine/programloader.cpp
+++ b/qtmips_machine/programloader.cpp
@@ -44,6 +44,7 @@
using namespace machine;
ProgramLoader::ProgramLoader(const char *file) {
+ const GElf_Ehdr *elf_ehdr;
// Initialize elf library
if (elf_version(EV_CURRENT) == EV_NONE)
throw QTMIPS_EXCEPTION(Input, "Elf library initialization failed", elf_errmsg(-1));
@@ -57,8 +58,10 @@ ProgramLoader::ProgramLoader(const char *file) {
if (elf_kind(this->elf) != ELF_K_ELF)
throw QTMIPS_EXCEPTION(Input, "Invalid input file elf format, plain elf file expected", "");
- if (!gelf_getehdr(this->elf, &this->hdr))
+ elf_ehdr = gelf_getehdr(this->elf, &this->hdr);
+ if (!elf_ehdr)
throw QTMIPS_EXCEPTION(Input, "Getting elf file header failed", elf_errmsg(-1));
+ executable_entry = elf_ehdr->e_entry;
// Check elf file format, executable expected, nothing else.
if (this->hdr.e_type != ET_EXEC)
throw QTMIPS_EXCEPTION(Input, "Invalid input file type", "");
@@ -119,3 +122,7 @@ std::uint32_t ProgramLoader::end() {
}
return last + 0x10; // We add offset so we are sure that also pipeline is empty
}
+
+std::uint32_t ProgramLoader::get_executable_entry() {
+ return executable_entry;
+}