diff --git a/.cvsignore b/.cvsignore index dd4485f..c7d2ec1 100644 --- a/.cvsignore +++ b/.cvsignore @@ -1 +1 @@ -ltrace_0.4.orig.tar.gz +ltrace-0.5.tar.gz diff --git a/ltrace-ppc32fc5.patch b/ltrace-ppc32fc5.patch new file mode 100644 index 0000000..25a688f --- /dev/null +++ b/ltrace-ppc32fc5.patch @@ -0,0 +1,198 @@ +Index: output.c +=================================================================== +--- output.c (revision 45) ++++ output.c (working copy) +@@ -170,7 +170,6 @@ void output_left(enum tof type, struct p + } + if (current_proc) { + fprintf(output, " \n"); +- current_proc = 0; + current_column = 0; + } + current_proc = proc; +Index: elf.c +=================================================================== +--- elf.c (revision 45) ++++ elf.c (working copy) +@@ -403,7 +403,7 @@ struct library_symbol *read_elf(struct p + add_library_symbol(addr, name, &library_symbols, + (PLTS_ARE_EXECUTABLE(lte) + ? LS_TOPLT_EXEC : LS_TOPLT_POINT), +- ELF64_ST_BIND(sym.st_info) != 0); ++ ELF64_ST_BIND(sym.st_info) == STB_WEAK); + if (!lib_tail) + lib_tail = &(library_symbols->next); + } +@@ -415,7 +415,7 @@ struct library_symbol *read_elf(struct p + already there. */ + main_cheat = (struct opt_x_t *)malloc(sizeof(struct opt_x_t)); + if (main_cheat == NULL) +- error(EXIT_FAILURE, 0, "Couldn allocate memory"); ++ error(EXIT_FAILURE, 0, "Couldn't allocate memory"); + main_cheat->next = opt_x; + main_cheat->found = 0; + main_cheat->name = PLTs_initialized_by_here; +@@ -464,7 +464,7 @@ struct library_symbol *read_elf(struct p + if (strcmp(xptr->name, PLTs_initialized_by_here) == 0) { + if (lte->ehdr.e_entry) { + add_library_symbol ( +- elf_plt2addr (lte, (void*)(long) ++ opd2addr (lte, (void*)(long) + lte->ehdr.e_entry), + PLTs_initialized_by_here, + lib_tail, 1, 0); +Index: sysdeps/linux-gnu/breakpoint.c +=================================================================== +--- sysdeps/linux-gnu/breakpoint.c (revision 45) ++++ sysdeps/linux-gnu/breakpoint.c (working copy) +@@ -9,6 +9,8 @@ + #include "output.h" + #include "debug.h" + ++#include ++ + static unsigned char break_insn[] = BREAKPOINT_VALUE; + + #ifdef ARCH_HAVE_ENABLE_BREAKPOINT +@@ -28,6 +30,10 @@ void enable_breakpoint(pid_t pid, struct + long a = + ptrace(PTRACE_PEEKTEXT, pid, sbp->addr + i * sizeof(long), + 0); ++ if (a == -1 && errno) { ++ perror ("ptrace"); ++ return; ++ } + for (j = 0; + j < sizeof(long) + && i * sizeof(long) + j < BREAKPOINT_LENGTH; j++) { +Index: sysdeps/linux-gnu/ppc/plt.c +=================================================================== +--- sysdeps/linux-gnu/ppc/plt.c (revision 45) ++++ sysdeps/linux-gnu/ppc/plt.c (working copy) +@@ -1,4 +1,5 @@ + #include ++#include + #include "ltrace.h" + #include "elf.h" + #include "debug.h" +@@ -15,8 +16,7 @@ void *sym2addr(struct process *proc, str + long addr = sym->enter_addr; + long pt_ret; + +- debug(3, 0); +- ++ debug(2, "sym2addr: sym=%s, pid=%d, enter_addr=%p", sym->name, proc->pid, addr); + if (sym->plt_type != LS_TOPLT_POINT) { + return addr; + } +@@ -46,6 +46,10 @@ void *sym2addr(struct process *proc, str + // break-point right in the PLT. + + pt_ret = ptrace(PTRACE_PEEKTEXT, proc->pid, addr, 0); ++ if (pt_ret == -1 && errno) { ++ perror ("ptrace"); ++ return 0; ++ } + + if (proc->mask_32bit) { + // Assume big-endian. +Index: sysdeps/linux-gnu/ppc/regs.c +=================================================================== +--- sysdeps/linux-gnu/ppc/regs.c (revision 45) ++++ sysdeps/linux-gnu/ppc/regs.c (working copy) +@@ -5,8 +5,10 @@ + #include + #include + #include ++#include + + #include "ltrace.h" ++#include "debug.h" + + #if (!defined(PTRACE_PEEKUSER) && defined(PTRACE_PEEKUSR)) + # define PTRACE_PEEKUSER PTRACE_PEEKUSR +@@ -35,6 +37,11 @@ void *get_stack_pointer(struct process * + + void *get_return_addr(struct process *proc, void *stack_pointer) + { +- return (void *)ptrace(PTRACE_PEEKUSER, proc->pid, sizeof(long) * PT_LNK, +- 0); ++ long p = ptrace(PTRACE_PEEKUSER, proc->pid, sizeof(long) * PT_LNK, NULL); ++ if (p == -1 && errno) { ++ perror ("ptrace"); ++ return NULL; ++ } ++ debug (3, "pid=%d ret=%p", proc->pid, p); ++ return (void*)p; + } +Index: sysdeps/linux-gnu/ppc/arch.h +=================================================================== +--- sysdeps/linux-gnu/ppc/arch.h (revision 45) ++++ sysdeps/linux-gnu/ppc/arch.h (working copy) +@@ -7,6 +7,7 @@ + #ifdef __powerpc64__ // Says 'ltrace' is 64 bits, says nothing about target. + #define LT_ELFCLASS2 ELFCLASS64 + #define LT_ELF_MACHINE2 EM_PPC64 ++#endif + + #define PLT_REINITALISATION_BP "_start" + +@@ -16,6 +17,3 @@ + #if (PPC_NOP_LENGTH != BREAKPOINT_LENGTH) + #error "Length of the breakpoint value not equal to the length of a nop instruction" + #endif +- +- +-#endif +Index: process_event.c +=================================================================== +--- process_event.c (revision 45) ++++ process_event.c (working copy) +@@ -263,7 +263,7 @@ static void process_breakpoint(struct ev + struct breakpoint *sbp, *nxtbp; + + debug(2, "event: breakpoint (%p)", event->e_un.brk_addr); +- if ((sbp = event->proc->breakpoint_being_enabled) != 0) { ++ if ((sbp = event->proc->breakpoint_being_enabled) != NULL) { + #ifdef __powerpc__ + char nop_inst[] = PPC_NOP; + if (memcmp(sbp->orig_value, nop_inst, PPC_NOP_LENGTH) == 0) { +@@ -344,8 +344,11 @@ static void process_breakpoint(struct ev + event->proc->stack_pointer = get_stack_pointer(event->proc); + event->proc->return_addr = + get_return_addr(event->proc, event->proc->stack_pointer); +- output_left(LT_TOF_FUNCTION, event->proc, sbp->libsym->name); +- callstack_push_symfunc(event->proc, sbp->libsym); ++ if (!sbp->libsym->is_weak || event->proc->return_addr == NULL) { ++ debug (2, "libsym name=%s", sbp->libsym->name); ++ output_left(LT_TOF_FUNCTION, event->proc, sbp->libsym->name); ++ callstack_push_symfunc(event->proc, sbp->libsym); ++ } + #ifdef PLT_REINITALISATION_BP + if (event->proc->need_to_reinitialize_breakpoints + && (strcmp(sbp->libsym->name, PLTs_initialized_by_here) == +Index: breakpoints.c +=================================================================== +--- breakpoints.c (revision 45) ++++ breakpoints.c (working copy) +@@ -28,6 +28,7 @@ insert_breakpoint(struct process *proc, + struct library_symbol *libsym) + { + struct breakpoint *sbp; ++ debug(1, "insert_breakpoint(symbol=%s, addr=%p)", libsym?libsym->name:"(nil)", addr); + + if (!proc->breakpoints) { + proc->breakpoints = +@@ -165,11 +166,9 @@ void breakpoints_init(struct process *pr + } else { + proc->list_of_symbols = NULL; + } +- sym = proc->list_of_symbols; +- while (sym) { ++ for (sym = proc->list_of_symbols; sym; sym = sym->next) { + /* proc->pid==0 delays enabling. */ + insert_breakpoint(proc, sym2addr(proc, sym), sym); +- sym = sym->next; + } + proc->callstack_depth = 0; + proc->breakpoints_enabled = -1; diff --git a/ltrace.spec b/ltrace.spec index 1ddfb79..bc17cde 100644 --- a/ltrace.spec +++ b/ltrace.spec @@ -1,16 +1,13 @@ Summary: Tracks runtime library calls from dynamically linked executables. Name: ltrace -Version: 0.4 -Release: 1.7.1 -Source: ftp://ftp.debian.org/debian/pool/main/l/ltrace/ltrace_%{version}.orig.tar.gz -Patch0: ltrace-opt_x.patch -Patch1: ltrace-testsuite.patch +Version: 0.5 +Release: 1.0.45svn +Source: ltrace-0.5.tar.gz Patch2: ltrace-opd.patch -Patch3: ltrace-demangle.patch -Patch4: ltrace-e_entry.patch +Patch3: ltrace-ppc32fc5.patch License: GPL Group: Development/Debuggers -ExclusiveArch: %{ix86} x86_64 ia64 ppc64 s390 s390x alpha sparc +ExclusiveArch: %{ix86} x86_64 ia64 ppc ppc64 s390 s390x alpha sparc Prefix: %{_prefix} Buildroot: %{_tmppath}/%{name}-root BuildRequires: elfutils-libelf-devel dejagnu @@ -27,11 +24,8 @@ execution of processes. %prep %setup -q -%patch0 -p0 -%patch1 -p0 %patch2 -p1 -%patch3 -p2 -%patch4 -p1 +%patch3 -p0 sed -i -e 's/-o root -g root//' Makefile.in %build @@ -58,6 +52,10 @@ rm -rf $RPM_BUILD_ROOT %config /etc/ltrace.conf %changelog +* Fri Jul 14 2006 Petr Machata - 0.5-1.0.45svn +- adding upstream (svn) version. It contains most of patches that we + already use, and has support for secure PLTs. + * Wed Jul 12 2006 Jesse Keating - 0.4-1.7.1 - rebuild diff --git a/sources b/sources index e050db1..3d9dd7a 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -8dbadad76ee360c2ed2caa915f5b1c8e ltrace_0.4.orig.tar.gz +9b96a0056e9ba88a54e938973bf83025 ltrace-0.5.tar.gz