From: Nicholas Piggin <npiggin@gmail.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: Nicholas Piggin <npiggin@gmail.com>
Subject: [PATCH 3/4] powerpc/64s: Remove support for ELFv1 little endian userspace
Date: Fri, 5 May 2023 17:18:49 +1000 [thread overview]
Message-ID: <20230505071850.228734-4-npiggin@gmail.com> (raw)
In-Reply-To: <20230505071850.228734-1-npiggin@gmail.com>
ELFv2 was introduced together with little-endian. ELFv1 with LE has
never been a thing. The GNU toolchain can create such a beast, but
anyone doing that is a maniac who needs to be stopped so I consider
this patch a feature.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
arch/powerpc/include/asm/elf.h | 6 ++++++
arch/powerpc/include/asm/thread_info.h | 6 +++++-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
index 79f1c480b5eb..a26ca097d032 100644
--- a/arch/powerpc/include/asm/elf.h
+++ b/arch/powerpc/include/asm/elf.h
@@ -12,8 +12,14 @@
/*
* This is used to ensure we don't load something for the wrong architecture.
+ * 64le only supports ELFv2 64-bit binaries (64be supports v1 and v2).
*/
+#if defined(CONFIG_PPC64) && defined(CONFIG_CPU_LITTLE_ENDIAN)
+#define elf_check_arch(x) (((x)->e_machine == ELF_ARCH) && \
+ (((x)->e_flags & 0x3) == 0x2))
+#else
#define elf_check_arch(x) ((x)->e_machine == ELF_ARCH)
+#endif
#define compat_elf_check_arch(x) ((x)->e_machine == EM_PPC)
#define CORE_DUMP_USE_REGSET
diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
index bf5dde1a4114..bc5d39a835fe 100644
--- a/arch/powerpc/include/asm/thread_info.h
+++ b/arch/powerpc/include/asm/thread_info.h
@@ -183,9 +183,13 @@ static inline bool test_thread_local_flags(unsigned int flags)
#define clear_tsk_compat_task(tsk) do { } while (0)
#endif
-#if defined(CONFIG_PPC64)
+#ifdef CONFIG_PPC64
+#ifdef CONFIG_CPU_BIG_ENDIAN
#define is_elf2_task() (test_thread_flag(TIF_ELF2ABI))
#else
+#define is_elf2_task() (1)
+#endif
+#else
#define is_elf2_task() (0)
#endif
--
2.40.1
next prev parent reply other threads:[~2023-05-05 7:22 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-05 7:18 [PATCH 0/4] powerpc/64: ELFv2 conversion Nicholas Piggin
2023-05-05 7:18 ` [PATCH 1/4] powerpc/64: Force ELFv2 when building with LLVM linker Nicholas Piggin
2023-05-05 21:39 ` Nathan Chancellor
2023-05-05 7:18 ` [PATCH 2/4] powerpc/64: Make ELFv2 the default for big-endian builds Nicholas Piggin
2023-05-05 7:18 ` Nicholas Piggin [this message]
2023-05-05 7:18 ` [RFC PATCH 4/4] powerpc/64: Remove support for kernel's built with ELFv1 ABI Nicholas Piggin
2023-05-05 8:49 ` Christophe Leroy
2023-05-09 8:25 ` Nicholas Piggin
2023-05-05 8:51 ` [PATCH 0/4] powerpc/64: ELFv2 conversion Christophe Leroy
2023-05-05 12:21 ` Michael Ellerman
2023-05-05 15:08 ` Naveen N. Rao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230505071850.228734-4-npiggin@gmail.com \
--to=npiggin@gmail.com \
--cc=linuxppc-dev@lists.ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).