On Sat, 05 Dec 2009 18:19:20 +0100, Roland McGrath wrote:
How about this?
--- step-into-handler.c 10 Dec 2008 04:42:43 -0800 1.8
+++ step-into-handler.c 05 Dec 2009 09:18:54 -0800
[...]
@@ -113,11 +114,11 @@ handler_alrm_get (void)
{
#if defined __powerpc64__
/* ppc64 `handler_alrm' resolves to the function descriptor. */
- return *(void **) handler_alrm;
+ return *(void **) (uintptr_t) handler_alrm;
/* __s390x__ defines both the symbols. */
#elif defined __s390__ !defined __s390x__
/* s390 bit 31 is zero here but I am not sure if it cannot be arbitrary.
*/
[...]
On Sat, 05 Dec 2009 18:39:05 +0100, CAI Qian wrote:
Thanks. Fixed.
I have to say it did not help for me (gcc-4.4.2-7.el6.ppc64).
error: dereferencing type-punned pointer will break strict-aliasing
rules
Checked-in the union-based fix below (both tests PASS on ppc64).
Regards,
Jan
--- erestartsys.c 27 Nov 2009 22:50:31 - 1.13
+++ erestartsys.c 14 Dec 2009 00:38:42 - 1.14
@@ -38,6 +38,7 @@
#include stddef.h
#include pty.h
#include string.h
+#include stdint.h
#if defined __x86_64__
# define REGISTER_IP .rip
@@ -298,8 +299,23 @@ main (int argc, char **argv)
user = user_orig;
user REGISTER_IP = (unsigned long) func;
#ifdef __powerpc64__
- user.nip = ((const unsigned long *) func)[0]; /* entry */
- user.gpr[2] = ((const unsigned long *) func)[1]; /* TOC */
+ {
+/* ppc64 `func' resolves to the function descriptor. */
+union
+ {
+ void (*f) (void);
+ struct
+ {
+ void *entry;
+ void *toc;
+ }
+ *p;
+ }
+const func_u = { func };
+
+user.nip = (uintptr_t) func_u.p-entry;
+user.gpr[2] = (uintptr_t) func_u.p-toc;
+ }
#endif
/* GDB amd64_linux_write_pc(): */
/* We must be careful with modifying the program counter. If we
--- step-into-handler.c 8 Dec 2008 18:23:41 - 1.8
+++ step-into-handler.c 14 Dec 2009 00:38:42 - 1.9
@@ -113,7 +113,19 @@ handler_alrm_get (void)
{
#if defined __powerpc64__
/* ppc64 `handler_alrm' resolves to the function descriptor. */
- return *(void **) handler_alrm;
+ union
+{
+ void (*f) (int signo);
+ struct
+ {
+ void *entry;
+ void *toc;
+ }
+ *p;
+}
+ const func_u = { handler_alrm };
+
+ return func_u.p-entry;
/* __s390x__ defines both the symbols. */
#elif defined __s390__ !defined __s390x__
/* s390 bit 31 is zero here but I am not sure if it cannot be arbitrary. */