summaryrefslogtreecommitdiffstats
path: root/libcorkscrew/symbol_table.c
diff options
context:
space:
mode:
Diffstat (limited to 'libcorkscrew/symbol_table.c')
-rw-r--r--libcorkscrew/symbol_table.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/libcorkscrew/symbol_table.c b/libcorkscrew/symbol_table.c
index 1b97180..29e4a79 100644
--- a/libcorkscrew/symbol_table.c
+++ b/libcorkscrew/symbol_table.c
@@ -19,14 +19,22 @@
#include <corkscrew/symbol_table.h>
+#include <stdbool.h>
#include <stdlib.h>
+#include <elf.h>
#include <fcntl.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/mman.h>
-#include <sys/exec_elf.h>
#include <cutils/log.h>
+static bool is_elf(Elf32_Ehdr* e) {
+ return (e->e_ident[EI_MAG0] == ELFMAG0 &&
+ e->e_ident[EI_MAG1] == ELFMAG1 &&
+ e->e_ident[EI_MAG2] == ELFMAG2 &&
+ e->e_ident[EI_MAG3] == ELFMAG3);
+}
+
// Compare function for qsort
static int qcompar(const void *a, const void *b) {
const symbol_t* asym = (const symbol_t*)a;
@@ -67,7 +75,7 @@ symbol_table_t* load_symbol_table(const char *filename) {
// Parse the file header
Elf32_Ehdr *hdr = (Elf32_Ehdr*)base;
- if (!IS_ELF(*hdr)) {
+ if (!is_elf(hdr)) {
goto out_close;
}
Elf32_Shdr *shdr = (Elf32_Shdr*)(base + hdr->e_shoff);