aboutsummaryrefslogtreecommitdiffstats
path: root/source/elf_load.cpp
diff options
context:
space:
mode:
authorClyne Sullivan <clyne@bitgloo.com>2020-08-29 19:58:08 -0400
committerClyne Sullivan <clyne@bitgloo.com>2020-08-29 19:58:08 -0400
commitd568f7ca9d7bf2d9dbf0b58d011ae8693ed6703e (patch)
tree0ea913ec1106c070b86d30a4db2b835baf7be4d3 /source/elf_load.cpp
parent09b2c79ed6320dc6541f1edf435a01b125fe0425 (diff)
improved elf loading
Diffstat (limited to 'source/elf_load.cpp')
-rw-r--r--source/elf_load.cpp24
1 files changed, 10 insertions, 14 deletions
diff --git a/source/elf_load.cpp b/source/elf_load.cpp
index 8149e8a..161bd7e 100644
--- a/source/elf_load.cpp
+++ b/source/elf_load.cpp
@@ -54,29 +54,25 @@ entry_t load(void *elf_data, void *elf_load_offset)
// [elf_load_offset](auto func) { (func + elf_load_offset)(); });
//}
- // Find filter code start
- if (auto filter = find_section(ehdr, ".process_data"); filter)
- return ptr_from_offset<entry_t>(elf_load_offset, filter->sh_addr | 1); // OR 1 to enable thumb
- else
- return nullptr;
+ return ptr_from_offset<entry_t>(elf_load_offset, ehdr->e_entry);
}
} // namespace elf
Elf32_Shdr *find_section(Elf32_Ehdr *ehdr, const char *name)
{
- auto shdr = ptr_from_offset<Elf32_Shdr *>(ehdr, ehdr->e_shoff);
- auto shdr_str = ptr_from_offset<Elf32_Shdr *>(ehdr,
+ auto shdr = ptr_from_offset<Elf32_Shdr *>(ehdr, ehdr->e_shoff);
+ auto shdr_str = ptr_from_offset<Elf32_Shdr *>(ehdr,
ehdr->e_shoff + ehdr->e_shstrndx * ehdr->e_shentsize);
- for (Elf32_Half i = 0; i < ehdr->e_shnum; i++) {
- char *section = ptr_from_offset<char *>(ehdr, shdr_str->sh_offset) + shdr->sh_name;
- if (!strcmp(section, name))
- return shdr;
+ for (Elf32_Half i = 0; i < ehdr->e_shnum; i++) {
+ char *section = ptr_from_offset<char *>(ehdr, shdr_str->sh_offset) + shdr->sh_name;
+ if (!strcmp(section, name))
+ return shdr;
- shdr = ptr_from_offset<Elf32_Shdr *>(shdr, ehdr->e_shentsize);
- }
+ shdr = ptr_from_offset<Elf32_Shdr *>(shdr, ehdr->e_shentsize);
+ }
- return 0;
+ return 0;
}