diff --git a/lib/Makefile b/lib/Makefile --- a/lib/Makefile +++ b/lib/Makefile @@ -210,6 +210,10 @@ SUBDIR.${MK_BHYVE}+= libvmmapi .endif +.if ${MACHINE_CPUARCH} != "aarch64" && ${MACHINE_CPUARCH} != "riscv" +SUBDIR+= libsbrk +.endif + .if ${MACHINE_ARCH} != "powerpc" && ${MACHINE_CPUARCH} != "arm" SUBDIR.${MK_OPENMP}+= libomp .endif diff --git a/lib/libsbrk/Makefile b/lib/libsbrk/Makefile new file mode 100644 --- /dev/null +++ b/lib/libsbrk/Makefile @@ -0,0 +1,11 @@ +PACKAGE= clibs +LIB= sbrk +SHLIB_MAJOR= 1 + +LDFLAGS+=-Wl,--filter=libc.so.7 +VERSION_DEF=${SRCTOP}/lib/libc/Versions.def +SYMBOL_MAPS=${.CURDIR}/Symbol.map + +SRCS= ${LIB}.c + +.include diff --git a/lib/libsbrk/Symbol.map b/lib/libsbrk/Symbol.map new file mode 100644 --- /dev/null +++ b/lib/libsbrk/Symbol.map @@ -0,0 +1,3 @@ +FBSD_1.0 { + sbrk; +}; diff --git a/lib/libsbrk/sbrk.c b/lib/libsbrk/sbrk.c new file mode 100644 --- /dev/null +++ b/lib/libsbrk/sbrk.c @@ -0,0 +1,42 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2023 SRI International + * + * This software was developed by SRI International, the University of + * Cambridge Computer Laboratory (Department of Computer Science and + * Technology), and Capabilities Limited under Defense Advanced Research + * Projects Agency (DARPA) Contract No. HR001122S0003 ("MTSS"). + * + * 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 + +void *sbrk(intptr_t); +void *libc_sbrk(intptr_t); + +asm (".symver libc_sbrk, sbrk@FBSD_1.0"); + +void *sbrk(intptr_t incr) { + return (libc_sbrk(incr)); +} diff --git a/lib/libsys/brk.2 b/lib/libsys/brk.2 --- a/lib/libsys/brk.2 +++ b/lib/libsys/brk.2 @@ -33,7 +33,7 @@ .Nm sbrk .Nd change data segment size .Sh LIBRARY -.Lb libc +.Lb libsbrk .Sh SYNOPSIS .In unistd.h .Ft int @@ -51,6 +51,11 @@ They are deprecated and not declared or directly linkable in libc on any architectures as of .Fx 15.0 . +The +.Fn sbrk +function may be directly declared and linked by linking via the libsbrk +library, but the kernel may not support it if backwards compatibility is +not configured. They are not available on the aarch64 or riscv architectures. The .Xr mmap 2 diff --git a/rescue/rescue/Makefile b/rescue/rescue/Makefile --- a/rescue/rescue/Makefile +++ b/rescue/rescue/Makefile @@ -146,7 +146,7 @@ CRUNCH_LIBS+= -l80211 -lalias -lcam -lncursesw -ldevstat -lipsec -llzma CRUNCH_LIBS_camcontrol+= ${LIBNVMF} .if ${MK_ZFS} != "no" -CRUNCH_LIBS+= -lavl -lpthread -luutil -lumem -ltpool -lspl -lrt +CRUNCH_LIBS+= -lavl -lpthread -lsys -luutil -lumem -ltpool -lspl -lrt CRUNCH_LIBS_zfs+= ${LIBBE} \ ${LIBZPOOL} \ ${LIBZFS} \ @@ -167,7 +167,7 @@ ${LIBNVPAIR} .else # liblzma needs pthread -CRUNCH_LIBS+= -lpthread +CRUNCH_LIBS+= -lpthread -lsys .endif CRUNCH_LIBS+= -lgeom -lbsdxml -lkiconv .if ${MK_OPENSSL} == "no"