Fix build for x86_64
Some ELF-related variables differ depending on the native host, so
this patch uses conditional compilation tricks to ensure everything
works out on both 32- and 64-bit hosts.
Signed-off-by: Zachary T Welch <zwelch@codesourcery.com>
diff --git a/ltrace-elf.c b/ltrace-elf.c
index e3ef5c3..68cc67c 100644
--- a/ltrace-elf.c
+++ b/ltrace-elf.c
@@ -363,8 +363,9 @@
if (shdr.sh_entsize != 0
&& shdr.sh_entsize != 4) {
error(EXIT_FAILURE, 0,
- ".gnu.hash sh_entsize in \"%s\" should be 4, but is %llu",
- filename, shdr.sh_entsize);
+ ".gnu.hash sh_entsize in \"%s\" "
+ "should be 4, but is %#" PRIx64,
+ filename, shdr.sh_entsize);
}
data = loaddata(scn, &shdr);
diff --git a/ltrace-elf.h b/ltrace-elf.h
index 37f2a18..a29fe2c 100644
--- a/ltrace-elf.h
+++ b/ltrace-elf.h
@@ -51,4 +51,13 @@
#ifndef SHT_GNU_HASH
#define SHT_GNU_HASH 0x6ffffff6 /* GNU-style hash table. */
#endif
+
+#if __WORDSIZE == 32
+#define PRI_ELF_ADDR PRIx32
+#define GELF_ADDR_CAST(x) (void *)(uint32_t)(x)
+#else
+#define PRI_ELF_ADDR PRIx64
+#define GELF_ADDR_CAST(x) (void *)(x)
+#endif
+
#endif
diff --git a/sysdeps/linux-gnu/proc.c b/sysdeps/linux-gnu/proc.c
index 3c17e1f..4e7733d 100644
--- a/sysdeps/linux-gnu/proc.c
+++ b/sysdeps/linux-gnu/proc.c
@@ -112,7 +112,9 @@
}
if (callback) {
- debug(2, "Dispatching callback for: %s, Loaded at 0x%x\n", lib_name, rlm.l_addr);
+ debug(2, "Dispatching callback for: %s, "
+ "Loaded at 0x%" PRI_ELF_ADDR "\n",
+ lib_name, rlm.l_addr);
data->addr = rlm.l_addr;
data->lib_name = lib_name;
callback(data);
@@ -252,7 +254,7 @@
int
linkmap_init(Process *proc, struct ltelf *lte) {
- void *dbg_addr = NULL, *dyn_addr = (void *)(unsigned)lte->dyn_addr;
+ void *dbg_addr = NULL, *dyn_addr = GELF_ADDR_CAST(lte->dyn_addr);
struct r_debug *rdbg = NULL;
struct cb_data data;