x32 regressions

Dmitry V. Levin ldv at altlinux.org
Wed May 1 22:49:02 UTC 2013


On Wed, May 01, 2013 at 06:27:32PM -0400, Mike Frysinger wrote:
> On Wednesday 01 May 2013 17:55:07 Dmitry V. Levin wrote:
> > OK, attempt #4, with some changes from v4.7-96-g8435d67 reverted.
> 
> initial build fails:
[...]
> i fix that locally by just moving the definition of printflock64.
[...]
> then an earlier warning turns into a link failure:
[...]
> file.o: In function `printoldstat':
> /root/strace/file.c:1235: undefined reference to `realprintstat'
[...]
> x32 builds define HAVE_STRUCT___OLD_KERNEL_STAT for the i386 32bit ABI.  i 
> hacked out that call just to get it to link and it looks like stat() gets 
> decoded properly:

Thanks.  I hope this would be the final attempt:

* desc.c (printflock) [X32]: Add special handling required for
this architecture with sizeof(long) < sizeof(off_t).
* file.c [X32] (struct stat64): Add __attribute__((packed)).
[X32] (HAVE_STAT64): Define.
(printstat) [X32]: Redirect to printstat64.
(printstat64) [X32]: Use "struct stat" instead of "struct stat64".
[X32] (realprintstat64): Rename to printstat64_x32.
(sys_stat64, sys_fstat64) [X32]: Remove second definitions of these
functions.  Call printstat64_x32 instead of printstat64
* linux/x32/syscallent.h: Fix handlers for truncate and ftruncate.
---
 desc.c                 |  56 ++++++++++-------
 file.c                 | 161 +++++++++++++++++++++++--------------------------
 linux/x32/syscallent.h |   4 +-
 3 files changed, 110 insertions(+), 111 deletions(-)

diff --git a/desc.c b/desc.c
index cd2c857..a420feb 100644
--- a/desc.c
+++ b/desc.c
@@ -223,6 +223,29 @@ static const struct xlat perf_event_open_flags[] = {
 	{ 0,				NULL			},
 };
 
+#if _LFS64_LARGEFILE
+/* fcntl/lockf */
+static void
+printflock64(struct tcb *tcp, long addr, int getlk)
+{
+	struct flock64 fl;
+
+	if (umove(tcp, addr, &fl) < 0) {
+		tprints("{...}");
+		return;
+	}
+	tprints("{type=");
+	printxval(lockfcmds, fl.l_type, "F_???");
+	tprints(", whence=");
+	printxval(whence_codes, fl.l_whence, "SEEK_???");
+	tprintf(", start=%lld, len=%lld", (long long) fl.l_start, (long long) fl.l_len);
+	if (getlk)
+		tprintf(", pid=%lu}", (unsigned long) fl.l_pid);
+	else
+		tprints("}");
+}
+#endif
+
 /* fcntl/lockf */
 static void
 printflock(struct tcb *tcp, long addr, int getlk)
@@ -230,6 +253,12 @@ printflock(struct tcb *tcp, long addr, int getlk)
 	struct flock fl;
 
 #if SUPPORTED_PERSONALITIES > 1
+# ifdef X32
+	if (current_personality == 0) {
+		printflock64(tcp, addr, getlk);
+		return;
+	}
+# endif
 	if (current_wordsize != sizeof(fl.l_start)) {
 		if (current_wordsize == 4) {
 			/* 32-bit x86 app on x86_64 and similar cases */
@@ -267,36 +296,17 @@ printflock(struct tcb *tcp, long addr, int getlk)
 	printxval(lockfcmds, fl.l_type, "F_???");
 	tprints(", whence=");
 	printxval(whence_codes, fl.l_whence, "SEEK_???");
+#ifdef X32
+	tprintf(", start=%lld, len=%lld", fl.l_start, fl.l_len);
+#else
 	tprintf(", start=%ld, len=%ld", fl.l_start, fl.l_len);
+#endif
 	if (getlk)
 		tprintf(", pid=%lu}", (unsigned long) fl.l_pid);
 	else
 		tprints("}");
 }
 
-#if _LFS64_LARGEFILE
-/* fcntl/lockf */
-static void
-printflock64(struct tcb *tcp, long addr, int getlk)
-{
-	struct flock64 fl;
-
-	if (umove(tcp, addr, &fl) < 0) {
-		tprints("{...}");
-		return;
-	}
-	tprints("{type=");
-	printxval(lockfcmds, fl.l_type, "F_???");
-	tprints(", whence=");
-	printxval(whence_codes, fl.l_whence, "SEEK_???");
-	tprintf(", start=%lld, len=%lld", (long long) fl.l_start, (long long) fl.l_len);
-	if (getlk)
-		tprintf(", pid=%lu}", (unsigned long) fl.l_pid);
-	else
-		tprints("}");
-}
-#endif
-
 int
 sys_fcntl(struct tcb *tcp)
 {
diff --git a/file.c b/file.c
index 837bfed..35f2b71 100644
--- a/file.c
+++ b/file.c
@@ -117,7 +117,8 @@ struct stat64 {
 	unsigned long		st_ctime;
 	unsigned long		st_ctime_nsec;
 	unsigned long long	st_ino;
-};
+} __attribute__((packed));
+# define HAVE_STAT64	1
 
 struct __old_kernel_stat {
 	unsigned short st_dev;
@@ -982,6 +983,7 @@ realprintstat(struct tcb *tcp, struct stat *statbuf)
 		tprints("...}");
 }
 
+#ifndef X32
 static void
 printstat(struct tcb *tcp, long addr)
 {
@@ -1023,6 +1025,9 @@ printstat(struct tcb *tcp, long addr)
 
 	realprintstat(tcp, &statbuf);
 }
+#else /* X32 */
+# define printstat printstat64
+#endif
 
 #if !defined HAVE_STAT64 && defined X86_64
 /*
@@ -1060,7 +1065,11 @@ struct stat64 {
 static void
 printstat64(struct tcb *tcp, long addr)
 {
+#ifdef X32
+	struct stat statbuf;
+#else
 	struct stat64 statbuf;
+#endif
 
 #ifdef STAT64_SIZE
 	(void) sizeof(char[sizeof statbuf == STAT64_SIZE ? 1 : -1]);
@@ -1239,6 +1248,63 @@ sys_stat(struct tcb *tcp)
 	return 0;
 }
 
+#ifdef X32
+static void
+printstat64_x32(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("...}");
+}
+#endif /* X32 */
+
 int
 sys_stat64(struct tcb *tcp)
 {
@@ -1247,7 +1313,11 @@ sys_stat64(struct tcb *tcp)
 		printpath(tcp, tcp->u_arg[0]);
 		tprints(", ");
 	} else {
+# ifdef X32
+		printstat64_x32(tcp, tcp->u_arg[1]);
+# else
 		printstat64(tcp, tcp->u_arg[1]);
+# endif
 	}
 	return 0;
 #else
@@ -1338,7 +1408,11 @@ sys_fstat64(struct tcb *tcp)
 		printfd(tcp, tcp->u_arg[0]);
 		tprints(", ");
 	} else {
+# ifdef X32
+		printstat64_x32(tcp, tcp->u_arg[1]);
+# else
 		printstat64(tcp, tcp->u_arg[1]);
+# endif
 	}
 	return 0;
 #else
@@ -2722,88 +2796,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/20130502/7b35d3db/attachment.bin>


More information about the Strace-devel mailing list