Check whether ABI is supported before we execute the binary
- this is fallout of the reorganization of open_program/execute_program.
I still think it makes better sense this wey, even though we need to
do the additional checking step now.
diff --git a/ltrace-elf.c b/ltrace-elf.c
index cc27e17..f24c2a1 100644
--- a/ltrace-elf.c
+++ b/ltrace-elf.c
@@ -136,18 +136,14 @@
}
int
-do_init_elf(struct ltelf *lte, const char *filename) {
- int i;
- GElf_Addr relplt_addr = 0;
- size_t relplt_size = 0;
-
- debug(DEBUG_FUNCTION, "do_init_elf(filename=%s)", filename);
- debug(1, "Reading ELF from %s...", filename);
-
+open_elf(struct ltelf *lte, const char *filename)
+{
lte->fd = open(filename, O_RDONLY);
if (lte->fd == -1)
return 1;
+ elf_version(EV_CURRENT);
+
#ifdef HAVE_ELF_C_READ_MMAP
lte->elf = elf_begin(lte->fd, ELF_C_READ_MMAP, NULL);
#else
@@ -180,6 +176,21 @@
error(EXIT_FAILURE, 0,
"\"%s\" is ELF from incompatible architecture", filename);
+ return 0;
+}
+
+int
+do_init_elf(struct ltelf *lte, const char *filename) {
+ int i;
+ GElf_Addr relplt_addr = 0;
+ size_t relplt_size = 0;
+
+ debug(DEBUG_FUNCTION, "do_init_elf(filename=%s)", filename);
+ debug(1, "Reading ELF from %s...", filename);
+
+ if (open_elf(lte, filename) < 0)
+ return -1;
+
Elf_Data *plt_data = NULL;
GElf_Addr ppcgot = 0;
@@ -621,8 +632,6 @@
library_num = 0;
proc->libdl_hooked = 0;
- elf_version(EV_CURRENT);
-
if (do_init_elf(lte, proc->filename))
return NULL;