Wednesday, February 28, 2024

Re: missing endbr64

Hi,
On Wednesday, February 28, 2024 21:13 CET, Theo Buehler <tb@theobuehler.org> wrote:

> On Sun, Feb 25, 2024 at 10:13:44PM +0100, Sebastian Reitenbach wrote:
> > On Sunday, February 25, 2024 16:44 CET, Mark Kettenis <mark.kettenis@xs4all.nl> wrote:
> >
> > > > x11/gnustep/libobjc2.log
> > > > ld: warning: __objc_block_trampoline_sret: missing endbr64
> > > > ld: warning: __objc_block_trampoline: missing endbr64
> > > > ld: warning: objc_msgSend: missing endbr64
> > > > ld: warning: objc_msgSend_fpret: missing endbr64
> > > > ld: warning: objc_msgSend_stret: missing endbr64
> > >
> > > I guess this is very similay to devel/objfw. Just add endbr64 to
> > > those functions like we did there. No aarch64 support here by the
> > > looks of it.
> >
> > Above version of libobjc2 is old, but due to build errors, and runtime errors, I was
> > unable to upgrade. However, a new version was released just a few days ago, and that one even builds
> > and doesn't show runtime errors so far.
> > I updated one test box, to get these new ld warnings, there are only these left on amd64:
> >
> > ld: warning: objc_msgSend: missing endbr64
> > ld: warning: objc_msgSend_fpret: missing endbr64
> > ld: warning: objc_msgSend_stret: missing endbr64
> >
> > Which are all the platforms, that need such fix? I see objc_msgSend_fpret for aarch64, arm,
> > amd64, i386, mips and riscv64.
> >
> > Attached patch to update to the new 2.2 release, without any fixes for the missing endbr64.
> >
> > Sebastian
>
> Not sure what to do for riscv64.
>
> The diff below on top of what you committed a few minutes ago should do
> the trick. However, the port needs fixing because of this:
>
> [1/9] Performing download step (git clone) for 'robinmap-populate'
> Cloning into 'robinmap-src'...
> fatal: unable to access 'https://github.com/Tessil/robin-map/': Could not resolve host: github.com
> Cloning into 'robinmap-src'...
> fatal: unable to access 'https://github.com/Tessil/robin-map/': Could not resolve host: github.com
> Cloning into 'robinmap-src'...
> fatal: unable to access 'https://github.com/Tessil/robin-map/': Could not resolve host: github.com
> -- Had to git clone more than once: 3 times.
> CMake Error at robinmap-subbuild/robinmap-populate-prefix/tmp/robinmap-populate-gitclone.cmake:39 (message):
> Failed to clone repository: 'https://github.com/Tessil/robin-map/'
>
do you have robin-map-1.2.1 installed, or some older version?
I haven't seen that here, but can trash that downloading with a patch if necessary.


I was just working on it (without having any clue what I'm doing here)
It got rid of the warnings, but looks differently to what you have.
I'll try your patch below Tomorrow

cheers,
Sebastian

>
> 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"

No comments:

Post a Comment