]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Define __mig_strlen to support dynamically sized strings in hurd RPCs
authorFlavio Cruz <flaviocruz@gmail.com>
Mon, 1 May 2023 00:09:49 +0000 (20:09 -0400)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Mon, 1 May 2023 00:24:04 +0000 (02:24 +0200)
We make lib{mach,hurd}user.so only call __mig_strlen which can be
relocated before libc.so is relocated, similar to what is done with
__mig_memcpy.
Message-Id: <ZE8DTRDpY2hpPZlJ@jupiter.tail36e24.ts.net>

mach/Makefile
mach/Versions
mach/mach/mig_support.h
mach/mig_strlen.c [new file with mode: 0644]
sysdeps/mach/include/mach/mig_support.h

index 39358fdb83752c3468b57370e5085d47d75df8e4..a5d1252f95025e5b86dea6d90f26406d4c409e02 100644 (file)
@@ -25,7 +25,7 @@ headers = mach_init.h mach.h mach_error.h mach-shortcuts.h mach/mach_traps.h \
 lock = spin-solid spin-lock mutex-init mutex-solid
 lock-headers = lock-intern.h spin-lock.h
 routines = $(mach-syscalls) $(mach-shortcuts) \
-          mach_init mig_strncpy mig_memcpy msg \
+          mach_init mig_strncpy mig_strlen mig_memcpy msg \
           mig-alloc mig-dealloc mig-reply \
           msg-destroy msgserver \
           mach_error errstring error_compat errsystems \
index b525cfdcf91c438ef19339043bb751c26d9ca31c..72e9d557db83a08f61cac76a92538a4447a7b500 100644 (file)
@@ -71,5 +71,6 @@ libc {
   GLIBC_PRIVATE {
     # functions used by RPC stubs
     __mig_memcpy;
+    __mig_strlen;
   }
 }
index 78d4c4f0e3c2d9565dcf32f5bd6341e58572f29d..c43fa953f87b62124301cf04694bc5d87db7680a 100644 (file)
@@ -55,5 +55,6 @@ extern vm_size_t mig_strncpy (char *__dst, const char *__src, vm_size_t __len);
 extern vm_size_t __mig_strncpy (char *__dst, const char *__src, vm_size_t);
 
 extern void *__mig_memcpy (void *__dst, const void *__src, vm_size_t __len);
+extern vm_size_t __mig_strlen (const char *__src);
 
 #endif /* mach/mig_support.h */
diff --git a/mach/mig_strlen.c b/mach/mig_strlen.c
new file mode 100644 (file)
index 0000000..3c5ef8d
--- /dev/null
@@ -0,0 +1,26 @@
+/* strlen stub for mig stubs in libmachuser and libhurduser.
+   Copyright (C) 2023 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <mach.h>
+#include <string.h>
+
+vm_size_t
+__mig_strlen (const char *src)
+{
+  return strlen (src);
+}
index 1888d481d229a89130a5e3352d47132a30970799..242f310a9c62caed66eed2a43c1c3c8c73ab7042 100644 (file)
@@ -9,10 +9,11 @@ libc_hidden_proto (__mig_init)
 # include <libc-symbols.h>
 
 # if defined USE_MULTIARCH && (IS_IN (libmachuser) || IS_IN (libhurduser))
-/* Avoid directly calling ifunc-enabled memcpy or strpcpy,
+/* Avoid directly calling ifunc-enabled memcpy or strlen,
    because they would introduce a relocation loop between lib*user and
    libc.so.  */
 #  define memcpy(dest, src, n) __mig_memcpy(dest, src, n)
+#  define strlen(src) __mig_strlen(src)
 # endif
 #endif