x32 regressions

Dmitry V. Levin ldv at altlinux.org
Wed May 1 18:34:13 UTC 2013


On Wed, May 01, 2013 at 01:55:18PM -0400, Mike Frysinger wrote:
[...]
> that makes it build, but runtime is incorrect

Thanks, could you please test another fix instead of the first one:

* file.c [X32] (struct stat64): Add __attribute__((packed)).
[X32] (HAVE_STAT64, STAT64_SIZE): Define.
(printstat) [X32]: Use printstat64 for current_personality == 0.
[X32] (realprintstat64, sys_fstat64, sys_stat64): Remove.
* linux/x32/syscallent.h: Fix handlers for truncate and ftruncate.
---
 file.c                 | 180 ++++++++++++++-----------------------------------
 linux/x32/syscallent.h |   4 +-
 2 files changed, 54 insertions(+), 130 deletions(-)

diff --git a/file.c b/file.c
index 837bfed..36900b8 100644
--- a/file.c
+++ b/file.c
@@ -117,7 +117,9 @@ struct stat64 {
 	unsigned long		st_ctime;
 	unsigned long		st_ctime_nsec;
 	unsigned long long	st_ino;
-};
+} __attribute__((packed));
+# define HAVE_STAT64	1
+# define STAT64_SIZE	96
 
 struct __old_kernel_stat {
 	unsigned short st_dev;
@@ -982,48 +984,6 @@ realprintstat(struct tcb *tcp, struct stat *statbuf)
 		tprints("...}");
 }
 
-static void
-printstat(struct tcb *tcp, long addr)
-{
-	struct stat statbuf;
-
-	if (!addr) {
-		tprints("NULL");
-		return;
-	}
-	if (syserror(tcp) || !verbose(tcp)) {
-		tprintf("%#lx", addr);
-		return;
-	}
-
-#if defined(SPARC) || defined(SPARC64)
-	if (current_personality == 1) {
-		printstatsol(tcp, addr);
-		return;
-	}
-#ifdef SPARC64
-	else if (current_personality == 2) {
-		printstat_sparc64(tcp, addr);
-		return;
-	}
-#endif
-#endif /* SPARC[64] */
-
-#if defined POWERPC64
-	if (current_personality == 1) {
-		printstat_powerpc32(tcp, addr);
-		return;
-	}
-#endif
-
-	if (umove(tcp, addr, &statbuf) < 0) {
-		tprints("{...}");
-		return;
-	}
-
-	realprintstat(tcp, &statbuf);
-}
-
 #if !defined HAVE_STAT64 && defined X86_64
 /*
  * Linux x86_64 has unified `struct stat' but its i386 biarch needs
@@ -1176,6 +1136,55 @@ printstat64(struct tcb *tcp, long addr)
 }
 #endif /* HAVE_STAT64 */
 
+static void
+printstat(struct tcb *tcp, long addr)
+{
+	struct stat statbuf;
+
+	if (!addr) {
+		tprints("NULL");
+		return;
+	}
+	if (syserror(tcp) || !verbose(tcp)) {
+		tprintf("%#lx", addr);
+		return;
+	}
+
+#if defined(SPARC) || defined(SPARC64)
+	if (current_personality == 1) {
+		printstatsol(tcp, addr);
+		return;
+	}
+#ifdef SPARC64
+	else if (current_personality == 2) {
+		printstat_sparc64(tcp, addr);
+		return;
+	}
+#endif
+#endif /* SPARC[64] */
+
+#if defined POWERPC64
+	if (current_personality == 1) {
+		printstat_powerpc32(tcp, addr);
+		return;
+	}
+#endif
+
+#ifdef X32
+	if (current_personality == 0) {
+		printstat64(tcp, addr);
+		return;
+	}
+#endif
+
+	if (umove(tcp, addr, &statbuf) < 0) {
+		tprints("{...}");
+		return;
+	}
+
+	realprintstat(tcp, &statbuf);
+}
+
 #if defined(HAVE_STRUCT___OLD_KERNEL_STAT)
 static void
 convertoldstat(const struct __old_kernel_stat *oldbuf, struct stat *newbuf)
@@ -2722,88 +2731,3 @@ sys_swapon(struct tcb *tcp)
 	}
 	return 0;
 }
-
-#ifdef X32
-# undef stat64
-# undef sys_fstat64
-# undef sys_stat64
-
-static void
-realprintstat64(struct tcb *tcp, long addr)
-{
-	struct stat64 statbuf;
-
-	if (!addr) {
-		tprints("NULL");
-		return;
-	}
-	if (syserror(tcp) || !verbose(tcp)) {
-		tprintf("%#lx", addr);
-		return;
-	}
-
-	if (umove(tcp, addr, &statbuf) < 0) {
-		tprints("{...}");
-		return;
-	}
-
-	if (!abbrev(tcp)) {
-		tprintf("{st_dev=makedev(%lu, %lu), st_ino=%llu, st_mode=%s, ",
-			(unsigned long) major(statbuf.st_dev),
-			(unsigned long) minor(statbuf.st_dev),
-			(unsigned long long) statbuf.st_ino,
-			sprintmode(statbuf.st_mode));
-		tprintf("st_nlink=%lu, st_uid=%lu, st_gid=%lu, ",
-			(unsigned long) statbuf.st_nlink,
-			(unsigned long) statbuf.st_uid,
-			(unsigned long) statbuf.st_gid);
-		tprintf("st_blksize=%lu, ",
-			(unsigned long) statbuf.st_blksize);
-		tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
-	}
-	else
-		tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
-	switch (statbuf.st_mode & S_IFMT) {
-	case S_IFCHR: case S_IFBLK:
-		tprintf("st_rdev=makedev(%lu, %lu), ",
-			(unsigned long) major(statbuf.st_rdev),
-			(unsigned long) minor(statbuf.st_rdev));
-		break;
-	default:
-		tprintf("st_size=%llu, ", (unsigned long long) statbuf.st_size);
-		break;
-	}
-	if (!abbrev(tcp)) {
-		tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
-		tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
-		tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
-		tprints("}");
-	}
-	else
-		tprints("...}");
-}
-
-int
-sys_fstat64(struct tcb *tcp)
-{
-	if (entering(tcp)) {
-		printfd(tcp, tcp->u_arg[0]);
-		tprints(", ");
-	} else {
-		realprintstat64(tcp, tcp->u_arg[1]);
-	}
-	return 0;
-}
-
-int
-sys_stat64(struct tcb *tcp)
-{
-	if (entering(tcp)) {
-		printpath(tcp, tcp->u_arg[0]);
-		tprints(", ");
-	} else {
-		realprintstat64(tcp, tcp->u_arg[1]);
-	}
-	return 0;
-}
-#endif
diff --git a/linux/x32/syscallent.h b/linux/x32/syscallent.h
index 4adf66b..0098e76 100644
--- a/linux/x32/syscallent.h
+++ b/linux/x32/syscallent.h
@@ -74,8 +74,8 @@
 	{ 2,	TD,	sys_flock,		"flock"		},  /* 73 */
 	{ 1,	TD,	sys_fsync,		"fsync"		},  /* 74 */
 	{ 1,	TD,	sys_fdatasync,		"fdatasync"	},  /* 75 */
-	{ 2,	TF,	sys_truncate,		"truncate"	},  /* 76 */
-	{ 2,	TD,	sys_ftruncate,		"ftruncate"	},  /* 77 */
+	{ 2,	TF,	sys_truncate64,		"truncate"	},  /* 76 */
+	{ 2,	TD,	sys_ftruncate64,	"ftruncate"	},  /* 77 */
 	{ 3,	TD,	sys_getdents,		"getdents"	}, /* 78 */
 	{ 2,	TF,	sys_getcwd,		"getcwd"	},  /* 79 */
 	{ 1,	TF,	sys_chdir,		"chdir"		},  /* 80 */

-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20130501/6a13f7c4/attachment.bin>


More information about the Strace-devel mailing list