zsh-workers
 help / color / mirror / code / Atom feed
From: "Jun. T" <takimoto-j@kba.biglobe.ne.jp>
To: zsh-workers@zsh.org
Subject: Re: [Bug] modules zsh/tcp, zsh/zftp unloadable, probably affecting most modern Linuxes
Date: Fri, 23 Jun 2023 22:41:39 +0900	[thread overview]
Message-ID: <D50EE265-8AA0-4412-B757-679AC26796D8@kba.biglobe.ne.jp> (raw)
In-Reply-To: <5E054934-C1FA-490E-9D4E-64E73907B280@kba.biglobe.ne.jp>

load_module("zsh/zftp", ...) is so designed that if
add_dep("zsh/zftp", "zsh/net/tcp")
is called before calling it (for example in init.c) then tcp
module is loaded before loading zftp (module.c, line 2268).

The patch below modifies mkbltnmlst.sh so that it outputs
the add_dep() in bltinmods.list.

Please test on Linux with LDFLAGS='-Wl,-z,relro -Wl,-z,now'.


diff --git a/Src/Modules/zftp.c b/Src/Modules/zftp.c
index 49b3ffa89..47a5e9de9 100644
--- a/Src/Modules/zftp.c
+++ b/Src/Modules/zftp.c
@@ -3172,7 +3172,7 @@ static struct features module_features = {
 int
 setup_(UNUSED(Module m))
 {
-    return (require_module("zsh/net/tcp", NULL, 0) == 1);
+    return 0;
 }
 
 /**/
diff --git a/Src/mkbltnmlst.sh b/Src/mkbltnmlst.sh
index c4611d8b3..ea7d5ac3d 100644
--- a/Src/mkbltnmlst.sh
+++ b/Src/mkbltnmlst.sh
@@ -76,6 +76,30 @@ for x_mod in $x_mods; do
     test "x$linked" = xno && echo "#endif"
 done
 
+# if dynamic module 'mod' with load=no has moddeps in its .mdd,
+# then output add_dep(mod, dep) for each 'mod' in moddeps.
+dyn_mods="`grep ' link=dynamic .* load=no ' $CFMOD | \
+          sed -e '/^#/d' -e 's/ .*/ /' -e 's/^name=/ /'`"
+
+for mod in $dyn_mods; do
+    modfile="`grep '^name='$mod' ' $CFMOD | \
+              sed -e 's/^.* modfile=//' -e 's/ .*//'`"
+    if test "x$modfile" = x; then
+	echo >&2 "WARNING: no name for \`$mod' in $CFMOD (ignored)"
+	continue
+    fi
+    unset moddeps
+    . $srcdir/../$modfile
+    if test -n "$moddeps"; then
+        echo '#ifdef DYNAMIC'
+        echo "/* non-linked-in known module \`$mod' */"
+        for dep in $moddeps; do
+          echo "  add_dep(\"$mod\", \"$dep\");"
+        done
+        echo '#endif'
+    fi
+done
+
 echo
 done_mods=" "
 for bin_mod in $bin_mods; do




  reply	other threads:[~2023-06-23 13:42 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-04 13:51 Marcus Müller
2023-06-04 20:37 ` Marcus Müller
2023-06-04 21:17   ` Philippe Troin
2023-06-05 19:35     ` Marcus Müller
2023-06-05 20:07       ` Bart Schaefer
2023-06-06  6:42         ` Jun T
2023-06-06  9:05           ` Peter Stephenson
2023-06-06 14:38             ` Jun. T
2023-06-06 15:01               ` Peter Stephenson
2023-06-06 16:37                 ` Philippe Troin
2023-06-06 17:54                   ` Mikael Magnusson
2023-06-07  2:05                     ` Jun T
2023-06-07  2:35                       ` Jun T
2023-06-07 14:40                         ` Jun. T
2023-06-23 13:41                           ` Jun. T [this message]
2023-06-07  9:25         ` Marcus Müller
2023-06-04 22:41   ` Axel Beckert

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=D50EE265-8AA0-4412-B757-679AC26796D8@kba.biglobe.ne.jp \
    --to=takimoto-j@kba.biglobe.ne.jp \
    --cc=zsh-workers@zsh.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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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 NNTP newsgroup(s).