aboutsummaryrefslogtreecommitdiff
path: root/ltrace-elf.c
diff options
context:
space:
mode:
authorPetr Machata <pmachata@redhat.com>2012-10-30 23:29:27 +0100
committerPetr Machata <pmachata@redhat.com>2012-10-30 23:29:27 +0100
commit1c79025768a4403e016cc59d7f41b266e868c9e6 (patch)
tree0938d8fe0ec0977171eeb6008aab5d154456bbe2 /ltrace-elf.c
parentc06f23d2803c7744f3d2cd1fb3e54886d9e41ddf (diff)
downloadltrace-1c79025768a4403e016cc59d7f41b266e868c9e6.tar.gz
Fix cross-tracing PIE binaries
Diffstat (limited to 'ltrace-elf.c')
-rw-r--r--ltrace-elf.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/ltrace-elf.c b/ltrace-elf.c
index ce7fd3d..bdb6220 100644
--- a/ltrace-elf.c
+++ b/ltrace-elf.c
@@ -814,6 +814,20 @@ read_module(struct library *lib, struct Process *proc,
if (open_elf(&lte, filename) < 0)
return -1;
+ /* XXX When we abstract ABI into a module, this should instead
+ * become something like
+ *
+ * proc->abi = arch_get_abi(lte.ehdr);
+ *
+ * The code in open_elf needs to be replaced by this logic.
+ * Be warned that libltrace.c calls open_elf as well to
+ * determine whether ABI is supported. This is to get
+ * reasonable error messages when trying to run 64-bit binary
+ * with 32-bit ltrace. It is desirable to preserve this. */
+ proc->e_machine = lte.ehdr.e_machine;
+ proc->e_class = lte.ehdr.e_ident[EI_CLASS];
+ get_arch_dep(proc);
+
/* Find out the base address. For PIE main binaries we look
* into auxv, otherwise we scan phdrs. */
if (main && lte.ehdr.e_type == ET_DYN) {
@@ -857,9 +871,6 @@ read_module(struct library *lib, struct Process *proc,
return -1;
}
- proc->e_machine = lte.ehdr.e_machine;
- proc->e_class = lte.ehdr.e_ident[EI_CLASS];
-
int status = 0;
if (lib == NULL)
goto fail;