From nobody Mon Dec 06 18:48:24 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 1058218B5C87; Mon, 6 Dec 2021 18:48:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4J7CB25kPCz4SKS; Mon, 6 Dec 2021 18:48:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7D5F9113B0; Mon, 6 Dec 2021 18:48:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1B6ImOBL065219; Mon, 6 Dec 2021 18:48:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1B6ImOXp065217; Mon, 6 Dec 2021 18:48:24 GMT (envelope-from git) Date: Mon, 6 Dec 2021 18:48:24 GMT Message-Id: <202112061848.1B6ImOXp065217@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 98c8b6252496 - main - vdso for ia32 on amd64 List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 98c8b6252496e874d337d9a7b565d9037609168f Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638816506; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=o71f4LPD0ZeZXni3dMh+q+noVNYU8dNFVSQXCRj4rMw=; b=jq3ePkptswTjIpqHq1mYYHHxWKtFjqKFW10jRIe5ulJNxcgef6aK1EeesY/bPDvrEu2pgP VbN8QQT+AD1RUou197sVOc6dzLEzHpPK7f6i+q5709qtguUnaTDeGKGWEfm5KtfwR3WT5i Pn4KhvJNN77a6N2PC3tGIlvf/MRIA1NZsYYjteM6skAcdhTr2myNZ477Dnvp8JH9RVNC4j hzC2Vf1z2GBg/8bV40+IoBoE/Jd554yjFagMv1YdDmwKAEa60q68jijNLqD806FdSvn9Pb dzK7MltU6IoHvjx/Re1++23zWQ1C9t3KU259zRKWzq3mgS/WQuwaDKayuDVJLQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638816507; a=rsa-sha256; cv=none; b=mL1D11zZDxvQto5jPqe9BNJiFPQceiWlo8Fpt1UAjJb2fy5eJMsZ7/sb2lG5OLupFEPczq aSQ78LTFjKZddvLKpyy+mt0piafu1eaVtEuQqA4Qt/EbOiZSkAqfS0GqBcp4foqNYQB12b eN5glXcWsNR3/2y1jN2pXK6YKvr0upVRPEccudjdFX2PzfiLeUvLawRKQ0w9If9MEduKIM gtJq/C9DR71WhxN1b5jtZudzeypDm7KOVQOw5bTUx1lx+aa46UaBWjfQ4yf3tvx+ASUnSy xq1KR9heIOibkLAhK9wVn0bi2gnnch9TWCYMlR086K8TOsJLhlpfesWtNYgrlg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=98c8b6252496e874d337d9a7b565d9037609168f commit 98c8b6252496e874d337d9a7b565d9037609168f Author: Konstantin Belousov AuthorDate: 2021-11-14 00:26:55 +0000 Commit: Konstantin Belousov CommitDate: 2021-12-06 18:46:49 +0000 vdso for ia32 on amd64 Reviewed by: emaste Discussed with: jrtc27 Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 month Differential revision: https://reviews.freebsd.org/D32960 --- sys/amd64/ia32/ia32_signal.c | 14 ++++-- sys/amd64/ia32/ia32_sigtramp.S | 40 +++++------------ sys/amd64/ia32/ia32_syscall.c | 10 ++++- sys/compat/ia32/ia32_signal.h | 8 ---- sys/compat/ia32/ia32_sysvec.c | 13 ++++-- sys/conf/files.amd64 | 7 ++- sys/conf/vdso_amd64_ia32.ldscript | 94 +++++++++++++++++++++++++++++++++++++++ sys/kern/imgact_aout.c | 19 +++++++- sys/tools/amd64_ia32_vdso.sh | 53 ++++++++++++++++++++++ 9 files changed, 211 insertions(+), 47 deletions(-) diff --git a/sys/amd64/ia32/ia32_signal.c b/sys/amd64/ia32/ia32_signal.c index 52a9af0f64d2..1349954f40a7 100644 --- a/sys/amd64/ia32/ia32_signal.c +++ b/sys/amd64/ia32/ia32_signal.c @@ -81,6 +81,12 @@ __FBSDID("$FreeBSD$"); #include #include +#include "vdso_ia32_offsets.h" + +extern const char _binary_elf_vdso32_so_1_start[]; +extern const char _binary_elf_vdso32_so_1_end[]; +extern char _binary_elf_vdso32_so_1_size; + #ifdef COMPAT_FREEBSD4 static void freebsd4_ia32_sendsig(sig_t, ksiginfo_t *, sigset_t *); #endif @@ -416,7 +422,9 @@ ia32_osendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) } regs->tf_rsp = (uintptr_t)fp; - regs->tf_rip = p->p_sysent->sv_psstrings - sz_ia32_osigcode; + regs->tf_rip = p->p_sysent->sv_psstrings - + (_binary_elf_vdso32_so_1_end - _binary_elf_vdso32_so_1_start) + + VDSO_IA32_OSIGCODE_OFFSET; regs->tf_rflags &= ~(PSL_T | PSL_D); regs->tf_cs = _ucode32sel; regs->tf_ds = _udatasel; @@ -527,8 +535,8 @@ freebsd4_ia32_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) } regs->tf_rsp = (uintptr_t)sfp; - regs->tf_rip = p->p_sysent->sv_sigcode_base + sz_ia32_sigcode - - sz_freebsd4_ia32_sigcode; + regs->tf_rip = p->p_sysent->sv_sigcode_base + + VDSO_FREEBSD4_IA32_SIGCODE_OFFSET - VDSO_IA32_SIGCODE_OFFSET; regs->tf_rflags &= ~(PSL_T | PSL_D); regs->tf_cs = _ucode32sel; regs->tf_ss = _udatasel; diff --git a/sys/amd64/ia32/ia32_sigtramp.S b/sys/amd64/ia32/ia32_sigtramp.S index c76852c91b06..4488e568c43e 100644 --- a/sys/amd64/ia32/ia32_sigtramp.S +++ b/sys/amd64/ia32/ia32_sigtramp.S @@ -32,14 +32,13 @@ #include "ia32_assym.h" .text - .code32 /* - * Signal trampoline, copied to top of user stack - * XXX may need to be MD to match backend sendsig handoff protocol + * Signal trampoline, mapped as vdso into shared page, or copied to + * top of user stack for old binaries. */ ALIGN_TEXT - .globl ia32_sigcode -ia32_sigcode: + .globl __vdso_ia32_sigcode +__vdso_ia32_sigcode: calll *IA32_SIGF_HANDLER(%esp) leal IA32_SIGF_UC(%esp),%eax /* get ucontext */ pushl %eax @@ -52,7 +51,8 @@ ia32_sigcode: #ifdef COMPAT_FREEBSD4 ALIGN_TEXT -freebsd4_ia32_sigcode: + .globl __vdso_freebsd4_ia32_sigcode +__vdso_freebsd4_ia32_sigcode: calll *IA32_SIGF_HANDLER(%esp) leal IA32_SIGF_UC4(%esp),%eax/* get ucontext */ pushl %eax @@ -66,7 +66,8 @@ freebsd4_ia32_sigcode: #ifdef COMPAT_43 ALIGN_TEXT -ia32_osigcode: + .globl __vdso_ia32_osigcode +__vdso_ia32_osigcode: calll *IA32_SIGF_HANDLER(%esp)/* call signal handler */ leal IA32_SIGF_SC(%esp),%eax /* get sigcontext */ pushl %eax @@ -90,28 +91,9 @@ ia32_osigcode: * vfork() and harder for other syscalls. */ ALIGN_TEXT -lcall_tramp: + .globl __vdso_lcall_tramp +__vdso_lcall_tramp: int $0x80 1: jmp 1b #endif - - ALIGN_TEXT -esigcode: - - .data - .globl sz_ia32_sigcode -sz_ia32_sigcode: - .long esigcode-ia32_sigcode -#ifdef COMPAT_FREEBSD4 - .globl sz_freebsd4_ia32_sigcode -sz_freebsd4_ia32_sigcode: - .long esigcode-freebsd4_ia32_sigcode -#endif -#ifdef COMPAT_43 - .globl sz_ia32_osigcode -sz_ia32_osigcode: - .long esigcode-ia32_osigcode - .globl sz_lcall_tramp -sz_lcall_tramp: - .long esigcode-lcall_tramp -#endif + .p2align 1 diff --git a/sys/amd64/ia32/ia32_syscall.c b/sys/amd64/ia32/ia32_syscall.c index 4e95d056d7fa..fac7b2cc2593 100644 --- a/sys/amd64/ia32/ia32_syscall.c +++ b/sys/amd64/ia32/ia32_syscall.c @@ -92,6 +92,12 @@ __FBSDID("$FreeBSD$"); #include #include +#include "vdso_ia32_offsets.h" + +extern const char _binary_elf_vdso32_so_1_start[]; +extern const char _binary_elf_vdso32_so_1_end[]; +extern char _binary_elf_vdso32_so_1_size; + #define IDTVEC(name) __CONCAT(X,name) extern inthand_t IDTVEC(int0x80_syscall), IDTVEC(int0x80_syscall_pti), @@ -264,7 +270,9 @@ setup_lcall_gate(void) bzero(&uap, sizeof(uap)); uap.start = 0; uap.num = 1; - lcall_addr = curproc->p_sysent->sv_psstrings - sz_lcall_tramp; + lcall_addr = curproc->p_sysent->sv_psstrings - + (_binary_elf_vdso32_so_1_end - _binary_elf_vdso32_so_1_start) + + VDSO_LCALL_TRAMP_OFFSET; bzero(&desc, sizeof(desc)); desc.sd_type = SDT_MEMERA; desc.sd_dpl = SEL_UPL; diff --git a/sys/compat/ia32/ia32_signal.h b/sys/compat/ia32/ia32_signal.h index e5fb8ec90fa2..fe310a8249a2 100644 --- a/sys/compat/ia32/ia32_signal.h +++ b/sys/compat/ia32/ia32_signal.h @@ -195,14 +195,6 @@ struct ia32_sigframe3 { struct ksiginfo; struct image_params; -extern char ia32_sigcode[]; -extern char freebsd4_ia32_sigcode[]; -extern char ia32_osigcode[]; -extern char lcall_tramp; -extern int sz_ia32_sigcode; -extern int sz_freebsd4_ia32_sigcode; -extern int sz_ia32_osigcode; -extern int sz_lcall_tramp; void ia32_sendsig(sig_t, struct ksiginfo *, sigset_t *); void ia32_setregs(struct thread *td, struct image_params *imgp, uintptr_t stack); diff --git a/sys/compat/ia32/ia32_sysvec.c b/sys/compat/ia32/ia32_sysvec.c index 969f5645a0f4..46e75f361bb1 100644 --- a/sys/compat/ia32/ia32_sysvec.c +++ b/sys/compat/ia32/ia32_sysvec.c @@ -83,6 +83,12 @@ CTASSERT(sizeof(struct ia32_ucontext4) == 324); CTASSERT(sizeof(struct ia32_sigframe4) == 408); #endif +#include "vdso_ia32_offsets.h" + +extern const char _binary_elf_vdso32_so_1_start[]; +extern const char _binary_elf_vdso32_so_1_end[]; +extern char _binary_elf_vdso32_so_1_size; + extern const char *freebsd32_syscallnames[]; static SYSCTL_NODE(_compat, OID_AUTO, ia32, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, @@ -101,8 +107,9 @@ struct sysentvec ia32_freebsd_sysvec = { .sv_transtrap = NULL, .sv_fixup = elf32_freebsd_fixup, .sv_sendsig = ia32_sendsig, - .sv_sigcode = ia32_sigcode, - .sv_szsigcode = &sz_ia32_sigcode, + .sv_sigcode = _binary_elf_vdso32_so_1_start, + .sv_szsigcode = (int *)&_binary_elf_vdso32_so_1_size, + .sv_sigcodeoff = VDSO_IA32_SIGCODE_OFFSET, .sv_name = "FreeBSD ELF32", .sv_coredump = elf32_coredump, .sv_elf_core_osabi = ELFOSABI_FREEBSD, @@ -121,7 +128,7 @@ struct sysentvec ia32_freebsd_sysvec = { .sv_fixlimit = ia32_fixlimit, .sv_maxssiz = &ia32_maxssiz, .sv_flags = SV_ABI_FREEBSD | SV_ASLR | SV_IA32 | SV_ILP32 | - SV_SHP | SV_TIMEKEEP | SV_RNG_SEED_VER, + SV_SHP | SV_TIMEKEEP | SV_RNG_SEED_VER | SV_DSO_SIG, .sv_set_syscall_retval = ia32_set_syscall_retval, .sv_fetch_syscall_args = ia32_fetch_syscall_args, .sv_syscallnames = freebsd32_syscallnames, diff --git a/sys/conf/files.amd64 b/sys/conf/files.amd64 index 8c08beab0756..cfccbe196f72 100644 --- a/sys/conf/files.amd64 +++ b/sys/conf/files.amd64 @@ -18,6 +18,12 @@ elf-vdso.so.o standard \ no-implicit-rule before-depend \ clean "elf-vdso.so.o elf-vdso.so.1 vdso_offsets.h sigtramp.pico" # +elf-vdso32.so.o optional compat_freebsd32 \ + dependency "$S/amd64/ia32/ia32_sigtramp.S ia32_assym.h $S/tools/amd64_ia32_vdso.sh" \ + compile-with "env AWK='${AWK}' NM='${NM}' LD='${LD}' CC='${CC}' OBJCOPY='${OBJCOPY}' S='${S}' sh $S/tools/amd64_ia32_vdso.sh" \ + no-implicit-rule before-depend \ + clean "elf-vdso32.so.o elf-vdso32.so.1 vdso_ia32_offsets.h ia32_sigtramp.pico" +# ia32_genassym.o standard \ dependency "$S/compat/ia32/ia32_genassym.c offset.inc" \ compile-with "${CC} ${CFLAGS:N-flto:N-fno-common} -fcommon -c ${.IMPSRC}" \ @@ -368,7 +374,6 @@ kern/link_elf_obj.c standard #amd64/ia32/ia32_exception.S optional compat_freebsd32 amd64/ia32/ia32_reg.c optional compat_freebsd32 amd64/ia32/ia32_signal.c optional compat_freebsd32 -amd64/ia32/ia32_sigtramp.S optional compat_freebsd32 amd64/ia32/ia32_syscall.c optional compat_freebsd32 amd64/ia32/ia32_misc.c optional compat_freebsd32 compat/ia32/ia32_sysvec.c optional compat_freebsd32 diff --git a/sys/conf/vdso_amd64_ia32.ldscript b/sys/conf/vdso_amd64_ia32.ldscript new file mode 100644 index 000000000000..2033ebb9a396 --- /dev/null +++ b/sys/conf/vdso_amd64_ia32.ldscript @@ -0,0 +1,94 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 The FreeBSD Foundation + * + * This software was developed by Konstantin Belousov + * 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 ia32 (32bit) vdso on amd64. + */ + +OUTPUT_ARCH(i386) + +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_ia32_sigcode; + __vdso_freebsd4_ia32_sigcode; + __vdso_ia32_osigcode; + __vdso_lcall_tramp; + local: + *; + }; +} diff --git a/sys/kern/imgact_aout.c b/sys/kern/imgact_aout.c index 5e0721254dd2..f5d5628c05c6 100644 --- a/sys/kern/imgact_aout.c +++ b/sys/kern/imgact_aout.c @@ -108,6 +108,12 @@ struct sysentvec aout_sysvec = { #elif defined(__amd64__) +#include "vdso_ia32_offsets.h" + +extern const char _binary_elf_vdso32_so_1_start[]; +extern const char _binary_elf_vdso32_so_1_end[]; +extern char _binary_elf_vdso32_so_1_size; + #define AOUT32_PS_STRINGS \ (AOUT32_USRSTACK - sizeof(struct freebsd32_ps_strings)) #define AOUT32_MINUSER FREEBSD32_MINUSER @@ -115,14 +121,16 @@ struct sysentvec aout_sysvec = { extern const char *freebsd32_syscallnames[]; extern u_long ia32_maxssiz; +static int aout_szsigcode; + struct sysentvec aout_sysvec = { .sv_size = FREEBSD32_SYS_MAXSYSCALL, .sv_table = freebsd32_sysent, .sv_transtrap = NULL, .sv_fixup = aout_fixup, .sv_sendsig = ia32_sendsig, - .sv_sigcode = ia32_sigcode, - .sv_szsigcode = &sz_ia32_sigcode, + .sv_sigcode = _binary_elf_vdso32_so_1_start, + .sv_szsigcode = &aout_szsigcode, .sv_name = "FreeBSD a.out", .sv_coredump = NULL, .sv_imgact_try = NULL, @@ -144,6 +152,13 @@ struct sysentvec aout_sysvec = { .sv_onexit = exit_onexit, .sv_set_fork_retval = x86_set_fork_retval, }; + +static void +aout_sysent(void *arg __unused) +{ + aout_szsigcode = (int)(uintptr_t)&_binary_elf_vdso32_so_1_size; +} +SYSINIT(aout_sysent, SI_SUB_EXEC, SI_ORDER_ANY, aout_sysent, NULL); #else #error "Only ia32 arch is supported" #endif diff --git a/sys/tools/amd64_ia32_vdso.sh b/sys/tools/amd64_ia32_vdso.sh new file mode 100644 index 000000000000..15ad866b4471 --- /dev/null +++ b/sys/tools/amd64_ia32_vdso.sh @@ -0,0 +1,53 @@ +#!/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 +# 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 -m32 \ + -o ia32_sigtramp.pico -I. -I"${S}" -include opt_global.h \ + "${S}"/amd64/ia32/ia32_sigtramp.S + +${LD} --shared -Bsymbolic -soname="elf-vdso32.so.1" \ + -T "${S}"/conf/vdso_amd64_ia32.ldscript \ + --eh-frame-hdr --no-undefined -z rodynamic -z norelro -nmagic \ + --hash-style=sysv --fatal-warnings --strip-all \ + -o elf-vdso32.so.1 ia32_sigtramp.pico + +${CC} -x assembler-with-cpp -DLOCORE -fPIC -nostdinc -c \ + -o elf-vdso32.so.o -I. -I"${S}" -include opt_global.h \ + -DVDSO_NAME=elf_vdso32_so_1 -DVDSO_FILE=elf-vdso32.so.1 \ + "${S}"/tools/vdso_wrap.S + +${NM} -D elf-vdso32.so.1 | ${AWK} \ + '/__vdso_ia32_sigcode/{printf "#define VDSO_IA32_SIGCODE_OFFSET 0x%s\n",$1} + /__vdso_freebsd4_ia32_sigcode/{printf "#define VDSO_FREEBSD4_IA32_SIGCODE_OFFSET 0x%s\n",$1} + /__vdso_ia32_osigcode/{printf "#define VDSO_IA32_OSIGCODE_OFFSET 0x%s\n",$1} + /__vdso_lcall_tramp/{printf "#define VDSO_LCALL_TRAMP_OFFSET 0x%s\n",$1}' \ + >vdso_ia32_offsets.h