@@ -768,6 +768,13 @@ static uint32_t get_elf_hwcap2(void)
#undef GET_FEATURE_ID
+#if TARGET_BIG_ENDIAN
+# include "vdso-be.c.inc"
+#else
+# include "vdso-le.c.inc"
+#endif
+#define vdso_image_info() &vdso_image_info
+
#endif /* not TARGET_AARCH64 */
#endif /* TARGET_ARM */
new file mode 100644
@@ -0,0 +1,33 @@
+# TARGET_BIG_ENDIAN is defined to 'n' for little-endian; which means it
+# is always true as far as source_set.apply() is concerned. Always build
+# both header files and include the right one via #if.
+
+vdso_cmd = [
+ build_vdso_cmd,
+ '-B', meson.project_build_root(),
+ '-C', meson.current_source_dir(),
+ '-T', 'aarch64-linux-user',
+ '-o', '@OUTPUT@',
+ '--',
+ '-nostdlib', '-shared',
+ '-Wl,-h,linux-vdso.so.1',
+ '-Wl,--build-id=sha1',
+ '-Wl,--hash-style=both',
+ '-Wl,-T,@INPUT1@',
+ '@INPUT0@'
+]
+
+vdso_le_so = custom_target(output: 'vdso-le.so',
+ input: files('vdso.S', 'vdso.ld'),
+ command: vdso_cmd + ['-mlittle-endian'])
+
+vdso_be_so = custom_target(output: 'vdso-be.so',
+ input: files('vdso.S', 'vdso.ld'),
+ command: vdso_cmd + ['-mbig-endian'])
+
+gen = [
+ gen_vdso.process(vdso_le_so, extra_args: ['-r', '__kernel_rt_sigreturn']),
+ gen_vdso.process(vdso_be_so, extra_args: ['-r', '__kernel_rt_sigreturn']),
+]
+
+linux_user_ss.add(when: 'TARGET_AARCH64', if_true: gen)
new file mode 100755
GIT binary patch
literal 3216
zcmc&$O>A355T57v+5{-Ysi=q)1g#XIswz)u5h$n}>|m!!<)$HRMcT{OwO?YViH)9L
zih~5?z=Z>%s3*h$7jXfJb1N?G0i;U3Re&lXl@n4Wq>3KOr9bY>?#y~^Y=p#tN%nm^
z-^}dn+ud2e5A%iTRLTP@K3u}SLugCJ*oV)vHVIoG18H~$^{v<fV@J+N4|=197KCBc
zDaVlE2R(y7jfK(7Duo>9^IFFKH#BtTHHOQ{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!|B8N{N`P+{Vb@R9%AEu=Ib7(&y
zZ~OH}x^=G~AEj-L?|!_O55VR12NUu~&O}bp-nWAxzIUETf0RB;@S8OMp>Xy)9ee+$
z!uj{Um(+z6uXE1Y|19H4`Tr{8Np+;6xLrryR@|-^A1S`4UX)4;OIHe)Yi@(4%QW30
zlYM<LvoQZMrym!7lbbX7<;+6P%w?C!oGzT1%@oX;eEzlES#vfsTgaLI4D9B8H^U#C
z%3a-mQzOW2ZmkE!H<$;0#H;Al8-Yh|d8=Mrua&|M>oP9}MRF_k4YyisRwF#{BV^O_
zo3%#0Z(z#gdR4RP7uP*gEwd&@<OW_V;641WByl143Zy0C5?taSPWV0mdy+d+hY>!A
zJ8%xJkZ^Z_J?hqRmdZC3{!t&mw<Gg#jWQMN@%=r)nBee_Is$%_WpRQ%_)9F5Zw~yU
z-hiXdVt&{m9Z$0DU;K@SJ?av;$c1eC2ql_T8SHTn0mr=q`nsJM(ktBS#QdYqfk*YD
z=O2E+&#}GSSujRD1jqUjBY1x-V3j+vCfGmdo(O&H8^#jDaeLHP@MBO^Zu@^n?Qw@d
zodL)CF^%m%?i)J7cUAE%eKEOL9_9xBlcL15pBv6L1oUxH1OAIR$bI|#CKyYyA5ll|
H{e%7AHUTDw
literal 0
HcmV?d00001
new file mode 100644
@@ -0,0 +1,73 @@
+/*
+ * aarch64 linux replacement vdso.
+ *
+ * Copyright 2023 Linaro, Ltd.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include <asm/unistd.h>
+
+/* ??? These are in include/elf.h, which is not ready for inclusion in asm. */
+#define NT_GNU_PROPERTY_TYPE_0 5
+#define GNU_PROPERTY_AARCH64_FEATURE_1_AND 0xc0000000
+#define GNU_PROPERTY_AARCH64_FEATURE_1_BTI (1U << 0)
+#define GNU_PROPERTY_AARCH64_FEATURE_1_PAC (1U << 1)
+
+#define GNU_PROPERTY_AARCH64_FEATURE_1_DEFAULT \
+ (GNU_PROPERTY_AARCH64_FEATURE_1_BTI | GNU_PROPERTY_AARCH64_FEATURE_1_PAC)
+
+ .section .note.gnu.property
+ .align 3
+ .long 2f - 1f
+ .long 6f - 3f
+ .long NT_GNU_PROPERTY_TYPE_0
+1: .string "GNU"
+2: .align 3
+3: .long GNU_PROPERTY_AARCH64_FEATURE_1_AND
+ .long 5f - 4f
+4: .long GNU_PROPERTY_AARCH64_FEATURE_1_DEFAULT
+5: .align 3
+6:
+
+ .text
+
+.macro endf name
+ .globl \name
+ .type \name, @function
+ .size \name, . - \name
+.endm
+
+.macro vdso_syscall name, nr
+\name:
+ bti c
+ mov x8, #\nr
+ svc #0
+ ret
+endf \name
+.endm
+
+ .cfi_startproc
+
+vdso_syscall __kernel_gettimeofday, __NR_gettimeofday
+vdso_syscall __kernel_clock_gettime, __NR_clock_gettime
+vdso_syscall __kernel_clock_getres, __NR_clock_getres
+
+ .cfi_endproc
+
+
+/*
+ * TODO: The kernel makes a big deal of turning off the .cfi directives,
+ * because they cause libgcc to crash, but that's because they're wrong.
+ *
+ * For now, elide the unwind info for __kernel_rt_sigreturn and rely on
+ * the libgcc fallback routine as we have always done. This requires
+ * that the code sequence used be exact.
+ */
+__kernel_rt_sigreturn:
+ /* No BTI C insn here -- we arrive via RET. */
+ mov x8, #__NR_rt_sigreturn
+ svc #0
+endf __kernel_rt_sigreturn
+
+/* TODO: Add elf note for LINUX_VERSION_CODE */
new file mode 100644
@@ -0,0 +1,72 @@
+/*
+ * Linker script for linux aarch64 replacement vdso.
+ *
+ * Copyright 2021 Linaro, Ltd.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+VERSION {
+ LINUX_2.6.39 {
+ global:
+ __kernel_rt_sigreturn;
+ __kernel_gettimeofday;
+ __kernel_clock_gettime;
+ __kernel_clock_getres;
+
+ local: *;
+ };
+}
+
+
+PHDRS {
+ phdr PT_PHDR FLAGS(4) PHDRS;
+ load PT_LOAD FLAGS(7) FILEHDR PHDRS;
+ dynamic PT_DYNAMIC FLAGS(4);
+ eh_frame_hdr PT_GNU_EH_FRAME;
+ note PT_NOTE FLAGS(4);
+}
+
+SECTIONS {
+ /*
+ * We can't prelink to any address without knowing something about
+ * the virtual memory space of the host, since that leaks over into
+ * the available memory space of the guest.
+ */
+ . = SIZEOF_HEADERS;
+
+ /*
+ * The following, including the FILEHDRS and PHDRS, are modified
+ * when we relocate the binary. We want them to be initially
+ * writable for the relocation; we'll force them read-only after.
+ */
+ .note : { *(.note*) } :load :note
+ .dynamic : { *(.dynamic) } :load :dynamic
+ .dynsym : { *(.dynsym) } :load
+ /*
+ * There ought not be any real read-write data.
+ * But since we manipulated the segment layout,
+ * we have to put these sections somewhere.
+ */
+ .data : {
+ *(.data*)
+ *(.sdata*)
+ *(.got.plt) *(.got)
+ *(.gnu.linkonce.d.*)
+ *(.bss*)
+ *(.dynbss*)
+ *(.gnu.linkonce.b.*)
+ }
+
+ .rodata : { *(.rodata*) }
+ .hash : { *(.hash) }
+ .gnu.hash : { *(.gnu.hash) }
+ .dynstr : { *(.dynstr) }
+ .gnu.version : { *(.gnu.version) }
+ .gnu.version_d : { *(.gnu.version_d) }
+ .gnu.version_r : { *(.gnu.version_r) }
+ .eh_frame_hdr : { *(.eh_frame_hdr) } :load :eh_frame_hdr
+ .eh_frame : { *(.eh_frame) } :load
+
+ .text : { *(.text*) } :load =0xd503201f
+}
@@ -36,6 +36,7 @@ gen_vdso_exe = executable('gen-vdso', 'gen-vdso.c',
gen_vdso = generator(gen_vdso_exe, output: '@BASENAME@.c.inc',
arguments: ['-o', '@OUTPUT@', '@EXTRA_ARGS@', '@INPUT@'])
+subdir('aarch64')
subdir('alpha')
subdir('arm')
subdir('hppa')
Signed-off-by: Richard Henderson <richard.henderson@linaro.org> --- linux-user/elfload.c | 7 ++++ linux-user/aarch64/meson.build | 33 +++++++++++++++ linux-user/aarch64/vdso-be.so | Bin 0 -> 3216 bytes linux-user/aarch64/vdso-le.so | Bin 0 -> 3216 bytes linux-user/aarch64/vdso.S | 73 +++++++++++++++++++++++++++++++++ linux-user/aarch64/vdso.ld | 72 ++++++++++++++++++++++++++++++++ linux-user/meson.build | 1 + 7 files changed, 186 insertions(+) create mode 100644 linux-user/aarch64/meson.build create mode 100755 linux-user/aarch64/vdso-be.so create mode 100755 linux-user/aarch64/vdso-le.so create mode 100644 linux-user/aarch64/vdso.S create mode 100644 linux-user/aarch64/vdso.ld