[Ltrace-devel] r70 - in ltrace/trunk: . sysdeps/linux-gnu/ia64 sysdeps/linux-gnu/ppc

Petr Machata pmachata-guest at alioth.debian.org
Thu Nov 30 14:45:08 CET 2006


Author: pmachata-guest
Date: 2006-11-30 14:45:07 +0100 (Thu, 30 Nov 2006)
New Revision: 70

Modified:
   ltrace/trunk/ChangeLog
   ltrace/trunk/breakpoints.c
   ltrace/trunk/elf.c
   ltrace/trunk/sysdeps/linux-gnu/ia64/arch.h
   ltrace/trunk/sysdeps/linux-gnu/ppc/arch.h
Log:
* Patch to fix .opd handling on IA64.
* Few cleanups.


Modified: ltrace/trunk/ChangeLog
===================================================================
--- ltrace/trunk/ChangeLog	2006-10-12 21:53:44 UTC (rev 69)
+++ ltrace/trunk/ChangeLog	2006-11-30 13:45:07 UTC (rev 70)
@@ -1,3 +1,12 @@
+2006-11-30  Petr Machata  <pmachata at redhat.com>
+
+	* elf.c (in_load_libraries): removed unused variables
+	bitmask_idxbits and shift.
+	* elf.c (do_init_elf, opd2addr): use ARCH_SUPPORTS_OPD to
+	determine whether to load/use .opd section
+	* sysdeps/linux-gnu/*/arch.h: define ARCH_SUPPORTS_OPD accordingly
+	* breakpoints.c (insert_breakpoint): rewrite loop to canonical for
+
 2006-10-13  Olaf Hering <olh at suse.de>
 
 	* options.c: fix up typo for config file

Modified: ltrace/trunk/breakpoints.c
===================================================================
--- ltrace/trunk/breakpoints.c	2006-10-12 21:53:44 UTC (rev 69)
+++ ltrace/trunk/breakpoints.c	2006-11-30 13:45:07 UTC (rev 70)
@@ -28,6 +28,7 @@
 		  struct library_symbol *libsym)
 {
 	struct breakpoint *sbp;
+	debug(1, "symbol=%s, addr=%p", libsym?libsym->name:"(nil)", addr);
 
 	if (!proc->breakpoints) {
 		proc->breakpoints =
@@ -165,11 +166,9 @@
 	} 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;

Modified: ltrace/trunk/elf.c
===================================================================
--- ltrace/trunk/elf.c	2006-10-12 21:53:44 UTC (rev 69)
+++ ltrace/trunk/elf.c	2006-11-30 13:45:07 UTC (rev 70)
@@ -240,11 +240,14 @@
 				if (shdr.sh_flags & SHF_EXECINSTR) {
 					lte->lte_flags |= LTE_PLT_EXECUTABLE;
 				}
-			} else if (strcmp(name, ".opd") == 0) {
+			}
+#ifdef ARCH_SUPPORTS_OPD
+			else if (strcmp(name, ".opd") == 0) {
 				lte->opd_addr = (GElf_Addr *) (long) shdr.sh_addr;
 				lte->opd_size = shdr.sh_size;
 				lte->opd = elf_rawdata(scn, NULL);
 			}
+#endif
 		}
 	}
 
@@ -351,13 +354,12 @@
 			Elf32_Word nbuckets = *hashbase++;
 			Elf32_Word symbias = *hashbase++;
 			Elf32_Word bitmask_nwords = *hashbase++;
-			Elf32_Word bitmask_idxbits = bitmask_nwords - 1;
-			Elf32_Word shift = *hashbase++;
 			Elf32_Word * buckets;
 			Elf32_Word * chain_zero;
 			Elf32_Word bucket;
 
-			hashbase += lte[i].ehdr.e_ident[EI_CLASS] * bitmask_nwords;
+			// +1 for skipped `shift'
+			hashbase += lte[i].ehdr.e_ident[EI_CLASS] * bitmask_nwords + 1;
 			buckets = hashbase;
 			hashbase += nbuckets;
 			chain_zero = hashbase - symbias;
@@ -408,6 +410,7 @@
 
 static GElf_Addr opd2addr(struct ltelf *lte, GElf_Addr addr)
 {
+#ifdef ARCH_SUPPORTS_OPD
 	unsigned long base, offset;
 
 	if (!lte->opd)
@@ -419,6 +422,9 @@
 		error(EXIT_FAILURE, 0, "static plt not in .opd");
 
 	return *(GElf_Addr*)(base + offset);
+#else //!ARCH_SUPPORTS_OPD
+	return addr;
+#endif
 }
 
 struct library_symbol *read_elf(struct process *proc)

Modified: ltrace/trunk/sysdeps/linux-gnu/ia64/arch.h
===================================================================
--- ltrace/trunk/sysdeps/linux-gnu/ia64/arch.h	2006-10-12 21:53:44 UTC (rev 69)
+++ ltrace/trunk/sysdeps/linux-gnu/ia64/arch.h	2006-11-30 13:45:07 UTC (rev 70)
@@ -7,3 +7,7 @@
 
 #define LT_ELFCLASS   ELFCLASS64
 #define LT_ELF_MACHINE EM_IA_64
+
+// ia64 actually does use .opd, but we don't need to do the
+// translation manually.
+#undef ARCH_SUPPORTS_OPD

Modified: ltrace/trunk/sysdeps/linux-gnu/ppc/arch.h
===================================================================
--- ltrace/trunk/sysdeps/linux-gnu/ppc/arch.h	2006-10-12 21:53:44 UTC (rev 69)
+++ ltrace/trunk/sysdeps/linux-gnu/ppc/arch.h	2006-11-30 13:45:07 UTC (rev 70)
@@ -4,9 +4,11 @@
 
 #define LT_ELFCLASS	ELFCLASS32
 #define LT_ELF_MACHINE	EM_PPC
+
 #ifdef __powerpc64__ // Says 'ltrace' is 64 bits, says nothing about target.
 #define LT_ELFCLASS2	ELFCLASS64
 #define LT_ELF_MACHINE2	EM_PPC64
+#define ARCH_SUPPORTS_OPD
 #endif
 
 #define PLT_REINITALISATION_BP    "_start"




More information about the Ltrace-devel mailing list