head	1.1;
access;
symbols;
locks; strict;
comment	@ * @;


1.1
date	2026.07.20.08.02.51;	author he;	state Exp;
branches;
next	;
commitid	T3qBoQLspnpMLmOG;


desc
@@


1.1
log
@lang/gcc14: Add changes to make this build on NetBSD/macppc 11.0_RC6.

This pulls over changes to config/rs6000/ and gcc/config.gcc from
our in-tree gcc instance of gcc14, while preserving existing Homebrew-
related changes to gcc/config.gcc.

The most important fix is that on NetBSD/powerpc, -msecure-plt is enabled
by default, so that resulting executables can be run with PAX_MPROTECT
active.  Otherwise, we end up with executables with sections which have
both "write" and "execute" turned on, which PAX_MPROTECT rejects.  Ref.
the entries for .plt and .got sections in "readelf -a".

Fixes PR#60439.

Bump PKGREVISION for both gcc14 and gcc14-libs, to adhere to rules in comments,
even though this *should* be a single-arch build fix, since I had to merge
the patch to gcc/config.gcc.
@
text
@$NetBSD: patch-gcc_config_rs6000_netbsd.h,v 1.1 2026/07/18 09:12:38 he Exp $

Carry over changes from in-tree gcc in an attempt at
making this build on NetBSD/powerpc.

In particular this should enable -msecure-plt by default so that
the compiler produces executables which will run with

   security.pax.mprotect.enabled=1

--- gcc/config/rs6000/netbsd.h.orig	2026-07-17 07:01:21.448909835 +0000
+++ gcc/config/rs6000/netbsd.h
@@@@ -19,6 +19,10 @@@@
    along with GCC; see the file COPYING3.  If not see
    <http://www.gnu.org/licenses/>.  */
 
+/* NetBSD doesn't support saving and restoring 64-bit regs in a 32-bit
+   process.  */
+#define OS_MISSING_POWERPC64 (!TARGET_64BIT)
+
 /* Undef gnu-user.h macros we don't want.  */
 #undef CPLUSPLUS_CPP_SPEC
 #undef LINK_GCC_C_SEQUENCE_SPEC
@@@@ -31,6 +35,12 @@@@
       builtin_define ("__powerpc__");		\
       builtin_assert ("cpu=powerpc");		\
       builtin_assert ("machine=powerpc");	\
+      if (TARGET_SECURE_PLT)			\
+        builtin_define ("_SECURE_PLT");		\
+      if (TARGET_SOFT_FLOAT)			\
+        builtin_define ("_SOFT_FLOAT");		\
+      if (TARGET_ISEL)				\
+        builtin_define ("__PPC_ISEL__");	\
     }						\
   while (0)
 
@@@@ -62,6 +72,29 @@@@
 #undef  PTRDIFF_TYPE
 #define PTRDIFF_TYPE "int"
 
+/* Redefine some types that where redefined by rs6000 include files.  */
+
+#undef WCHAR_TYPE
+#define WCHAR_TYPE "int"
+
+#undef WCHAR_TYPE_SIZE
+#define WCHAR_TYPE_SIZE 32
+
+#undef WINT_TYPE
+#define WINT_TYPE "int"
+
+#undef INT64_TYPE
+#define INT64_TYPE "long long int"
+
+#undef UINT64_TYPE
+#define UINT64_TYPE "long long unsigned int"
+
+#undef INTMAX_TYPE
+#define INTMAX_TYPE "long long int"
+
+#undef UINTMAX_TYPE
+#define UINTMAX_TYPE "long long unsigned int"
+
 /* Undo the spec mess from sysv4.h, and just define the specs
    the way NetBSD systems actually expect.  */
 
@@@@ -79,18 +112,39 @@@@
 #define STARTFILE_SPEC NETBSD_STARTFILE_SPEC
 
 #undef  ENDFILE_SPEC
-#define ENDFILE_SPEC "%(netbsd_endfile_spec)"
+#define ENDFILE_SPEC NETBSD_ENDFILE_SPEC
 
 #undef  LIB_SPEC
 #define LIB_SPEC NETBSD_LIB_SPEC
 
 #undef  SUBTARGET_EXTRA_SPECS
 #define SUBTARGET_EXTRA_SPECS					\
-  { "netbsd_link_spec",		NETBSD_LINK_SPEC_ELF },		\
-  { "netbsd_entry_point",	NETBSD_ENTRY_POINT },		\
-  { "netbsd_endfile_spec",	NETBSD_ENDFILE_SPEC },
+  { "cc1_secure_plt_default",  CC1_SECURE_PLT_DEFAULT_SPEC },   \
+  NETBSD_SUBTARGET_EXTRA_SPECS
 
+/*
+ * Add NetBSD specific defaults: -mstrict-align
+ */
+#undef TARGET_DEFAULT
+#define TARGET_DEFAULT (MASK_STRICT_ALIGN)
+
+/*
+ * We know we have the right binutils for this (we shouldn't need to do this
+ * but until the cross build does the right thing...)
+ */
+#undef TARGET_SECURE_PLT
+#define TARGET_SECURE_PLT secure_plt
+#undef HAVE_AS_TLS
+#define HAVE_AS_TLS 1
+#define POWERPC_NETBSD
+
+/* Attempt to enable execute permissions on the stack.  */
+//#define TRANSFER_FROM_TRAMPOLINE NETBSD_ENABLE_EXECUTE_STACK
+// XXXMRG use enable-execute-stack-mprotect.c ?
+#ifdef L_trampoline
+#undef TRAMPOLINE_SIZE
+#define TRAMPOLINE_SIZE 48
+#endif
 
 /* Use standard DWARF numbering for DWARF debugging information.  */
 #define RS6000_USE_DWARF_NUMBERING
-
@
