Module Name:    src
Committed By:   rin
Date:           Mon Nov 18 12:06:26 UTC 2019

Modified Files:
        src/sys/compat/netbsd32: netbsd32.h
        src/sys/compat/sys: siginfo.h

Log Message:
8-byte objects on i386 or arm-oabi are aligned in 4-byte boundary.
Therefore, we must use __attribute__((__aligned__(4))) for them.
netbsd32_{,u}int64 are provided for this purpose. However, we
cannot use it in <compat/sys/siginfo.h> due to circular dependency
b/w <machine/netbsd32_machdep.h>.

In order to distangle it, we choose here to have a duplicate type,
netbsd32_siginfo_uint64, in <compat/sys/siginfo.h>. The equivalence
with netbsd32_uint64 is asserted in <compat/netbsd32/netbsd32.h>.

Now, gdb for i386 works again on amd64 kernel.

Based on patch provided by kamil. Thanks!

XXX
pullup to netbsd-9


To generate a diff of this commit:
cvs rdiff -u -r1.130 -r1.131 src/sys/compat/netbsd32/netbsd32.h
cvs rdiff -u -r1.8 -r1.9 src/sys/compat/sys/siginfo.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/netbsd32/netbsd32.h
diff -u src/sys/compat/netbsd32/netbsd32.h:1.130 src/sys/compat/netbsd32/netbsd32.h:1.131
--- src/sys/compat/netbsd32/netbsd32.h:1.130	Mon Nov 18 04:17:08 2019
+++ src/sys/compat/netbsd32/netbsd32.h	Mon Nov 18 12:06:26 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32.h,v 1.130 2019/11/18 04:17:08 rin Exp $	*/
+/*	$NetBSD: netbsd32.h,v 1.131 2019/11/18 12:06:26 rin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001, 2008, 2015 Matthew R. Green
@@ -162,6 +162,10 @@ typedef int64_t netbsd32_int64 NETBSD32_
 typedef uint64_t netbsd32_uint64 NETBSD32_INT64_ALIGN;
 #undef NETBSD32_INT64_ALIGN
 
+/* Type used in siginfo, avoids circular dependencies between headers. */
+CTASSERT(sizeof(netbsd32_uint64) == sizeof(netbsd32_siginfo_uint64));
+CTASSERT(__alignof__(netbsd32_uint64) == __alignof__(netbsd32_siginfo_uint64));
+
 /*
  * all pointers are netbsd32_pointer_t (defined in <machine/netbsd32_machdep.h>)
  */

Index: src/sys/compat/sys/siginfo.h
diff -u src/sys/compat/sys/siginfo.h:1.8 src/sys/compat/sys/siginfo.h:1.9
--- src/sys/compat/sys/siginfo.h:1.8	Mon Sep 30 21:13:33 2019
+++ src/sys/compat/sys/siginfo.h	Mon Nov 18 12:06:26 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: siginfo.h,v 1.8 2019/09/30 21:13:33 kamil Exp $	 */
+/*	$NetBSD: siginfo.h,v 1.9 2019/11/18 12:06:26 rin Exp $	 */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -34,6 +34,15 @@
 
 #ifdef _KERNEL
 
+/* Avoids circular dependency with machine/netbsd32_machdep.h */
+#if defined(__x86_64__) || (defined(__arm__) && defined(__ARM_EABI__))
+#define NETBSD32_SIGINFO_UINT64_ALIGN __attribute__((__aligned__(4)))
+#else
+#define NETBSD32_SIGINFO_UINT64_ALIGN __attribute__((__aligned__(8)))
+#endif
+typedef uint64_t netbsd32_siginfo_uint64 NETBSD32_SIGINFO_UINT64_ALIGN;
+#undef NETBSD32_SIGINFO_UINT64_ALIGN
+
 typedef union sigval32 {
 	int sival_int;
 	uint32_t sival_ptr;
@@ -73,7 +82,7 @@ struct __ksiginfo32 {
 			int	_sysnum;
 			int	_retval[2];
 			int	_error;
-			uint64_t _args[8]; /* SYS_MAXSYSARGS */
+			netbsd32_siginfo_uint64 _args[8]; /* SYS_MAXSYSARGS */
 		} _syscall;
 
 		struct {

Reply via email to