[Ltrace-devel] [PATCH v3] Tracing PLT-less MIPS binaries

Faraz Shahbazker faraz.shahbazker at imgtec.com
Tue Apr 28 15:56:34 UTC 2015


Hi Petr,

I've enclosed the little bit of final clean-up needed on top of pmachata/mips branch.

Could we please get the PLT-less fix merged on to master? Anything else I can pitch-in to speed this along? mips64 support is waiting on this.

Regards,
Faraz Shahbazker


---
 sysdeps/linux-gnu/mips/plt.c   |   13 ++++++-------
 sysdeps/linux-gnu/mips/trace.c |    2 +-
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/sysdeps/linux-gnu/mips/plt.c b/sysdeps/linux-gnu/mips/plt.c
index 500d208..c7c10ac 100644
--- a/sysdeps/linux-gnu/mips/plt.c
+++ b/sysdeps/linux-gnu/mips/plt.c
@@ -169,7 +169,6 @@ arch_plt_sym_val(struct ltelf *lte, size_t ndx, GElf_Rela *rela)
 void *
 sym2addr(struct process *proc, struct library_symbol *sym)
 {
-	fprintf(stderr, "sym %s addr %p\n", sym->name, sym->enter_addr);
         return sym->enter_addr;
 }
 
@@ -426,8 +425,8 @@ arch_elf_add_plt_entry(struct process *proc, struct ltelf *lte,
 	GElf_Addr got_entry_addr = rela->r_offset + lte->bias;
 	GElf_Addr stub_addr = rela->r_addend + lte->bias;
 
-	fprintf(stderr, "PLT-less arch_elf_add_plt_entry %s = %#llx\n",
-		a_name, stub_addr);
+	debug(2, "PLT-less arch_elf_add_plt_entry %s = %#llx\n",
+	      a_name, stub_addr);
 
 	struct library_symbol *libsym = NULL;
 	if (default_elf_add_plt_entry(proc, lte, a_name, rela, ndx,
@@ -437,7 +436,7 @@ arch_elf_add_plt_entry(struct process *proc, struct ltelf *lte,
 		goto fail;
 	}
 
-	fprintf(stderr, "%s unresolved\n", libsym->name);
+	debug(2, "%s unresolved\n", libsym->name);
 	libsym->arch.got_entry_addr = got_entry_addr;
 	libsym->arch.resolved_value = stub_addr;
 	libsym->arch.type = MIPS_PLT_UNRESOLVED;
@@ -563,7 +562,7 @@ cb_keep_stepping_p(struct process_stopping_handler *self)
 	 * the PLT entry value.  */
 	if (got_entry_value == libsym->arch.resolved_value)
 		return CBS_CONT;
-	fprintf(stderr, "%#" PRIx64 " resolved to %#" PRIx64 "\n",
+	debug(2, "%#" PRIx64 " resolved to %#" PRIx64 "\n",
 		libsym->arch.got_entry_addr, got_entry_value);
 
 	/* The GOT entry got resolved!  We can migrate the breakpoint
@@ -621,7 +620,7 @@ mips_stub_bp_continue(struct breakpoint *bp, struct process *proc)
 			(struct process_stopping_handler *);
 
 	case MIPS_PLT_RESOLVED:
-		fprintf(stderr, "hit resolved BP %s\n", bp->libsym->name);
+		debug(2, "hit resolved BP %s\n", bp->libsym->name);
 		jump_to_entry_point(proc, bp);
 		continue_process(proc->pid);
 		return;
@@ -698,7 +697,7 @@ arch_breakpoint_init(struct process *proc, struct breakpoint *bp)
 	    || bp->libsym->arch.type == MIPS_PLT_DEFAULT)
 		return 0;
 
-	fprintf(stderr, "new STUB breakpoint at %p\n", bp->addr);
+	debug(2, "new STUB breakpoint at %p\n", bp->addr);
 	static struct bp_callbacks cbs = {
 		.on_continue = mips_stub_bp_continue,
 		.on_retract = mips_stub_bp_retract,
diff --git a/sysdeps/linux-gnu/mips/trace.c b/sysdeps/linux-gnu/mips/trace.c
index 2a4fc7b..001f001 100644
--- a/sysdeps/linux-gnu/mips/trace.c
+++ b/sysdeps/linux-gnu/mips/trace.c
@@ -363,7 +363,7 @@ arch_sw_singlestep(struct process *proc, struct breakpoint *bp,
 		arch_addr_t baddr = (arch_addr_t) newpcs[nr];
 		/* Not sure what to do here. We've already got a bp?  */
 		if (DICT_HAS_KEY(proc->leader->breakpoints, &baddr)) {
-			fprintf(stderr, "skip %p %p\n", baddr, add_cb_data);
+			debug(2, "skip %p %p\n", baddr, add_cb_data);
 			continue;
 		}
 
-- 
1.7.9.5




More information about the Ltrace-devel mailing list