diff options
author | Petr Machata <pmachata@redhat.com> | 2012-10-30 23:29:27 +0100 |
---|---|---|
committer | Petr Machata <pmachata@redhat.com> | 2012-10-30 23:29:27 +0100 |
commit | 1c79025768a4403e016cc59d7f41b266e868c9e6 (patch) | |
tree | 0938d8fe0ec0977171eeb6008aab5d154456bbe2 | |
parent | c06f23d2803c7744f3d2cd1fb3e54886d9e41ddf (diff) | |
download | ltrace-1c79025768a4403e016cc59d7f41b266e868c9e6.tar.gz |
Fix cross-tracing PIE binaries
-rw-r--r-- | breakpoints.c | 5 | ||||
-rw-r--r-- | ltrace-elf.c | 17 |
2 files changed, 17 insertions, 5 deletions
diff --git a/breakpoints.c b/breakpoints.c index d77fefc..258be93 100644 --- a/breakpoints.c +++ b/breakpoints.c @@ -346,8 +346,9 @@ entry_breakpoint_init(struct Process *proc, struct entry_breakpoint *bp, arch_addr_t addr, struct library *lib) { - int err; - if ((err = breakpoint_init(&bp->super, proc, addr, NULL)) < 0) + assert(addr != 0); + int err = breakpoint_init(&bp->super, proc, addr, NULL); + if (err < 0) return err; static struct bp_callbacks entry_callbacks = { 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(<e, 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; |