public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Flavio Cruz <flaviocruz@gmail.com>
To: libc-alpha@sourceware.org
Cc: bugaevc@gmail.com, samuel.thibault@gnu.org, bug-hurd@gnu.org
Subject: [PATCH] Define mig_strlen and __mig_strlen to support dynamically sized strings in hurd RPCs
Date: Sat, 29 Apr 2023 20:27:36 -0400	[thread overview]
Message-ID: <ZE21+AbyHtzYzU/c@jupiter.tail36e24.ts.net> (raw)

We make lib{mach,hurd}user.so call __mig_strlen which can be
relocated before libc.so is relocated, similar to what is done with
__mig_memcpy.
---
 mach/Makefile                       |  2 +-
 mach/Versions                       |  4 ++++
 mach/mach/mig_support.h             |  2 ++
 mach/mig_strlen.c                   | 27 +++++++++++++++++++++++++++
 sysdeps/mach/hurd/i386/libc.abilist |  1 +
 5 files changed, 35 insertions(+), 1 deletion(-)
 create mode 100644 mach/mig_strlen.c

diff --git a/mach/Makefile b/mach/Makefile
index 39358fdb83..a5d1252f95 100644
--- a/mach/Makefile
+++ b/mach/Makefile
@@ -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 \
diff --git a/mach/Versions b/mach/Versions
index b525cfdcf9..2dff5c477e 100644
--- a/mach/Versions
+++ b/mach/Versions
@@ -61,6 +61,9 @@ libc {
   GLIBC_2.32 {
     mach_print;
   }
+  GLIBC_2.38 {
+    mig_strlen;
+  }
 
   HURD_CTHREADS_0.3 {
     __mutex_init; __mutex_lock; __mutex_lock_solid; __mutex_trylock;
@@ -71,5 +74,6 @@ libc {
   GLIBC_PRIVATE {
     # functions used by RPC stubs
     __mig_memcpy;
+    __mig_strlen;
   }
 }
diff --git a/mach/mach/mig_support.h b/mach/mach/mig_support.h
index 78d4c4f0e3..3108e0af56 100644
--- a/mach/mach/mig_support.h
+++ b/mach/mach/mig_support.h
@@ -53,6 +53,8 @@ extern void mig_reply_setup (const mach_msg_header_t *__request,
 /* Idiocy support function.  */
 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 vm_size_t mig_strlen (const char *__src);
+extern vm_size_t __mig_strlen (const char *__src);
 
 extern void *__mig_memcpy (void *__dst, const void *__src, vm_size_t __len);
 
diff --git a/mach/mig_strlen.c b/mach/mig_strlen.c
new file mode 100644
index 0000000000..65e39b9bdf
--- /dev/null
+++ b/mach/mig_strlen.c
@@ -0,0 +1,27 @@
+/* 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);
+}
+weak_alias (__mig_strlen, mig_strlen)
diff --git a/sysdeps/mach/hurd/i386/libc.abilist b/sysdeps/mach/hurd/i386/libc.abilist
index 6925222ff3..ac7d06e385 100644
--- a/sysdeps/mach/hurd/i386/libc.abilist
+++ b/sysdeps/mach/hurd/i386/libc.abilist
@@ -2326,6 +2326,7 @@ GLIBC_2.38 __isoc23_wcstoull F
 GLIBC_2.38 __isoc23_wcstoull_l F
 GLIBC_2.38 __isoc23_wcstoumax F
 GLIBC_2.38 __isoc23_wscanf F
+GLIBC_2.38 mig_strlen F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
-- 
2.39.2


             reply	other threads:[~2023-04-30  0:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-30  0:27 Flavio Cruz [this message]
2023-04-30 22:56 ` Samuel Thibault

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZE21+AbyHtzYzU/c@jupiter.tail36e24.ts.net \
    --to=flaviocruz@gmail.com \
    --cc=bug-hurd@gnu.org \
    --cc=bugaevc@gmail.com \
    --cc=libc-alpha@sourceware.org \
    --cc=samuel.thibault@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).