git: 203bcad73164 - stable/13 - amd64: wrap 64bit sigtramp into vdso

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Sun, 02 Jan 2022 19:08:10 UTC
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=203bcad73164bf6e4f51edc4ffda7f2a3885b413

commit 203bcad73164bf6e4f51edc4ffda7f2a3885b413
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2021-11-05 08:07:24 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2022-01-02 16:43:01 +0000

    amd64: wrap 64bit sigtramp into vdso
    
    (cherry picked from commit ab4524b3d7fba872a143b03c9346cb04c3670efa)
---
 sys/amd64/amd64/elf_machdep.c | 20 +++++++---
 sys/amd64/amd64/sigtramp.S    | 18 +++------
 sys/compat/linux/linux_vdso.c |  4 +-
 sys/conf/files.amd64          |  7 +++-
 sys/conf/vdso_amd64.ldscript  | 89 +++++++++++++++++++++++++++++++++++++++++++
 sys/kern/kern_proc.c          |  7 +++-
 sys/kern/kern_sharedpage.c    | 18 ++++++++-
 sys/sys/sysent.h              |  4 +-
 sys/tools/amd64_vdso.sh       | 59 ++++++++++++++++++++++++++++
 sys/tools/vdso_wrap.S         | 48 +++++++++++++++++++++++
 10 files changed, 247 insertions(+), 27 deletions(-)

diff --git a/sys/amd64/amd64/elf_machdep.c b/sys/amd64/amd64/elf_machdep.c
index 445efa883fd2..6a4c25072962 100644
--- a/sys/amd64/amd64/elf_machdep.c
+++ b/sys/amd64/amd64/elf_machdep.c
@@ -49,14 +49,21 @@ __FBSDID("$FreeBSD$");
 #include <machine/fpu.h>
 #include <machine/md_var.h>
 
+#include "vdso_offsets.h"
+
+extern const char _binary_elf_vdso_so_1_start[];
+extern const char _binary_elf_vdso_so_1_end[];
+extern char _binary_elf_vdso_so_1_size;
+
 struct sysentvec elf64_freebsd_sysvec_la48 = {
 	.sv_size	= SYS_MAXSYSCALL,
 	.sv_table	= sysent,
 	.sv_transtrap	= NULL,
 	.sv_fixup	= __elfN(freebsd_fixup),
 	.sv_sendsig	= sendsig,
-	.sv_sigcode	= sigcode,
-	.sv_szsigcode	= &szsigcode,
+	.sv_sigcode	= _binary_elf_vdso_so_1_start,
+	.sv_szsigcode	= (int *)&_binary_elf_vdso_so_1_size,
+	.sv_sigcodeoff	= VDSO_SIGCODE_OFFSET,
 	.sv_name	= "FreeBSD ELF64",
 	.sv_coredump	= __elfN(coredump),
 	.sv_imgact_try	= NULL,
@@ -72,7 +79,7 @@ struct sysentvec elf64_freebsd_sysvec_la48 = {
 	.sv_fixlimit	= NULL,
 	.sv_maxssiz	= NULL,
 	.sv_flags	= SV_ABI_FREEBSD | SV_ASLR | SV_LP64 | SV_SHP |
-			    SV_TIMEKEEP | SV_RNG_SEED_VER,
+			    SV_TIMEKEEP | SV_RNG_SEED_VER | SV_DSO_SIG,
 	.sv_set_syscall_retval = cpu_set_syscall_retval,
 	.sv_fetch_syscall_args = cpu_fetch_syscall_args,
 	.sv_syscallnames = syscallnames,
@@ -92,8 +99,9 @@ struct sysentvec elf64_freebsd_sysvec_la57 = {
 	.sv_transtrap	= NULL,
 	.sv_fixup	= __elfN(freebsd_fixup),
 	.sv_sendsig	= sendsig,
-	.sv_sigcode	= sigcode,
-	.sv_szsigcode	= &szsigcode,
+	.sv_sigcode	= _binary_elf_vdso_so_1_start,
+	.sv_szsigcode	= (int *)&_binary_elf_vdso_so_1_size,
+	.sv_sigcodeoff	= VDSO_SIGCODE_OFFSET,
 	.sv_name	= "FreeBSD ELF64",
 	.sv_coredump	= __elfN(coredump),
 	.sv_imgact_try	= NULL,
@@ -109,7 +117,7 @@ struct sysentvec elf64_freebsd_sysvec_la57 = {
 	.sv_fixlimit	= NULL,
 	.sv_maxssiz	= NULL,
 	.sv_flags	= SV_ABI_FREEBSD | SV_ASLR | SV_LP64 | SV_SHP |
-			    SV_TIMEKEEP | SV_RNG_SEED_VER,
+			    SV_TIMEKEEP | SV_RNG_SEED_VER | SV_DSO_SIG,
 	.sv_set_syscall_retval = cpu_set_syscall_retval,
 	.sv_fetch_syscall_args = cpu_fetch_syscall_args,
 	.sv_syscallnames = syscallnames,
diff --git a/sys/amd64/amd64/sigtramp.S b/sys/amd64/amd64/sigtramp.S
index a249a1a646f2..05bf30293a9a 100644
--- a/sys/amd64/amd64/sigtramp.S
+++ b/sys/amd64/amd64/sigtramp.S
@@ -27,18 +27,15 @@
  */
 
 #include <sys/syscall.h>
-
 #include <machine/asmacros.h>
 
 #include "assym.inc"
 
 	.text
-/**********************************************************************
- *
- * Signal trampoline, copied to top of user stack
- *
+/*
+ * Signal trampoline, mapped as vdso into shared page.
  */
-NON_GPROF_ENTRY(sigcode)
+ENTRY(__vdso_sigcode)
 	call	*SIGF_HANDLER(%rsp)	/* call signal handler */
 	lea	SIGF_UC(%rsp),%rdi	/* get ucontext_t */
 	pushq	$0			/* junk to fake return addr. */
@@ -46,11 +43,6 @@ NON_GPROF_ENTRY(sigcode)
 	syscall				/* enter kernel with args */
 0:	hlt				/* trap priviliged instruction */
 	jmp	0b
+END(__vdso_sigcode)
 
-	ALIGN_TEXT
-esigcode:
-
-	.data
-	.globl	szsigcode
-szsigcode:
-	.long	esigcode-sigcode
+	.section .note.GNU-stack,"",%progbits
diff --git a/sys/compat/linux/linux_vdso.c b/sys/compat/linux/linux_vdso.c
index a05c0b01ff40..ba828c1b6816 100644
--- a/sys/compat/linux/linux_vdso.c
+++ b/sys/compat/linux/linux_vdso.c
@@ -110,7 +110,7 @@ __elfN(linux_vdso_fixup)(struct sysentvec *sv)
 	Elf_Shdr *shdr;
 	int i;
 
-	ehdr = (Elf_Ehdr *) sv->sv_sigcode;
+	ehdr = __DECONST(Elf_Ehdr *, sv->sv_sigcode);
 
 	if (!IS_ELF(*ehdr) ||
 	    ehdr->e_ident[EI_CLASS] != ELF_TARG_CLASS ||
@@ -153,7 +153,7 @@ __elfN(linux_vdso_reloc)(struct sysentvec *sv)
 	Elf_Sym *sym;
 	int i, j, symcnt;
 
-	ehdr = (Elf_Ehdr *) sv->sv_sigcode;
+	ehdr = __DECONST(Elf_Ehdr *, sv->sv_sigcode);
 
 	/* Adjust our so relative to the sigcode_base */
 	if (sv->sv_shared_page_base != 0) {
diff --git a/sys/conf/files.amd64 b/sys/conf/files.amd64
index 633d9125398c..f529ffeba7e8 100644
--- a/sys/conf/files.amd64
+++ b/sys/conf/files.amd64
@@ -12,6 +12,12 @@ include 	"conf/files.x86"
 # dependency lines other than the first are silently ignored.
 #
 #
+elf-vdso.so.o			standard				\
+	dependency	"$S/amd64/amd64/sigtramp.S assym.inc $S/tools/amd64_vdso.sh" \
+	compile-with	"env AWK='${AWK}' NM='${NM}' LD='${LD}' CC='${CC}' OBJCOPY='${OBJCOPY}' S='${S}' sh $S/tools/amd64_vdso.sh" \
+	no-implicit-rule before-depend	\
+	clean		"elf-vdso.so.o elf-vdso.so.1 vdso_offsets.h sigtramp.pico"
+#
 cloudabi32_vdso.o		optional	compat_cloudabi32	\
 	dependency	"$S/contrib/cloudabi/cloudabi_vdso_i686_on_64bit.S" \
 	compile-with	"${CC} -x assembler-with-cpp -m32 -shared -nostdinc -nostdlib -Wl,-T$S/compat/cloudabi/cloudabi_vdso.lds $S/contrib/cloudabi/cloudabi_vdso_i686_on_64bit.S -o ${.TARGET}" \
@@ -124,7 +130,6 @@ amd64/amd64/mpboot.S		optional	smp
 amd64/amd64/pmap.c		standard
 amd64/amd64/prof_machdep.c	optional	profiling-routine
 amd64/amd64/ptrace_machdep.c	standard
-amd64/amd64/sigtramp.S		standard
 amd64/amd64/support.S		standard
 amd64/amd64/sys_machdep.c	standard
 amd64/amd64/trap.c		standard
diff --git a/sys/conf/vdso_amd64.ldscript b/sys/conf/vdso_amd64.ldscript
new file mode 100644
index 000000000000..d412abd4cd02
--- /dev/null
+++ b/sys/conf/vdso_amd64.ldscript
@@ -0,0 +1,89 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2021 The FreeBSD Foundation
+ *
+ * This software was developed by Konstantin Belousov <kib@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Linker script for amd64 vdso.
+ */
+
+PHDRS
+{
+	text		PT_LOAD		FILEHDR PHDRS FLAGS(5); /* PF_R|PF_X */
+	dynamic		PT_DYNAMIC	FLAGS(5);
+	eh_frame_hdr	PT_GNU_EH_FRAME FLAGS(5);
+}
+
+SECTIONS
+{
+	. = . + SIZEOF_HEADERS;
+
+	.hash		: { *(.hash) }			:text
+	.gnu.hash	: { *(.gnu.hash) }		:text
+	.dynsym		: { *(.dynsym) }		:text
+	.dynstr		: { *(.dynstr) }		:text
+	.gnu.version	: { *(.gnu.version) }		:text
+	.gnu.version_d	: { *(.gnu.version_d) }		:text
+	.gnu.version_r	: { *(.gnu.version_r) }		:text
+	.eh_frame_hdr	: { *(.eh_frame_hdr) }		:text	:eh_frame_hdr
+	.eh_frame	: { KEEP (*(.eh_frame)) }	:text
+	.dynamic	: { *(.dynamic) }		:text	:dynamic
+	.rodata		: { *(.rodata*) }		:text
+	.data : {
+	      *(.got.plt) *(.got)
+	} :text
+	/DISCARD/ /* .data */: {
+	      *(.data*)
+	      *(.sdata*)
+	      *(.gnu.linkonce.d.*)
+	      *(.bss*)
+	      *(.dynbss*)
+	      *(.gnu.linkonce.b.*)
+	      *(.ctors)
+	      *(.dtors)
+	      *(.jcr)
+	      *(.init_array)
+	      *(.init)
+	      *(.fini)
+	      *(.debug*)
+	      *(.comment)
+	}
+
+	. = ALIGN(0x10);
+	.text		: { *(.text .text*) }		:text	=0x90909090
+}
+
+VERSION
+{
+	FBSD_1.7 {
+		global:
+			__vdso_sigcode;
+		local:
+			*;
+	};
+}
diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c
index 21af09265dd2..dc3068c29514 100644
--- a/sys/kern/kern_proc.c
+++ b/sys/kern/kern_proc.c
@@ -3100,7 +3100,9 @@ sysctl_kern_proc_sigtramp(SYSCTL_HANDLER_ARGS)
 			if (sv->sv_sigcode_base != 0) {
 				kst32.ksigtramp_start = sv->sv_sigcode_base;
 				kst32.ksigtramp_end = sv->sv_sigcode_base +
-				    *sv->sv_szsigcode;
+				    ((sv->sv_flags & SV_DSO_SIG) == 0 ?
+				    *sv->sv_szsigcode :
+				    (uintptr_t)sv->sv_szsigcode);
 			} else {
 				kst32.ksigtramp_start = sv->sv_psstrings -
 				    *sv->sv_szsigcode;
@@ -3116,7 +3118,8 @@ sysctl_kern_proc_sigtramp(SYSCTL_HANDLER_ARGS)
 	if (sv->sv_sigcode_base != 0) {
 		kst.ksigtramp_start = (char *)sv->sv_sigcode_base;
 		kst.ksigtramp_end = (char *)sv->sv_sigcode_base +
-		    *sv->sv_szsigcode;
+		    ((sv->sv_flags & SV_DSO_SIG) == 0 ? *sv->sv_szsigcode :
+		    (uintptr_t)sv->sv_szsigcode);
 	} else {
 		kst.ksigtramp_start = (char *)sv->sv_psstrings -
 		    *sv->sv_szsigcode;
diff --git a/sys/kern/kern_sharedpage.c b/sys/kern/kern_sharedpage.c
index e47fbbe62bb7..98f7b619e0b7 100644
--- a/sys/kern/kern_sharedpage.c
+++ b/sys/kern/kern_sharedpage.c
@@ -305,10 +305,12 @@ void
 exec_sysvec_init(void *param)
 {
 	struct sysentvec *sv;
+	vm_offset_t sb;
 #ifdef RANDOM_FENESTRASX
 	ptrdiff_t base;
 #endif
 	u_int flags;
+	int res;
 
 	sv = param;
 	flags = sv->sv_flags;
@@ -319,8 +321,20 @@ exec_sysvec_init(void *param)
 
 	sv->sv_shared_page_obj = shared_page_obj;
 	if ((flags & SV_ABI_MASK) == SV_ABI_FREEBSD) {
-		sv->sv_sigcode_base = sv->sv_shared_page_base +
-		    shared_page_fill(*(sv->sv_szsigcode), 16, sv->sv_sigcode);
+		if ((flags & SV_DSO_SIG) != 0) {
+			sb = sv->sv_shared_page_base;
+			res = shared_page_fill((uintptr_t)sv->sv_szsigcode,
+			    16, sv->sv_sigcode);
+			if (res == -1)
+				panic("copying sigtramp to shared page");
+			sb += res;
+			sb += sv->sv_sigcodeoff;
+			sv->sv_sigcode_base = sb;
+		} else {
+			sv->sv_sigcode_base = sv->sv_shared_page_base +
+			    shared_page_fill(*(sv->sv_szsigcode), 16,
+			    sv->sv_sigcode);
+		}
 	}
 	if ((flags & SV_TIMEKEEP) != 0) {
 #ifdef COMPAT_FREEBSD32
diff --git a/sys/sys/sysent.h b/sys/sys/sysent.h
index d95ea5cd9038..cc3f183ff7cd 100644
--- a/sys/sys/sysent.h
+++ b/sys/sys/sysent.h
@@ -108,8 +108,9 @@ struct sysentvec {
 					/* stack fixup function */
 	void		(*sv_sendsig)(void (*)(int), struct ksiginfo *, struct __sigset *);
 			    		/* send signal */
-	char 		*sv_sigcode;	/* start of sigtramp code */
+	const char 	*sv_sigcode;	/* start of sigtramp code */
 	int 		*sv_szsigcode;	/* size of sigtramp code */
+	int		sv_sigcodeoff;
 	char		*sv_name;	/* name of binary type */
 	int		(*sv_coredump)(struct thread *, struct vnode *, off_t, int);
 					/* function to dump core, or NULL */
@@ -164,6 +165,7 @@ struct sysentvec {
 #define	SV_RNG_SEED_VER	0x100000	/* random(4) reseed generation. */
 #define	SV_SIG_DISCIGN	0x200000	/* Do not discard ignored signals */
 #define	SV_SIG_WAITNDQ	0x400000	/* Wait does not dequeue SIGCHLD */
+#define	SV_DSO_SIG	0x800000	/* Signal trampoline packed in dso */
 
 #define	SV_ABI_MASK	0xff
 #define	SV_PROC_FLAG(p, x)	((p)->p_sysent->sv_flags & (x))
diff --git a/sys/tools/amd64_vdso.sh b/sys/tools/amd64_vdso.sh
new file mode 100644
index 000000000000..39406eccd2ef
--- /dev/null
+++ b/sys/tools/amd64_vdso.sh
@@ -0,0 +1,59 @@
+#!/bin/sh
+# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+#
+# Copyright (c) 2021 The FreeBSD Foundation
+# All rights reserved.
+#
+# This software was developed by Konstantin Belousov <kib@FreeBSD.org>
+# under sponsorship from the FreeBSD Foundation.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+
+set -e
+
+${CC} -x assembler-with-cpp -DLOCORE -fPIC -nostdinc -c \
+   -o sigtramp.pico -I. -I"${S}" -include opt_global.h \
+   "${S}"/amd64/amd64/sigtramp.S
+
+# We need to make vdso as compact as possible, for it to leave space
+# for other things in the shared page.  For this, we pack everything
+# into single loadable segment.
+#
+# -z rodynamic is undocumented lld-specific option, seemingly required
+# for lld to avoid putting dynamic into dedicated writeable segment,
+# despite ldscript placement.  It is ignored by ld.bfd but ldscript
+# alone is enough there.
+#
+${LD} --shared -Bsymbolic -soname="elf-vdso.so.1" \
+   -T "${S}"/conf/vdso_amd64.ldscript \
+   --eh-frame-hdr --no-undefined -z rodynamic -z norelro -nmagic \
+   --hash-style=sysv --fatal-warnings --strip-all \
+   -o elf-vdso.so.1 sigtramp.pico
+
+${CC} -x assembler-with-cpp -DLOCORE -fPIC -nostdinc -c \
+   -o elf-vdso.so.o -I. -I"${S}" -include opt_global.h \
+   -DVDSO_NAME=elf_vdso_so_1 -DVDSO_FILE=elf-vdso.so.1 \
+   "${S}"/tools/vdso_wrap.S
+
+${NM} -D elf-vdso.so.1 | \
+   awk '/__vdso_sigcode/{printf "#define VDSO_SIGCODE_OFFSET 0x%s\n",$1}' \
+   >vdso_offsets.h
diff --git a/sys/tools/vdso_wrap.S b/sys/tools/vdso_wrap.S
new file mode 100644
index 000000000000..807dcf9c06f4
--- /dev/null
+++ b/sys/tools/vdso_wrap.S
@@ -0,0 +1,48 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2021 The FreeBSD Foundation
+ *
+ * This software was developed by Konstantin Belousov <kib@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+
+#define	VDSO_BLOB_START(S)	__CONCAT(_binary_, __CONCAT(S, _start))
+#define	VDSO_BLOB_END(S)	__CONCAT(_binary_, __CONCAT(S, _end))
+#define	VDSO_BLOB_SIZE(S)	__CONCAT(_binary_, __CONCAT(S, _size))
+
+	.section .rodata, "a", %progbits
+	.globl	VDSO_BLOB_START(VDSO_NAME)
+	.type	VDSO_BLOB_START(VDSO_NAME), %object
+	.size	VDSO_BLOB_START(VDSO_NAME), 0
+VDSO_BLOB_START(VDSO_NAME):
+	.incbin	__XSTRING(VDSO_FILE)
+	.globl	VDSO_BLOB_END(VDSO_NAME)
+	.type	VDSO_BLOB_END(VDSO_NAME), %object
+	.size	VDSO_BLOB_END(VDSO_NAME), 0
+VDSO_BLOB_END(VDSO_NAME):
+	.globl	VDSO_BLOB_SIZE(VDSO_NAME)
+	.set	VDSO_BLOB_SIZE(VDSO_NAME), . - VDSO_BLOB_START(VDSO_NAME)