[PATCH] Fix aarch64 decoding of arm struct stat64.
enh
enh at google.com
Fri Apr 4 00:58:59 UTC 2014
commit bc566480e1dbb05d7c8c3d2226f256eebcbe7212
Author: Elliott Hughes <enh at google.com>
Date: Thu Apr 3 17:50:14 2014 -0700
Fix aarch64 decoding of arm struct stat64.
We need to handle this situation more like x86-64. 32-bit arm and i386
actually have a common struct stat64, except the arm one must not be
packed. Additionally, on aarch64 the 32-bit personality is personality 0.
Signed-off-by: Elliott Hughes <enh at google.com>
diff --git a/file.c b/file.c
index 7e0773d..b2790e0 100644
--- a/file.c
+++ b/file.c
@@ -181,10 +181,6 @@ struct __old_kernel_stat {
#undef st_mtime
#undef st_ctime
-#ifdef AARCH64
-#define stat64 stat
-#endif /* AARCH64 */
-
#include <fcntl.h>
#ifdef HAVE_SYS_VFS_H
# include <sys/vfs.h>
@@ -1026,12 +1022,16 @@ printstat(struct tcb *tcp, long addr)
# define printstat printstat64
#endif
-#if !defined HAVE_STAT64 && defined X86_64
+#if !defined HAVE_STAT64 && (defined AARCH64 || defined X86_64)
/*
* Linux x86_64 has unified `struct stat' but its i386 biarch needs
* `struct stat64'. Its <asm-i386/stat.h> definition expects 32-bit `long'.
* <linux/include/asm-x86_64/ia32.h> is not in the public includes set.
* __GNUC__ is needed for the required __attribute__ below.
+ *
+ * Similarly, aarch64 has a unified `struct stat' but its arm personality
+ * needs `struct stat64' (which also expects a 32-bit `long' but which
+ * shouldn't be packed).
*/
struct stat64 {
unsigned long long st_dev;
@@ -1053,10 +1053,16 @@ struct stat64 {
unsigned int st_ctime;
unsigned int st_ctime_nsec;
unsigned long long st_ino;
-} __attribute__((packed));
+}
+#if defined X86_64
+__attribute__((packed))
+#endif
+;
# define HAVE_STAT64 1
+#if defined X86_64
# define STAT64_SIZE 96
#endif
+#endif
#ifdef HAVE_STAT64
static void
@@ -1094,6 +1100,12 @@ printstat64(struct tcb *tcp, long addr)
# endif
#endif /* SPARC[64] */
+#if defined AARCH64
+ if (current_personality != 0) {
+ printstat(tcp, addr);
+ return;
+ }
+#endif
#if defined X86_64
if (current_personality != 1) {
printstat(tcp, addr);
--
Elliott Hughes - http://who/enh - http://jessies.org/~enh/
Java i18n/JNI/NIO, or bionic questions? Mail me/drop by/add me as a reviewer.
-------------- next part --------------
commit bc566480e1dbb05d7c8c3d2226f256eebcbe7212
Author: Elliott Hughes <enh at google.com>
Date: Thu Apr 3 17:50:14 2014 -0700
Fix aarch64 decoding of arm struct stat64.
We need to handle this situation more like x86-64. 32-bit arm and i386
actually have a common struct stat64, except the arm one must not be
packed. Additionally, on aarch64 the 32-bit personality is personality 0.
Signed-off-by: Elliott Hughes <enh at google.com>
diff --git a/file.c b/file.c
index 7e0773d..b2790e0 100644
--- a/file.c
+++ b/file.c
@@ -181,10 +181,6 @@ struct __old_kernel_stat {
#undef st_mtime
#undef st_ctime
-#ifdef AARCH64
-#define stat64 stat
-#endif /* AARCH64 */
-
#include <fcntl.h>
#ifdef HAVE_SYS_VFS_H
# include <sys/vfs.h>
@@ -1026,12 +1022,16 @@ printstat(struct tcb *tcp, long addr)
# define printstat printstat64
#endif
-#if !defined HAVE_STAT64 && defined X86_64
+#if !defined HAVE_STAT64 && (defined AARCH64 || defined X86_64)
/*
* Linux x86_64 has unified `struct stat' but its i386 biarch needs
* `struct stat64'. Its <asm-i386/stat.h> definition expects 32-bit `long'.
* <linux/include/asm-x86_64/ia32.h> is not in the public includes set.
* __GNUC__ is needed for the required __attribute__ below.
+ *
+ * Similarly, aarch64 has a unified `struct stat' but its arm personality
+ * needs `struct stat64' (which also expects a 32-bit `long' but which
+ * shouldn't be packed).
*/
struct stat64 {
unsigned long long st_dev;
@@ -1053,10 +1053,16 @@ struct stat64 {
unsigned int st_ctime;
unsigned int st_ctime_nsec;
unsigned long long st_ino;
-} __attribute__((packed));
+}
+#if defined X86_64
+__attribute__((packed))
+#endif
+;
# define HAVE_STAT64 1
+#if defined X86_64
# define STAT64_SIZE 96
#endif
+#endif
#ifdef HAVE_STAT64
static void
@@ -1094,6 +1100,12 @@ printstat64(struct tcb *tcp, long addr)
# endif
#endif /* SPARC[64] */
+#if defined AARCH64
+ if (current_personality != 0) {
+ printstat(tcp, addr);
+ return;
+ }
+#endif
#if defined X86_64
if (current_personality != 1) {
printstat(tcp, addr);
More information about the Strace-devel
mailing list