]> granicus.if.org Git - strace/commitdiff
Treat PowerPC 64 LE as a separate architecture
authorEugene Syromyatnikov <evgsyr@gmail.com>
Wed, 24 Jul 2019 14:57:34 +0000 (16:57 +0200)
committerDmitry V. Levin <ldv@altlinux.org>
Sun, 4 Aug 2019 22:33:09 +0000 (22:33 +0000)
That seems to be the easiest way to properly handle the fact that
PPC64LE does not have a meaningful m32 personality.

* configure.ac: Move AC_C_BIGENDIAN before arch detection; determine
powerpc64/powerpc64le arch based on $ac_cv_c_bigendian value.
* linux/dummy.h [POWERPC64LE] (sys_oldselect): Redirect to printargs.
* linux/powerpc64le/arch_defs_.h: New file.
* linux/powerpc64le/arch_regs.c: Likewise.
* linux/powerpc64le/arch_rt_sigframe.c: Likewise.
* linux/powerpc64le/errnoent.h: Likewise.
* linux/powerpc64le/get_error.c: Likewise.
* linux/powerpc64le/get_scno.c: Likewise.
* linux/powerpc64le/get_syscall_args.c: Likewise.
* linux/powerpc64le/ioctls_arch0.h: Likewise.
* linux/powerpc64le/ioctls_inc0.h: Likewise.
* linux/powerpc64le/raw_syscall.h: Likewise.
* linux/powerpc64le/rt_sigframe.h: Likewise.
* linux/powerpc64le/set_error.c: Likewise.
* linux/powerpc64le/set_scno.c: Likewise.
* linux/powerpc64le/syscallent.h: Likewise.
* linux/powerpc64le/userent.h: Likewise.
* Makefile.am (EXTRA_DIST): Add them.
* tests/ipc_msg.c: Check for POWERPC64LE definition in addition to
POWERPC64.
* util.c (getllval): Add check for POWERPC64LE definition in addition to
POWERPC64.
* strace.1.in (.SH MULTIPLE PERSONALITY SUPPORT): Mention that only big
endian PowerPC 64 has mpers support.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
20 files changed:
Makefile.am
configure.ac
linux/powerpc64le/arch_defs_.h [new file with mode: 0644]
linux/powerpc64le/arch_regs.c [new file with mode: 0644]
linux/powerpc64le/arch_rt_sigframe.c [new file with mode: 0644]
linux/powerpc64le/errnoent.h [new file with mode: 0644]
linux/powerpc64le/get_error.c [new file with mode: 0644]
linux/powerpc64le/get_scno.c [new file with mode: 0644]
linux/powerpc64le/get_syscall_args.c [new file with mode: 0644]
linux/powerpc64le/ioctls_arch0.h [new file with mode: 0644]
linux/powerpc64le/ioctls_inc0.h [new file with mode: 0644]
linux/powerpc64le/raw_syscall.h [new file with mode: 0644]
linux/powerpc64le/rt_sigframe.h [new file with mode: 0644]
linux/powerpc64le/set_error.c [new file with mode: 0644]
linux/powerpc64le/set_scno.c [new file with mode: 0644]
linux/powerpc64le/syscallent.h [new file with mode: 0644]
linux/powerpc64le/userent.h [new file with mode: 0644]
strace.1.in
tests/ipc_msg.c
util.c

index 0fa7f25d857a5126dec4d9400894d015d1134e4d..25a81f2c42effe2307fe43869be9abf50703f5b0 100644 (file)
@@ -720,6 +720,21 @@ EXTRA_DIST =                               \
        linux/powerpc64/syscallent.h    \
        linux/powerpc64/syscallent1.h   \
        linux/powerpc64/userent.h       \
+       linux/powerpc64le/arch_defs_.h  \
+       linux/powerpc64le/arch_regs.c   \
+       linux/powerpc64le/arch_rt_sigframe.c    \
+       linux/powerpc64le/errnoent.h    \
+       linux/powerpc64le/get_error.c   \
+       linux/powerpc64le/get_scno.c    \
+       linux/powerpc64le/get_syscall_args.c    \
+       linux/powerpc64le/ioctls_arch0.h        \
+       linux/powerpc64le/ioctls_inc0.h \
+       linux/powerpc64le/raw_syscall.h \
+       linux/powerpc64le/rt_sigframe.h \
+       linux/powerpc64le/set_error.c   \
+       linux/powerpc64le/set_scno.c    \
+       linux/powerpc64le/syscallent.h  \
+       linux/powerpc64le/userent.h     \
        linux/ptrace_pokeuser.c         \
        linux/raw_syscall.h             \
        linux/riscv/arch_defs_.h        \
index 3394357ba281aa6cf3c64feba1ea1b204b5f6700..0bd49b6b3953f216717dae9f7efa1ad1e170127e 100644 (file)
@@ -48,6 +48,8 @@ AC_SUBST([COPYRIGHT_YEAR], [copyright_year])
 AC_DEFINE([MANPAGE_DATE], "[manpage_date]", [Date])
 AC_SUBST([MANPAGE_DATE], [manpage_date])
 
+AC_C_BIGENDIAN
+
 AC_MSG_CHECKING([for supported architecture])
 arch_m32=
 arch_mx32=
@@ -126,8 +128,19 @@ powerpc*)
 # error 32 bit
 #endif], [], arch=powerpc64, arch=powerpc)
        if test "$arch" = "powerpc64"; then
-               arch_m32=powerpc
-               AC_DEFINE([POWERPC64], 1, [Define for the PowerPC64 architecture.])
+               # $ac_cv_c_bigendian is defined by AC_C_BIGENDIAN
+               case "$ac_cv_c_bigendian" in
+               no)
+                       arch=powerpc64le
+                       AC_DEFINE([POWERPC64LE], 1,
+                                 [Define for the little endian PowerPC64 architecture.])
+                       ;;
+               *)
+                       arch_m32=powerpc
+                       AC_DEFINE([POWERPC64], 1,
+                                 [Define for the big endian PowerPC64 architecture.])
+                       ;;
+               esac
        fi
        ;;
 riscv*)
@@ -243,7 +256,6 @@ esac
 AC_DEFINE_UNQUOTED([ENABLE_ARM_OABI], [$enable_arm_oabi],
                   [Define to 1 if you want OABI support on ARM EABI.])
 
-AC_C_BIGENDIAN
 AC_C_TYPEOF
 
 AC_TYPE_UID_T
diff --git a/linux/powerpc64le/arch_defs_.h b/linux/powerpc64le/arch_defs_.h
new file mode 100644 (file)
index 0000000..494672a
--- /dev/null
@@ -0,0 +1,9 @@
+/*
+ * Copyright (c) 2019 The strace developers.
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#define HAVE_ARCH_OLD_SELECT 1
+#define HAVE_ARCH_DEDICATED_ERR_REG 1
diff --git a/linux/powerpc64le/arch_regs.c b/linux/powerpc64le/arch_regs.c
new file mode 100644 (file)
index 0000000..8c4a45d
--- /dev/null
@@ -0,0 +1 @@
+#include "../powerpc/arch_regs.c"
diff --git a/linux/powerpc64le/arch_rt_sigframe.c b/linux/powerpc64le/arch_rt_sigframe.c
new file mode 100644 (file)
index 0000000..d5d1267
--- /dev/null
@@ -0,0 +1,12 @@
+/*
+ * Copyright (c) 2017-2018 Dmitry V. Levin <ldv@altlinux.org>
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+FUNC_GET_RT_SIGFRAME_ADDR
+{
+       kernel_ulong_t sp;
+       return get_stack_pointer(tcp, &sp) ? sp : 0;
+}
diff --git a/linux/powerpc64le/errnoent.h b/linux/powerpc64le/errnoent.h
new file mode 100644 (file)
index 0000000..945ce85
--- /dev/null
@@ -0,0 +1 @@
+#include "../powerpc64/errnoent.h"
diff --git a/linux/powerpc64le/get_error.c b/linux/powerpc64le/get_error.c
new file mode 100644 (file)
index 0000000..c7fc341
--- /dev/null
@@ -0,0 +1 @@
+#include "../powerpc64/get_error.c"
diff --git a/linux/powerpc64le/get_scno.c b/linux/powerpc64le/get_scno.c
new file mode 100644 (file)
index 0000000..6624614
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * Copyright (c) 2015-2018 The strace developers.
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+/* Return codes: 1 - ok, 0 - ignore, other - error. */
+static int
+arch_get_scno(struct tcb *tcp)
+{
+       tcp->scno = ppc_regs.gpr[0];
+       return 1;
+}
diff --git a/linux/powerpc64le/get_syscall_args.c b/linux/powerpc64le/get_syscall_args.c
new file mode 100644 (file)
index 0000000..281eb60
--- /dev/null
@@ -0,0 +1 @@
+#include "../powerpc64/get_syscall_args.c"
diff --git a/linux/powerpc64le/ioctls_arch0.h b/linux/powerpc64le/ioctls_arch0.h
new file mode 100644 (file)
index 0000000..14d0c0b
--- /dev/null
@@ -0,0 +1 @@
+#include "../powerpc64/ioctls_arch0.h"
diff --git a/linux/powerpc64le/ioctls_inc0.h b/linux/powerpc64le/ioctls_inc0.h
new file mode 100644 (file)
index 0000000..a89fa3c
--- /dev/null
@@ -0,0 +1 @@
+#include "../powerpc64/ioctls_inc0.h"
diff --git a/linux/powerpc64le/raw_syscall.h b/linux/powerpc64le/raw_syscall.h
new file mode 100644 (file)
index 0000000..f1800fc
--- /dev/null
@@ -0,0 +1 @@
+#include "../powerpc64/raw_syscall.h"
diff --git a/linux/powerpc64le/rt_sigframe.h b/linux/powerpc64le/rt_sigframe.h
new file mode 100644 (file)
index 0000000..cd8902f
--- /dev/null
@@ -0,0 +1 @@
+#include "../powerpc64/rt_sigframe.h"
diff --git a/linux/powerpc64le/set_error.c b/linux/powerpc64le/set_error.c
new file mode 100644 (file)
index 0000000..207ffe9
--- /dev/null
@@ -0,0 +1 @@
+#include "../powerpc64/set_error.c"
diff --git a/linux/powerpc64le/set_scno.c b/linux/powerpc64le/set_scno.c
new file mode 100644 (file)
index 0000000..d3f6479
--- /dev/null
@@ -0,0 +1 @@
+#include "../powerpc64/set_scno.c"
diff --git a/linux/powerpc64le/syscallent.h b/linux/powerpc64le/syscallent.h
new file mode 100644 (file)
index 0000000..785a81b
--- /dev/null
@@ -0,0 +1 @@
+#include "../powerpc64/syscallent.h"
diff --git a/linux/powerpc64le/userent.h b/linux/powerpc64le/userent.h
new file mode 100644 (file)
index 0000000..1f71181
--- /dev/null
@@ -0,0 +1 @@
+#include "../powerpc64/userent.h"
index 567283719e98e1ede62c3a6ece27f1325ba3f6f4..4100427e5b85a15cddc5f6c709e29a681514ce9b 100644 (file)
@@ -1039,7 +1039,7 @@ l l.
 Architecture   ABIs supported
 x86_64 i386, x32 (when built as an x86_64 application); i386 (when built as an x32 application)
 AArch64        ARM 32-bit EABI
-PowerPC 64-bit PowerPC 32-bit
+PowerPC 64-bit BE      PowerPC 32-bit
 RISC-V 64-bit  RISC-V 32-bit
 s390x  s390
 SPARC 64-bit   SPARC 32-bit
index b12f4af3315f9aaa734ba787cf18c9796cf43eb8..2290d818a89779cf47203b14cf74130aa3627607 100644 (file)
  * which led to segmentation fault.
  */
 #undef TEST_MSGCTL_BOGUS_ADDR
-#if defined __GLIBC__ && defined POWERPC64
+#if defined __GLIBC__ && (defined POWERPC64 || defined POWERPC64LE)
 # if !(defined __GLIBC_MINOR__) \
    || ((__GLIBC__ << 16) + __GLIBC_MINOR__ < (2 << 16) + 23)
 #  define TEST_MSGCTL_BOGUS_ADDR 0
 # endif
-#endif /* __GLIBC__ && POWERPC64 */
+#endif /* __GLIBC__ && (POWERPC64 || POWERPC64LE) */
 
 #ifndef TEST_MSGCTL_BOGUS_ADDR
 # define TEST_MSGCTL_BOGUS_ADDR 1
diff --git a/util.c b/util.c
index 2349ec1589f2b31201b1d0daba2e92403de049e1..814f78c4cb4c35f42e4e789d8d9438cfa89a4c9a 100644 (file)
--- a/util.c
+++ b/util.c
@@ -159,10 +159,10 @@ getllval(struct tcb *tcp, unsigned long long *val, int arg_no)
 #if SIZEOF_KERNEL_LONG_T > 4
 # ifndef current_klongsize
        if (current_klongsize < SIZEOF_KERNEL_LONG_T) {
-#  if defined(AARCH64) || defined(POWERPC64)
+#  if defined(AARCH64) || defined(POWERPC64) || defined(POWERPC64LE)
                /* Align arg_no to the next even number. */
                arg_no = (arg_no + 1) & 0xe;
-#  endif /* AARCH64 || POWERPC64 */
+#  endif /* AARCH64 || POWERPC64 || POWERPC64LE */
                *val = ULONG_LONG(tcp->u_arg[arg_no], tcp->u_arg[arg_no + 1]);
                arg_no += 2;
        } else