]> granicus.if.org Git - strace/commitdiff
Fix SA_HANDLER function pointer comparisons for hppa
authorCarlos O'Donell <carlos@systemhalted.org>
Wed, 9 Sep 2009 18:13:19 +0000 (18:13 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 5 Oct 2009 22:50:39 +0000 (22:50 +0000)
* signal.c (sys_sigaction): Cast SA_HANDLER function pointers to long.
(sys_rt_sigaction): Likewise.

signal.c

index b7db9463e37eab8ce6184903e9845d7b7062d2b3..4f3111a89e2d2be8ac42dd75a674958e1d7e9607 100644 (file)
--- a/signal.c
+++ b/signal.c
@@ -1121,11 +1121,19 @@ struct tcb *tcp;
        else if (umove(tcp, addr, &sa) < 0)
                tprintf("{...}");
        else {
-               if (sa.SA_HANDLER == SIG_ERR)
+               /* Architectures using function pointers, like
+                * hppa, may need to manipulate the function pointer
+                * to compute the result of a comparison. However,
+                * the SA_HANDLER function pointer exists only in
+                * the address space of the traced process, and can't
+                * be manipulated by strace. In order to prevent the
+                * compiler from generating code to manipulate
+                * SA_HANDLER we cast the function pointers to long. */
+               if ((long)sa.SA_HANDLER == (long)SIG_ERR)
                        tprintf("{SIG_ERR, ");
-               else if (sa.SA_HANDLER == SIG_DFL)
+               else if ((long)sa.SA_HANDLER == (long)SIG_DFL)
                        tprintf("{SIG_DFL, ");
-               else if (sa.SA_HANDLER == SIG_IGN) {
+               else if ((long)sa.SA_HANDLER == (long)SIG_IGN) {
 #ifndef USE_PROCFS
                        if (tcp->u_arg[0] == SIGTRAP) {
                                tcp->flags |= TCB_SIGTRAPPED;
@@ -1931,12 +1939,19 @@ sys_rt_sigaction(struct tcb *tcp)
                tprintf("{...}");
                goto after_sa;
        }
-
-       if (sa.__sa_handler == SIG_ERR)
+       /* Architectures using function pointers, like
+        * hppa, may need to manipulate the function pointer
+        * to compute the result of a comparison. However,
+        * the SA_HANDLER function pointer exists only in
+        * the address space of the traced process, and can't
+        * be manipulated by strace. In order to prevent the
+        * compiler from generating code to manipulate
+        * SA_HANDLER we cast the function pointers to long. */
+       if ((long)sa.__sa_handler == (long)SIG_ERR)
                tprintf("{SIG_ERR, ");
-       else if (sa.__sa_handler == SIG_DFL)
+       else if ((long)sa.__sa_handler == (long)SIG_DFL)
                tprintf("{SIG_DFL, ");
-       else if (sa.__sa_handler == SIG_IGN)
+       else if ((long)sa.__sa_handler == (long)SIG_IGN)
                tprintf("{SIG_IGN, ");
        else
                tprintf("{%#lx, ", (long) sa.__sa_handler);