1 backtrace.c: Fix word cast to a pointer
3 This patch fixes a compilation problem of Xorg + libunwind support when
4 building it on MIPS variants with 32-bit pointers.
8 http://lists.busybox.net/pipermail/buildroot/2014-December/114404.html
10 Patch submitted upstream:
12 http://lists.x.org/archives/xorg-devel/2015-January/045226.html
14 Patch reviewed by an Xorg developer:
16 http://lists.x.org/archives/xorg-devel/2015-January/045383.html
18 Signed-off-by: Vicente Olivert Riera <Vincent.Riera@imgtec.com>
20 From 84f04e0274661401a91efd4e9b21dccc1396e1d6 Mon Sep 17 00:00:00 2001
21 From: Vicente Olivert Riera <Vincent.Riera@imgtec.com>
22 Date: Wed, 3 Dec 2014 11:34:47 +0000
23 Subject: [PATCH] backtrace.c: Fix word cast to a pointer
25 backtrace.c uses a word size provided by libunwind. In some
26 architectures like MIPS, libunwind makes that word size 64-bit for all
27 variants of the architecture.
29 In the lines #90 and #98, backtrace.c tries to do a cast to a pointer,
30 which fails in all MIPS variants with 32-bit pointers, like MIPS32 or
31 MIPS64 n32, because it's trying to do a cast from a 64-bit wide variable
35 make[2]: Entering directory
36 `/home/test/test/1/output/build/xserver_xorg-server-1.15.1/os'
41 backtrace.c: In function 'xorg_backtrace':
42 backtrace.c:90:20: error: cast to pointer from integer of different size
43 [-Werror=int-to-pointer-cast]
44 if (dladdr((void *)(pip.start_ip + off), &dlinfo) &&
47 backtrace.c:98:13: error: cast to pointer from integer of different size
48 [-Werror=int-to-pointer-cast]
49 (void *)(pip.start_ip + off));
51 cc1: some warnings being treated as errors
52 make[2]: *** [backtrace.lo] Error 1
53 make[2]: *** Waiting for unfinished jobs....
55 Making the cast to a pointer-sized integer, and then to a pointer fixes
59 https://bugs.freedesktop.org/show_bug.cgi?id=79939
61 Signed-off-by: Vicente Olivert Riera <Vincent.Riera@imgtec.com>
63 os/backtrace.c | 4 ++--
64 1 files changed, 2 insertions(+), 2 deletions(-)
66 diff --git a/os/backtrace.c b/os/backtrace.c
67 index 3d1195b..fd129ef 100644
70 @@ -87,7 +87,7 @@ xorg_backtrace(void)
74 - if (dladdr((void *)(pip.start_ip + off), &dlinfo) && dlinfo.dli_fname &&
75 + if (dladdr((void *)(uintptr_t)(pip.start_ip + off), &dlinfo) && dlinfo.dli_fname &&
77 filename = dlinfo.dli_fname;
79 @@ -95,7 +95,7 @@ xorg_backtrace(void)
81 ErrorFSigSafe("%u: %s (%s%s+0x%x) [%p]\n", i++, filename, procname,
82 ret == -UNW_ENOMEM ? "..." : "", (int)off,
83 - (void *)(pip.start_ip + off));
84 + (void *)(uintptr_t)(pip.start_ip + off));
86 ret = unw_step(&cursor);