[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 13/20] hurd: Add a basic AArch64 port
From: |
Sergey Bugaev |
Subject: |
[PATCH v2 13/20] hurd: Add a basic AArch64 port |
Date: |
Sat, 23 Mar 2024 20:32:54 +0300 |
The following commits will add TLS, HTL, and the signal bits.
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
---
sysdeps/mach/hurd/aarch64/Implies | 3 ++
sysdeps/mach/hurd/aarch64/longjmp-ts.c | 49 ++++++++++++++++++++++
sysdeps/mach/hurd/aarch64/shlib-versions | 2 +
sysdeps/mach/hurd/aarch64/static-start.S | 52 ++++++++++++++++++++++++
sysdeps/mach/hurd/aarch64/vm_param.h | 24 +++++++++++
5 files changed, 130 insertions(+)
create mode 100644 sysdeps/mach/hurd/aarch64/Implies
create mode 100644 sysdeps/mach/hurd/aarch64/longjmp-ts.c
create mode 100644 sysdeps/mach/hurd/aarch64/shlib-versions
create mode 100644 sysdeps/mach/hurd/aarch64/static-start.S
create mode 100644 sysdeps/mach/hurd/aarch64/vm_param.h
diff --git a/sysdeps/mach/hurd/aarch64/Implies
b/sysdeps/mach/hurd/aarch64/Implies
new file mode 100644
index 00000000..02af165f
--- /dev/null
+++ b/sysdeps/mach/hurd/aarch64/Implies
@@ -0,0 +1,3 @@
+mach/hurd/htl
+aarch64/htl
+mach/hurd/aarch64/htl
diff --git a/sysdeps/mach/hurd/aarch64/longjmp-ts.c
b/sysdeps/mach/hurd/aarch64/longjmp-ts.c
new file mode 100644
index 00000000..2fcb7493
--- /dev/null
+++ b/sysdeps/mach/hurd/aarch64/longjmp-ts.c
@@ -0,0 +1,49 @@
+/* Perform a `longjmp' on a Mach thread_state. AArch64 version.
+ Copyright (C) 1991-2024 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <setjmp.h>
+#include <jmpbuf-offsets.h>
+#include <mach/thread_status.h>
+
+
+/* Set up STATE to do the equivalent of `longjmp (ENV, VAL);'. */
+
+void
+_hurd_longjmp_thread_state (void *state, jmp_buf env, int val)
+{
+ struct aarch64_thread_state *ts = state;
+
+ ts->x[19] = env[0].__jmpbuf[JB_X19];
+ ts->x[20] = env[0].__jmpbuf[JB_X20];
+ ts->x[21] = env[0].__jmpbuf[JB_X21];
+ ts->x[22] = env[0].__jmpbuf[JB_X22];
+ ts->x[23] = env[0].__jmpbuf[JB_X23];
+ ts->x[24] = env[0].__jmpbuf[JB_X24];
+ ts->x[25] = env[0].__jmpbuf[JB_X25];
+ ts->x[26] = env[0].__jmpbuf[JB_X26];
+ ts->x[27] = env[0].__jmpbuf[JB_X27];
+ ts->x[28] = env[0].__jmpbuf[JB_X28];
+ ts->x[29] = env[0].__jmpbuf[JB_X29];
+
+ /* XXX: We're ignoring all the d[] (SIMD) registers.
+ Is that fine? */
+
+ ts->pc = PTR_DEMANGLE (env[0].__jmpbuf[JB_LR]);
+ ts->sp = _jmpbuf_sp (env[0].__jmpbuf);
+ ts->x[0] = val ?: 1;
+}
diff --git a/sysdeps/mach/hurd/aarch64/shlib-versions
b/sysdeps/mach/hurd/aarch64/shlib-versions
new file mode 100644
index 00000000..b9e7c2cb
--- /dev/null
+++ b/sysdeps/mach/hurd/aarch64/shlib-versions
@@ -0,0 +1,2 @@
+DEFAULT GLIBC_2.40
+ld=ld-aarch64.so.1
diff --git a/sysdeps/mach/hurd/aarch64/static-start.S
b/sysdeps/mach/hurd/aarch64/static-start.S
new file mode 100644
index 00000000..e09865c4
--- /dev/null
+++ b/sysdeps/mach/hurd/aarch64/static-start.S
@@ -0,0 +1,52 @@
+/* Startup code for statically linked Hurd/AArch64 binaries.
+ Copyright (C) 1998-2024 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+
+/* This is the actual entry point for statically linked aarch64-gnu
executables,
+ the very first code to run in a process. */
+
+ .text
+ENTRY(_start)
+ /* Set up the initial stack frame. */
+ cfi_undefined (x30)
+ mov x29, #0
+ mov x30, #0
+
+ /* Pre-fill GOT entries for select ifunc routines that may get
+ called during _hurd_stack_setup () with baseline implementations. */
+ adrp x1, __memcpy_generic
+ add x1, x1, #:lo12:__memcpy_generic
+ adrp x0, :got:memcpy
+ str x1, [x0, :got_lo12:memcpy]
+
+ adrp x1, __strlen_generic
+ add x1, x1, #:lo12:__strlen_generic
+ adrp x0, :got:strlen
+ str x1, [x0, :got_lo12:strlen]
+
+ mov x0, sp
+ bl _hurd_stack_setup
+
+ /* Jump to the regular entry point. */
+ mov x0, #0
+ b _start1
+END(_start)
+
+#define _start _start1
+#include <sysdeps/aarch64/start.S>
diff --git a/sysdeps/mach/hurd/aarch64/vm_param.h
b/sysdeps/mach/hurd/aarch64/vm_param.h
new file mode 100644
index 00000000..304a2f2b
--- /dev/null
+++ b/sysdeps/mach/hurd/aarch64/vm_param.h
@@ -0,0 +1,24 @@
+/* Copyright (C) 2020-2024 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#ifndef _AARCH64_VM_PARAM_H
+#define _AARCH64_VM_PARAM_H
+
+/* Arbitrary start of the brk. This is after usual binary and library
mappings. */
+#define BRK_START 0x200000000000
+
+#endif /* aarch64/vm_param.h */
--
2.44.0
- [PATCH v2 00/20] aarch64-gnu port & GNU/Hurd on AArch64 progress, Sergey Bugaev, 2024/03/23
- [PATCH v2 01/20] hurd: Move internal functions to internal header, Sergey Bugaev, 2024/03/23
- [PATCH v2 05/20] hurd: Use the RETURN_ADDRESS macro, Sergey Bugaev, 2024/03/23
- [PATCH v2 04/20] hurd: Disable Prefer_MAP_32BIT_EXEC on non-x86_64 for now, Sergey Bugaev, 2024/03/23
- [PATCH v2 06/20] htl: Respect GL(dl_stack_flags) when allocating stacks, Sergey Bugaev, 2024/03/23
- [PATCH v2 08/20] aarch64: Add dl-procinfo, Sergey Bugaev, 2024/03/23
- [PATCH v2 11/20] mach: Add a basic AArch64 port, Sergey Bugaev, 2024/03/23
- [PATCH v2 13/20] hurd: Add a basic AArch64 port,
Sergey Bugaev <=
- [PATCH v2 18/20] htl: Implement some support for TLS_DTV_AT_TP, Sergey Bugaev, 2024/03/23
- [PATCH v2 02/20] hurd: Stop relying on VM_MAX_ADDRESS, Sergey Bugaev, 2024/03/23
- [PATCH v2 03/20] Allow glibc to be compiled without EXEC_PAGESIZE, Sergey Bugaev, 2024/03/23
- [PATCH v2 07/20] aarch64: Move pointer_guard.h out of sysdeps/unix/sysv/linux, Sergey Bugaev, 2024/03/23
- [PATCH v2 10/20] aarch64: Allow building without kernel support for BTI, Sergey Bugaev, 2024/03/23
- [PATCH v2 12/20] mach: Declare the new thread_set_self_state () trap, Sergey Bugaev, 2024/03/23
- [PATCH v2 15/20] hurd: Implement longjmp for AArch64, Sergey Bugaev, 2024/03/23
- [PATCH v2 17/20] hurd: Add an AArch64 signal implementation, Sergey Bugaev, 2024/03/23
- [PATCH v2 09/20] aarch64: Move saving user entry into _dl_start_user, Sergey Bugaev, 2024/03/23
- [PATCH v2 14/20] hurd: Implement TLS on AArch64, Sergey Bugaev, 2024/03/23