Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F98917147
D43002.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D43002.diff
View Options
diff --git a/lib/Makefile b/lib/Makefile
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -90,6 +90,7 @@
librss \
librt \
librtld_db \
+ libsbrk \
libsbuf \
libsmb \
libstdbuf \
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 <bsd.lib.mk>
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,44 @@
+/*-
+ * 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 <inttypes.h>
+
+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
@@ -81,6 +81,11 @@
function
sets the break to
.Fa addr .
+.Bf -symbolic
+It is implemented in the
+.Lb libc
+as a compatibility symbol and no mechanism is provided to link it.
+.Ef
.Pp
The
.Fn sbrk
@@ -95,6 +100,12 @@
the break is lowered by
.Fa incr
bytes.
+.Bf -symbolic
+It is implemented in the
+.Lb libc
+as a compatibility symbol and can be linked via the
+.Lb libsbrk .
+.Ef
.Sh NOTES
While the actual process data segment size maintained by the kernel will only
grow or shrink in page sizes, these functions allow setting the break
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Oct 6, 7:23 AM (22 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
13713771
Default Alt Text
D43002.diff (3 KB)
Attached To
Mode
D43002: libsbrk: add a trivial library that exposes sbrk
Attached
Detach File
Event Timeline
Log In to Comment