File ltrace.trunk-r68.patch of Package ltrace

------------------------------------------------------------------------
r68 | ianw-guest | 2006-09-25 00:31:27 +0000 (Mon, 25 Sep 2006) | 2 lines
Changed paths:
   M /ltrace/trunk/ChangeLog
   M /ltrace/trunk/elf.c
   M /ltrace/trunk/elf.h

little SHT_GNU_HASH fixups

------------------------------------------------------------------------
Index: elf.c
===================================================================
--- elf.c	(revision 67)
+++ elf.c	(revision 68)
@@ -211,18 +211,16 @@ static void do_init_elf(struct ltelf *lt
 				error(EXIT_FAILURE, 0,
 				      "Unknown .hash sh_entsize in \"%s\"",
 				      filename);
-#ifdef SHT_GNU_HASH
 		} else if (shdr.sh_type == SHT_GNU_HASH
 			   && lte->hash == NULL) {
 			Elf_Data *data;
-			size_t j;
 
 			lte->hash_type = SHT_GNU_HASH;
 
 			if (shdr.sh_entsize != 0
 			    && shdr.sh_entsize != 4) {
 				error(EXIT_FAILURE, 0,
-				      ".gnu.hash sh_entsize in \"%s\" should be 4, but is %d",
+				      ".gnu.hash sh_entsize in \"%s\" should be 4, but is %llu",
 				      filename, shdr.sh_entsize);
 			}
 
@@ -234,7 +232,6 @@ static void do_init_elf(struct ltelf *lt
 				      filename);
 
 			lte->hash = (Elf32_Word *) data->d_buf;
-#endif
 		} else if (shdr.sh_type == SHT_PROGBITS
 			   || shdr.sh_type == SHT_NOBITS) {
 			if (strcmp(name, ".plt") == 0) {
@@ -323,26 +320,32 @@ add_library_symbol(GElf_Addr addr, const
 	debug(2, "addr: %p, symbol: \"%s\"", (void *)(uintptr_t) addr, name);
 }
 
+/* stolen from elfutils-0.123 */
+static unsigned long elf_gnu_hash(const char *name)
+{
+	unsigned long h = 5381;
+	const unsigned char *string = (const unsigned char *)name;
+	unsigned char c;
+	for (c = *string; c; c = *++string)
+		h = h * 33 + c;
+	return h & 0xffffffff;
+}
+
 static int in_load_libraries(const char *name, struct ltelf *lte)
 {
 	size_t i;
 	unsigned long hash;
-#ifdef SHT_GNU_HASH
 	unsigned long gnu_hash;
-#endif
 
 	if (!library_num)
 		return 1;
 
 	hash = elf_hash((const unsigned char *)name);
-#ifdef SHT_GNU_HASH
-	gnu_hash = elf_gnu_hash((const unsigned char *)name);
-#endif
+	gnu_hash = elf_gnu_hash(name);
 	for (i = 1; i <= library_num; ++i) {
 		if (lte[i].hash == NULL)
 			continue;
 
-#ifdef SHT_GNU_HASH
 		if (lte[i].hash_type == SHT_GNU_HASH) {
 			Elf32_Word * hashbase = lte[i].hash;
 			Elf32_Word nbuckets = *hashbase++;
@@ -378,9 +381,7 @@ static int in_load_libraries(const char 
 					}
 				while ((*hasharr++ & 1u) == 0);
 			}
-		} else
-#endif
-		{
+		} else {
 			Elf32_Word nbuckets, symndx;
 			Elf32_Word *buckets, *chain;
 			nbuckets = lte[i].hash[0];
Index: elf.h
===================================================================
--- elf.h	(revision 67)
+++ elf.h	(revision 68)
@@ -40,4 +40,7 @@ extern struct library_symbol *read_elf(s
 
 extern GElf_Addr arch_plt_sym_val(struct ltelf *, size_t, GElf_Rela *);
 
+#ifndef SHT_GNU_HASH
+#define SHT_GNU_HASH	0x6ffffff6	/* GNU-style hash table. */
+#endif
 #endif
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 67)
+++ ChangeLog	(revision 68)
@@ -1,3 +1,9 @@
+2006-09-25  Olaf Hering <olh@suse.de>
+
+	* elf.c, elf.h : remove confilict with glibc SHT_GNU_HASH, include
+	elf_gnu_hash() directly, remove special casing and fix up output
+	specifier.
+
 2006-09-18    Steve Fink <sphink@gmail.com>
 
 	* display_args.c: store arg_num in arg_type_info
openSUSE Build Service is sponsored by