Here the assembly gets generated by M4 macros.  There is macro for
generating CPU-specific function prologues.  So provide one for arm64
that adds the required BTI instruction.

ok?


Index: devel/gmp/Makefile
===================================================================
RCS file: /cvs/ports/devel/gmp/Makefile,v
retrieving revision 1.46
diff -u -p -r1.46 Makefile
--- devel/gmp/Makefile  8 Mar 2022 14:27:55 -0000       1.46
+++ devel/gmp/Makefile  20 Apr 2023 20:42:45 -0000
@@ -2,7 +2,7 @@ COMMENT-main=   library for arbitrary prec
 COMMENT-cxx=   C++ library for arbitrary precision arithmetic
 
 VERSION=       6.2.1
-REVISION-main= 0
+REVISION-main= 1
 DISTNAME=      gmp-${VERSION}
 MULTI_PACKAGES=        -main -cxx
 PKGNAME-cxx=   gmpxx-${VERSION}
@@ -39,6 +39,10 @@ CONFIGURE_ARGS+=--build=${MACHINE_ARCH}-
 
 # Our vsnprintf works properly; skip test that uses %n.
 CONFIGURE_ENV+=        gmp_cv_func_vsnprintf=yes
+
+.if ${MACHINE_ARCH:Maarch64}
+CONFIGURE_ENV+= ASMFLAGS=-mmark-bti-property
+.endif
 
 .include <bsd.port.arch.mk>
 .if ${BUILD_PACKAGES:M-cxx}
Index: devel/gmp/patches/patch-mpn_arm64_arm64-defs_m4
===================================================================
RCS file: devel/gmp/patches/patch-mpn_arm64_arm64-defs_m4
diff -N devel/gmp/patches/patch-mpn_arm64_arm64-defs_m4
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ devel/gmp/patches/patch-mpn_arm64_arm64-defs_m4     20 Apr 2023 20:42:45 
-0000
@@ -0,0 +1,21 @@
+Index: mpn/arm64/arm64-defs.m4
+--- mpn/arm64/arm64-defs.m4.orig
++++ mpn/arm64/arm64-defs.m4
+@@ -37,6 +37,17 @@ dnl  don't want to disable macro expansions in or afte
+ changecom
+ 
+ 
++dnl  Called: PROLOGUE_cpu(GSYM_PREFIX`'foo)
++
++define(`PROLOGUE_cpu',
++m4_assert_numargs(1)
++`     TEXT
++      ALIGN(8)
++      GLOBL   `$1' GLOBL_ATTR
++      TYPE(`$1',`function')
++`$1'LABEL_SUFFIX
++      bti     c')
++
+ dnl  LEA_HI(reg,gmp_symbol), LEA_LO(reg,gmp_symbol)
+ dnl
+ dnl  Load the address of gmp_symbol into a register. We split this into two

Reply via email to