Index | Thread | Search

From:
"Sebastian Reitenbach" <sebastia@l00-bugdead-prods.de>
Subject:
Re: gnustep/libobjc2 and BTI (was: Re: x11/gnustep/libobjc2 failed to build)
To:
"Mark Kettenis" <mark.kettenis@xs4all.nl>
Cc:
jca@wxcvbn.org, kettenis@openbsd.org, tb@openbsd.org, stu@spacehopper.org, ajacoutot@bsdfrog.org, ports@openbsd.org
Date:
Thu, 07 Mar 2024 09:01:13 +0100

Download raw body.

Thread
Hi,


On Wednesday, March 06, 2024 23:42 CET, Mark Kettenis <mark.kettenis@xs4all.nl> wrote:

> > Date: Wed, 06 Mar 2024 23:32:51 +0100
> > From: Mark Kettenis <mark.kettenis@xs4all.nl>
> > 
> > > Date: Wed, 6 Mar 2024 19:02:35 +0100
> > > From: Jeremie Courreges-Anglas <jca@wxcvbn.org>
> > > 
> > > Le Wed, Mar 06, 2024 at 10:17:32AM +0100, Theo Buehler a écrit :
> > > > Could you please resend the endbr64 patches with Cc kettenis? They
> > > > should make release.
> > > 
> > > Since I now have a laptop with BTI I figured I was going to give this
> > > a try.  -current x11/gnustep/zipper was crashing with SIGILL on amd64.
> > > For the amd64 diff I'm deliberately not caring about the assembly for
> > > Windows.  I can't test the arm64 part but it looks simple.
> > > 
> > > ok?
> > > 
> > > Sebastian, feel free to commit this if it matches your previous diff.
> > 
> > Looks right to me.
> 
> Actually, the arm64 bit is probably incomplete.  And tb@ has a point
> that endbr64 should be after the .cfi_startproc.
> 

I already created a lot of mess rushing getting the update in, I'm 
a bit confused with this back and fourth. Before messing up even more, 
which of these should be the correct version, the one from tb@ or jca@ ?
And that one would also be complete in aarch64?
If I got all those threats right, the tb@ version would be the correct one?
Both attached below.


How do I get a BTI enabled machine?

Sebastian

tb@ version:

Index: patches/patch-block_trampolines_S
===================================================================
RCS file: patches/patch-block_trampolines_S
diff -N patches/patch-block_trampolines_S
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ patches/patch-block_trampolines_S	28 Feb 2024 20:08:24 -0000
@@ -0,0 +1,19 @@
+Index: block_trampolines.S
+--- block_trampolines.S.orig
++++ block_trampolines.S
+@@ -22,6 +22,7 @@
+ // x86-64 trampoline
+ ////////////////////////////////////////////////////////////////////////////////
+ .macro trampoline arg0, arg1
++	endbr64
+ 	mov   -0x1007(%rip), \arg1   # Load the block pointer into the second argument
+ 	xchg  \arg1, \arg0           # Swap the first and second arguments
+ 	jmp   *-0x1008(%rip)         # Call the block function
+@@ -121,6 +122,7 @@
+ // AArch64 (ARM64) trampoline
+ ////////////////////////////////////////////////////////////////////////////////
+ .macro trampoline arg0, arg1
++	bti c
+ 	adr x17, #-4096
+ 	mov \arg1, \arg0
+ 	ldp \arg0, x17, [x17]
Index: patches/patch-objc_msgSend_aarch64_S
===================================================================
RCS file: patches/patch-objc_msgSend_aarch64_S
diff -N patches/patch-objc_msgSend_aarch64_S
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ patches/patch-objc_msgSend_aarch64_S	28 Feb 2024 20:08:24 -0000
@@ -0,0 +1,12 @@
+Index: objc_msgSend.aarch64.S
+--- objc_msgSend.aarch64.S.orig
++++ objc_msgSend.aarch64.S
+@@ -47,7 +47,7 @@
+ #   define EH_NOP .seh_nop
+ #else
+ // Marks the real start and end of the function
+-#   define EH_START .cfi_startproc
++#   define EH_START .cfi_startproc; bti c
+ #   define EH_END .cfi_endproc
+ 
+ // The following directives are either not
Index: patches/patch-objc_msgSend_x86-64_S
===================================================================
RCS file: patches/patch-objc_msgSend_x86-64_S
diff -N patches/patch-objc_msgSend_x86-64_S
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ patches/patch-objc_msgSend_x86-64_S	28 Feb 2024 20:08:24 -0000
@@ -0,0 +1,12 @@
+Index: objc_msgSend.x86-64.S
+--- objc_msgSend.x86-64.S.orig
++++ objc_msgSend.x86-64.S
+@@ -8,7 +8,7 @@
+ #	define SECOND_ARGUMENT %rdx
+ #	define THIRD_ARGUMENT %r8
+ #else
+-#	define START_PROC(x) .cfi_startproc
++#	define START_PROC(x) .cfi_startproc; endbr64
+ #	define END_PROC(x) .cfi_endproc
+ #	define FRAME_OFFSET(x) .cfi_adjust_cfa_offset x
+ #	define FIRST_ARGUMENT_STR "%rdi"



@jca version:



Index: Makefile
===================================================================
RCS file: /home/cvs/ports/x11/gnustep/libobjc2/Makefile,v
diff -u -p -r1.37 Makefile
--- Makefile	5 Mar 2024 16:11:15 -0000	1.37
+++ Makefile	6 Mar 2024 17:26:11 -0000
@@ -4,7 +4,7 @@ COMMENT =	GNUstep libobjc2 objective-c r
 
 # note: this port does not use the gnustep module
 VERSION =	2.2
-REVISION =	3
+REVISION =	4
 GH_ACCOUNT =	gnustep
 GH_PROJECT =	libobjc2
 GH_TAGNAME =	v${VERSION}
Index: patches/patch-objc_msgSend_aarch64_S
===================================================================
RCS file: patches/patch-objc_msgSend_aarch64_S
diff -N patches/patch-objc_msgSend_aarch64_S
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ patches/patch-objc_msgSend_aarch64_S	6 Mar 2024 17:19:04 -0000
@@ -0,0 +1,11 @@
+Index: objc_msgSend.aarch64.S
+--- objc_msgSend.aarch64.S.orig
++++ objc_msgSend.aarch64.S
+@@ -73,6 +73,7 @@ CDECL(objc_msgSend):
+ CDECL(objc_msgSend_fpret):
+ CDECL(objc_msgSend_stret):
+ 	EH_START
++	bti    c
+ 
+ 	cbz    x0, 4f                   // Skip everything if the receiver is nil
+ 	                                       // Jump to 6: if this is a small object
Index: patches/patch-objc_msgSend_x86-64_S
===================================================================
RCS file: patches/patch-objc_msgSend_x86-64_S
diff -N patches/patch-objc_msgSend_x86-64_S
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ patches/patch-objc_msgSend_x86-64_S	6 Mar 2024 17:18:56 -0000
@@ -0,0 +1,15 @@
+Index: objc_msgSend.x86-64.S
+--- objc_msgSend.x86-64.S.orig
++++ objc_msgSend.x86-64.S
+@@ -307,9 +307,11 @@ TYPE_DIRECTIVE(CDECL(objc_msgSend), @function)
+ TYPE_DIRECTIVE(CDECL(objc_msgSend_fpret), @function)
+ CDECL(objc_msgSend_fpret):
+ CDECL(objc_msgSend):
++	endbr64
+ 	MSGSEND objc_msgSend, %rdi, %rsi
+ .globl CDECL(objc_msgSend_stret)
+ TYPE_DIRECTIVE(CDECL(objc_msgSend_stret), @function)
+ CDECL(objc_msgSend_stret):
++	endbr64
+ 	MSGSEND objc_msgSend_stret, %rsi, %rdx
+ #endif