x32 regressions
Dmitry V. Levin
ldv at altlinux.org
Wed May 1 21:55:07 UTC 2013
On Wed, May 01, 2013 at 02:46:42PM -0400, Mike Frysinger wrote:
> On Wednesday 01 May 2013 14:34:13 Dmitry V. Levin wrote:
> > 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:
>
> still no dice :)
OK, attempt #4, with some changes from v4.7-96-g8435d67 reverted.
* 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.
(realprintstat, printstat) [X32]: Do not define these functions,
redirect printstat to printstat64 instead.
(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 | 10 +++
file.c | 161 +++++++++++++++++++++++--------------------------
linux/x32/syscallent.h | 4 +-
3 files changed, 87 insertions(+), 88 deletions(-)
diff --git a/desc.c b/desc.c
index cd2c857..4ee6ee4 100644
--- a/desc.c
+++ b/desc.c
@@ -230,6 +230,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,7 +273,11 @@ 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
diff --git a/file.c b/file.c
index 837bfed..80a70a7 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;
@@ -917,6 +918,7 @@ static const struct xlat fileflags[] = {
{ 0, NULL },
};
+#ifndef X32
static void
realprintstat(struct tcb *tcp, struct stat *statbuf)
{
@@ -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/6dfef256/attachment.bin>
More information about the Strace-devel
mailing list