[Ltrace-devel] [PATCH 2/2] Fix build for x86_64
Zachary T Welch
zwelch at codesourcery.com
Fri Dec 10 22:52:34 UTC 2010
Some ELF-related variables differ depending on the native host, so
this patch uses conditional compilation tricks to ensure everything
works out on each host.
Signed-off-by: Zachary T Welch <zwelch at codesourcery.com>
---
ltrace-elf.c | 10 ++++++++--
sysdeps/linux-gnu/proc.c | 16 ++++++++++++++--
2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/ltrace-elf.c b/ltrace-elf.c
index e3ef5c3..8592f03 100644
--- a/ltrace-elf.c
+++ b/ltrace-elf.c
@@ -363,8 +363,14 @@ do_init_elf(struct ltelf *lte, const char *filename) {
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 %#"
+#if __ELF_NATIVE_CLASS == 32
+ PRIx32
+#else
+ PRIx64
+#endif
+ , filename, shdr.sh_entsize);
}
data = loaddata(scn, &shdr);
diff --git a/sysdeps/linux-gnu/proc.c b/sysdeps/linux-gnu/proc.c
index 3c17e1f..136aff4 100644
--- a/sysdeps/linux-gnu/proc.c
+++ b/sysdeps/linux-gnu/proc.c
@@ -112,7 +112,13 @@ crawl_linkmap(Process *proc, struct r_debug *dbg, void (*callback)(void *), stru
}
if (callback) {
- debug(2, "Dispatching callback for: %s, Loaded at 0x%x\n", lib_name, rlm.l_addr);
+ debug(2, "Dispatching callback for: %s, "
+#if __ELF_NATIVE_CLASS == 32
+ "Loaded at 0x%" PRIx32 "\n",
+#else
+ "Loaded at 0x%" PRIx64 "\n",
+#endif
+ lib_name, rlm.l_addr);
data->addr = rlm.l_addr;
data->lib_name = lib_name;
callback(data);
@@ -252,7 +258,13 @@ hook_libdl_cb(void *data) {
int
linkmap_init(Process *proc, struct ltelf *lte) {
- void *dbg_addr = NULL, *dyn_addr = (void *)(unsigned)lte->dyn_addr;
+ void *dbg_addr = NULL;
+ void *dyn_addr =
+#if __ELF_NATIVE_CLASS == 32
+ (void *)(uint32_t)lte->dyn_addr;
+#else
+ (void *)(uint64_t)lte->dyn_addr;
+#endif
struct r_debug *rdbg = NULL;
struct cb_data data;
--
1.7.2.2
More information about the Ltrace-devel
mailing list