[Ltrace-devel] r68 - ltrace/trunk
Ian Wienand
ianw-guest at costa.debian.org
Mon Sep 25 00:31:27 UTC 2006
Author: ianw-guest
Date: 2006-09-25 00:31:27 +0000 (Mon, 25 Sep 2006)
New Revision: 68
Modified:
ltrace/trunk/ChangeLog
ltrace/trunk/elf.c
ltrace/trunk/elf.h
Log:
little SHT_GNU_HASH fixups
Modified: ltrace/trunk/ChangeLog
===================================================================
--- ltrace/trunk/ChangeLog 2006-09-25 00:27:08 UTC (rev 67)
+++ ltrace/trunk/ChangeLog 2006-09-25 00:31:27 UTC (rev 68)
@@ -1,3 +1,9 @@
+2006-09-25 Olaf Hering <olh at 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 at gmail.com>
* display_args.c: store arg_num in arg_type_info
Modified: ltrace/trunk/elf.c
===================================================================
--- ltrace/trunk/elf.c 2006-09-25 00:27:08 UTC (rev 67)
+++ ltrace/trunk/elf.c 2006-09-25 00:31:27 UTC (rev 68)
@@ -211,18 +211,16 @@
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 @@
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 @@
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 @@
}
while ((*hasharr++ & 1u) == 0);
}
- } else
-#endif
- {
+ } else {
Elf32_Word nbuckets, symndx;
Elf32_Word *buckets, *chain;
nbuckets = lte[i].hash[0];
Modified: ltrace/trunk/elf.h
===================================================================
--- ltrace/trunk/elf.h 2006-09-25 00:27:08 UTC (rev 67)
+++ ltrace/trunk/elf.h 2006-09-25 00:31:27 UTC (rev 68)
@@ -40,4 +40,7 @@
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
More information about the Ltrace-devel
mailing list