#!/bin/sh1# SPDX-License-Identifier: BSD-2-Clause2#3# Copyright (c) 2021 The FreeBSD Foundation4# All rights reserved.5#6# This software was developed by Konstantin Belousov <[email protected]>7# under sponsorship from the FreeBSD Foundation.8#9# Redistribution and use in source and binary forms, with or without10# modification, are permitted provided that the following conditions11# are met:12# 1. Redistributions of source code must retain the above copyright13# notice, this list of conditions and the following disclaimer.14# 2. Redistributions in binary form must reproduce the above copyright15# notice, this list of conditions and the following disclaimer in the16# documentation and/or other materials provided with the distribution.17#18# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND19# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE20# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE21# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE22# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL23# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS24# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)25# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT26# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF28# SUCH DAMAGE.2930set -e3132${CC} -x assembler-with-cpp -DLOCORE -fPIC -nostdinc -c -m32 \33-o ia32_sigtramp.pico -I. -I"${S}" -include opt_global.h \34"${S}"/amd64/ia32/ia32_sigtramp.S3536if ${LD} --version | ${AWK} '/^GNU ld/{exit 1}' ; then37RODYNAMIC="-z rodynamic"38else39RODYNAMIC=""40fi41${LD} --shared -Bsymbolic -soname="elf-vdso32.so.1" \42-T "${S}"/conf/vdso_amd64_ia32.ldscript \43--eh-frame-hdr --no-undefined ${RODYNAMIC} -z norelro -nmagic \44--hash-style=sysv --fatal-warnings --strip-all \45-o elf-vdso32.so.1 ia32_sigtramp.pico4647if [ "$(wc -c elf-vdso32.so.1 | ${AWK} '{print $1}')" -gt 2048 ]48then49echo "elf-vdso32.so.1 too large" 1>&250exit 151fi5253if [ -n "$(${ELFDUMP} -d elf-vdso32.so.1 | \54${AWK} '/DT_REL.*SZ/{print "RELOCS"}')" ]55then56echo "elf-vdso32.so.1 contains runtime relocations" 1>&257exit 158fi5960${CC} -x assembler-with-cpp -DLOCORE -fPIC -nostdinc -c \61-o elf-vdso32.so.o -I. -I"${S}" -include opt_global.h \62-DVDSO_NAME=elf_vdso32_so_1 -DVDSO_FILE=\"elf-vdso32.so.1\" \63"${S}"/tools/vdso_wrap.S6465${NM} -D elf-vdso32.so.1 | ${AWK} \66'/__vdso_ia32_sigcode/{printf "#define VDSO_IA32_SIGCODE_OFFSET 0x%s\n",$1}67/__vdso_freebsd4_ia32_sigcode/{printf "#define VDSO_FREEBSD4_IA32_SIGCODE_OFFSET 0x%s\n",$1}68/__vdso_ia32_osigcode/{printf "#define VDSO_IA32_OSIGCODE_OFFSET 0x%s\n",$1}69/__vdso_lcall_tramp/{printf "#define VDSO_LCALL_TRAMP_OFFSET 0x%s\n",$1}' \70>vdso_ia32_offsets.h717273