Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Evergreen:11.1
ltrace
ltrace.trunk-r40.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File ltrace.trunk-r40.patch of Package ltrace
------------------------------------------------------------------------ r40 | pgilliam-guest | 2006-04-24 20:06:23 +0000 (Mon, 24 Apr 2006) | 30 lines Changed paths: M /ltrace/trunk/ChangeLog M /ltrace/trunk/elf.c M /ltrace/trunk/ltrace.1 M /ltrace/trunk/options.c M /ltrace/trunk/process_event.c M /ltrace/trunk/sysdeps/linux-gnu/alpha/arch.h M /ltrace/trunk/sysdeps/linux-gnu/arm/arch.h M /ltrace/trunk/sysdeps/linux-gnu/i386/arch.h M /ltrace/trunk/sysdeps/linux-gnu/ia64/arch.h M /ltrace/trunk/sysdeps/linux-gnu/m68k/arch.h M /ltrace/trunk/sysdeps/linux-gnu/ppc/arch.h M /ltrace/trunk/sysdeps/linux-gnu/s390/arch.h M /ltrace/trunk/sysdeps/linux-gnu/sparc/arch.h M /ltrace/trunk/sysdeps/linux-gnu/x86_64/arch.h Some versions of ltrace need to set a breakpoint at "_start", or somewhere, so that breakpoints can be set *after* the dynamic loader has run. By default, ltrace looks for "_start" in the symbol table. But if the target program has been stripped, there is no symbol table. This patch changes things so that if "_start" (or whatever the user specified using -X) could not be found, the value of "e_entry" in the elf header will be assumed to be that address. This patch *also* makes all the "_start" stuff conditional on PLT_REINITALISATION_BP. If an architecture doesn't need this stuff, then it doesn't define PLT_REINITALISATION_BP in it's "arch.h" file (which is copied to sysdep/linux-gnu/sysdep.h by configure). ------------------------------------------------------------------------ --- ChangeLog | 21 +++++++++++++++++++++ elf.c | 31 +++++++++++++++++++++++++++---- ltrace.1 | 3 ++- options.c | 13 +++++++++++-- process_event.c | 5 +++-- sysdeps/linux-gnu/alpha/arch.h | 3 --- sysdeps/linux-gnu/arm/arch.h | 3 --- sysdeps/linux-gnu/i386/arch.h | 3 --- sysdeps/linux-gnu/ia64/arch.h | 3 --- sysdeps/linux-gnu/m68k/arch.h | 3 --- sysdeps/linux-gnu/ppc/arch.h | 7 +------ sysdeps/linux-gnu/s390/arch.h | 3 --- sysdeps/linux-gnu/sparc/arch.h | 3 --- sysdeps/linux-gnu/x86_64/arch.h | 3 --- 14 files changed, 65 insertions(+), 39 deletions(-) Index: elf.c =================================================================== --- elf.c.orig +++ elf.c @@ -25,7 +25,9 @@ static void add_library_symbol(GElf_Addr static int in_load_libraries(const char *name, struct ltelf *lte); static GElf_Addr elf_plt2addr(struct ltelf *ltc, void *addr); +#ifdef PLT_REINITALISATION_BP extern char *PLTs_initialized_by_here; +#endif static void do_init_elf(struct ltelf *lte, const char *filename) { @@ -387,8 +389,10 @@ struct library_symbol *read_elf(struct p "Couldn't get relocation from \"%s\"", proc->filename); +#ifdef PLT_REINITALISATION_BP if (!sym.st_value && PLTs_initialized_by_here) proc->need_to_reinitialize_breakpoints = 1; +#endif name = lte->dynstr + sym.st_name; if (in_load_libraries(name, lte)) { @@ -400,12 +404,15 @@ struct library_symbol *read_elf(struct p } } +#ifdef PLT_REINITALISATION_BP if (proc->need_to_reinitialize_breakpoints) { - /* Add "PLTs_initialized_by_here" to opt_x list, if not already there. */ + /* Add "PLTs_initialized_by_here" to opt_x list, if not + 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"); main_cheat->next = opt_x; + main_cheat->found = 0; main_cheat->name = PLTs_initialized_by_here; for (xptr = opt_x; xptr; xptr = xptr->next) @@ -418,6 +425,7 @@ struct library_symbol *read_elf(struct p if (main_cheat) opt_x = main_cheat; } +#endif for (i = 0; i < lte->symtab_count; ++i) { GElf_Sym sym; @@ -448,13 +456,28 @@ struct library_symbol *read_elf(struct p for (xptr = opt_x; xptr; xptr = xptr->next) if ( ! xptr->found) { char *badthing = "WARNING"; - if (E_ENTRY_NAME && strcmp(xptr->name, E_ENTRY_NAME)) { +#ifdef PLT_REINITALISATION_BP + if (strcmp(xptr->name, PLTs_initialized_by_here) == 0) { + if (lte->ehdr.e_entry) { + add_library_symbol ( + elf_plt2addr (lte, (void*)(long) + lte->ehdr.e_entry), + PLTs_initialized_by_here, + lib_tail, 1, 0); + fprintf (stderr, "WARNING: Using e_ent" + "ry from elf header (%p) for " + "address of \"%s\"\n", (void*) + (long) lte->ehdr.e_entry, + PLTs_initialized_by_here); + continue; + } badthing = "ERROR"; exit_out = 1; } +#endif fprintf (stderr, - "%s: Couldn't find symbol \"%s\" in file \"%s\"\n", - badthing, xptr->name, proc->filename); + "%s: Couldn't find symbol \"%s\" in file \"%s" + "\"\n", badthing, xptr->name, proc->filename); } if (exit_out) { exit (1); Index: ChangeLog =================================================================== --- ChangeLog.orig +++ ChangeLog @@ -1,3 +1,24 @@ + 2006-04-24 Paul Gilliam <pgilliam@us.ibm.com> + + * elf.c: Use PLT_REINITALISATION_BP for those architectures that need + to re-initialize breakpoints after the dynamic linker has run. Also, + use value of "e_entry" for address of PLT_REINITALISATION_BP if the + target program has been stripped. + * ltrace.1: Note that fact that "-X" is only available on architectures + that need it. + * options.c: Use PLT_REINITALISATION_BP for those architectures that + need to re-initialize breakpoints after the dynamic linker has run. + * process_event.c: ditto. + * sysdeps/linux-gnu/ppc/arch.h: This is the only such architecture. + * sysdeps/linux-gnu/arm/arch.h: Delete use of PLT_REINITALISATION_BP. + * sysdeps/linux-gnu/m68k/arch.h: ditto. + * sysdeps/linux-gnu/alpha/arch.h: ditto. + * sysdeps/linux-gnu/i386/arch.h: ditto. + * sysdeps/linux-gnu/x86_64/arch.h: ditto. + * sysdeps/linux-gnu/s390/arch.h: ditto. + * sysdeps/linux-gnu/ia64/arch.h: ditto. + * sysdeps/linux-gnu/sparc/arch.h: ditto. + 2006-04-24 Paul Gilliam <pgilliam@us.ibm.com> * elf.c: Adds some casts to keep a more picky version of GCC happy. Index: sysdeps/linux-gnu/arm/arch.h =================================================================== --- sysdeps/linux-gnu/arm/arch.h.orig +++ sysdeps/linux-gnu/arm/arch.h @@ -4,6 +4,3 @@ #define LT_ELFCLASS ELFCLASS32 #define LT_ELF_MACHINE EM_ARM - -#define PLTs_INIT_BY_HERE NULL -#define E_ENTRY_NAME "_start" Index: sysdeps/linux-gnu/ppc/arch.h =================================================================== --- sysdeps/linux-gnu/ppc/arch.h.orig +++ sysdeps/linux-gnu/ppc/arch.h @@ -1,7 +1,6 @@ #define BREAKPOINT_VALUE { 0x7f, 0xe0, 0x00, 0x08 } #define BREAKPOINT_LENGTH 4 #define DECR_PC_AFTER_BREAK 0 -#define E_ENTRY_NAME "_start" #define LT_ELFCLASS ELFCLASS32 #define LT_ELF_MACHINE EM_PPC @@ -9,10 +8,6 @@ #define LT_ELFCLASS2 ELFCLASS64 #define LT_ELF_MACHINE2 EM_PPC64 -#define PLTs_INIT_BY_HERE E_ENTRY_NAME - -#else - -#define PLTs_INIT_BY_HERE NULL +#define PLT_REINITALISATION_BP "_start" #endif Index: sysdeps/linux-gnu/m68k/arch.h =================================================================== --- sysdeps/linux-gnu/m68k/arch.h.orig +++ sysdeps/linux-gnu/m68k/arch.h @@ -4,6 +4,3 @@ #define LT_ELFCLASS ELFCLASS32 #define LT_ELF_MACHINE EM_68K - -#define PLTs_INIT_BY_HERE NULL -#define E_ENTRY_NAME "_start" Index: sysdeps/linux-gnu/alpha/arch.h =================================================================== --- sysdeps/linux-gnu/alpha/arch.h.orig +++ sysdeps/linux-gnu/alpha/arch.h @@ -6,6 +6,3 @@ #define LT_ELF_MACHINE EM_ALPHA #define LT_ELFCLASS2 ELFCLASS64 #define LT_ELF_MACHINE2 EM_FAKE_ALPHA - -#define PLTs_INIT_BY_HERE NULL -#define E_ENTRY_NAME "_start" Index: sysdeps/linux-gnu/i386/arch.h =================================================================== --- sysdeps/linux-gnu/i386/arch.h.orig +++ sysdeps/linux-gnu/i386/arch.h @@ -4,6 +4,3 @@ #define LT_ELFCLASS ELFCLASS32 #define LT_ELF_MACHINE EM_386 - -#define PLTs_INIT_BY_HERE NULL -#define E_ENTRY_NAME "_start" Index: sysdeps/linux-gnu/x86_64/arch.h =================================================================== --- sysdeps/linux-gnu/x86_64/arch.h.orig +++ sysdeps/linux-gnu/x86_64/arch.h @@ -7,9 +7,6 @@ #define LT_ELFCLASS2 ELFCLASS32 #define LT_ELF_MACHINE2 EM_386 -#define PLTs_INIT_BY_HERE NULL -#define E_ENTRY_NAME "_start" - /* __NR_fork, __NR_clone, __NR_clone2, __NR_vfork and __NR_execve from asm-i386/unistd.h. */ #define FORK_EXEC_SYSCALLS , { 2, 120, -1, 190, 11 } Index: sysdeps/linux-gnu/s390/arch.h =================================================================== --- sysdeps/linux-gnu/s390/arch.h.orig +++ sysdeps/linux-gnu/s390/arch.h @@ -16,6 +16,3 @@ #define LT_ELFCLASS ELFCLASS32 #define LT_ELF_MACHINE EM_S390 #endif - -#define PLTs_INIT_BY_HERE NULL -#define E_ENTRY_NAME "_start" Index: sysdeps/linux-gnu/ia64/arch.h =================================================================== --- sysdeps/linux-gnu/ia64/arch.h.orig +++ sysdeps/linux-gnu/ia64/arch.h @@ -7,6 +7,3 @@ #define LT_ELFCLASS ELFCLASS64 #define LT_ELF_MACHINE EM_IA_64 - -#define PLTs_INIT_BY_HERE NULL -#define E_ENTRY_NAME "_start" Index: sysdeps/linux-gnu/sparc/arch.h =================================================================== --- sysdeps/linux-gnu/sparc/arch.h.orig +++ sysdeps/linux-gnu/sparc/arch.h @@ -6,6 +6,3 @@ #define LT_ELF_MACHINE EM_SPARC #define LT_ELFCLASS2 ELFCLASS32 #define LT_ELF_MACHINE2 EM_SPARC32PLUS - -#define PLTs_INIT_BY_HERE NULL -#define E_ENTRY_NAME "_start" Index: process_event.c =================================================================== --- process_event.c.orig +++ process_event.c @@ -332,11 +332,12 @@ static void process_breakpoint(struct ev 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 (PLTs_initialized_by_here - && event->proc->need_to_reinitialize_breakpoints +#ifdef PLT_REINITALISATION_BP + if (event->proc->need_to_reinitialize_breakpoints && (strcmp(sbp->libsym->name, PLTs_initialized_by_here) == 0)) reinitialize_breakpoints(event->proc); +#endif continue_after_breakpoint(event->proc, sbp); return; Index: ltrace.1 =================================================================== --- ltrace.1.orig +++ ltrace.1 @@ -132,7 +132,8 @@ Some architectures need to know where to after the dynamic linker has run. If this flag is used, then the breakpoint is set at .IR extern , -which must be an external function. By default, 'main' is used. +which must be an external function. By default, '_start' is used. +NOTE: this flag is only available on the architectures that need it. .TP .I \-x extern Trace the external function Index: options.c =================================================================== --- options.c.orig +++ options.c @@ -53,9 +53,11 @@ int opt_e_enable = 1; /* List of global function names given to -x: */ struct opt_x_t *opt_x = NULL; +#ifdef PLT_REINITALISATION_BP /* Set a break on the routine named here in order to re-initialize breakpoints after all the PLTs have been initialzed */ -char *PLTs_initialized_by_here = PLTs_INIT_BY_HERE; +char *PLTs_initialized_by_here = PLT_REINITALISATION_BP; +#endif static void usage(void) { @@ -120,8 +122,10 @@ static void usage(void) " -V output version information and exit.\n" # endif " -x NAME treat the global NAME like a library subroutine.\n" +#ifdef PLT_REINITALISATION_BP " -X NAME same as -x; and PLT's will be initialized by here.\n" - "\nReport bugs to Juan Cespedes <cespedes@debian.org>\n", +#endif + "\nReport bugs to ltrace-devel@lists.alioth.debian.org\n", progname); #endif } @@ -318,7 +322,12 @@ char **process_options(int argc, char ** "version 2 or later for copying conditions. There is NO warranty.\n"); exit(0); case 'X': +#ifdef PLT_REINITALISATION_BP PLTs_initialized_by_here = optarg; +#else + fprintf(stderr, "WANRING: \"-X\" not used for this " + "architecture: assuming you meant \"-x\"\n"); +#endif /* Fall Thru */ case 'x':
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor