Our in-kernel linker does not understand weak references. It would
be a lot of work to implement, and there are some issues that would
need to be considered carefully.
For example, if module A defines a weak alias, and module B is loaded
and resolves the alias, what do you do if module C gets loaded and we
discover a "strong" definition of the same symbol? Do you keep the
original resolution, or do you re-resolve it to the new definition?
On Mon, 9 Mar 2020, Rin Okuyama wrote:
Hi,
modload(8) fails if some depended functions are alias, at least
on m68k. For example:
# uname -a
NetBSD 9.99.49 NetBSD 9.99.49 (GENERIC) #6: Mon Mar 9 22:53:07 JST 2020 rin@latipes:/build/src/sys/arch/sun2/compile/GENERIC sun2
# modload nfs
[xxx.xxx] kobj_checksyms, 998: [nfs]: linker error: symbol '__ffssi2' not found
[xxx.xxx] WARNING: module error: unable to affix module 'nfs', error 8
modload: nfs: Exec format error
#
Here, __ffssi4 is weak alias of ffs on m68k:
# nm /netbsd | grep __ffssi2
0012327c W __ffssi2
# nm /netbsd | grep 0012327c
0012327c W __ffssi2
0012327c T ffs
#
If this symbol is turned into a ``real'' object by attached patch,
modload(8) and loaded module work fine:
# nm /netbsd | grep __ffssi4
0012327c T __ffssi2
# modload nfs
# mount_nfs server:/path /mnt
# ls /mnt
foo bar baz ...
#
Is this a bug or feature? How can I fix this problem?
Thanks,
rin
----
Index: common/lib/libc/arch/m68k/string/ffs.S
===================================================================
RCS file: /cvsroot/src/common/lib/libc/arch/m68k/string/ffs.S,v
retrieving revision 1.7
diff -p -u -r1.7 ffs.S
--- common/lib/libc/arch/m68k/string/ffs.S 9 Mar 2020 13:36:10 -0000 1.7
+++ common/lib/libc/arch/m68k/string/ffs.S 9 Mar 2020 14:09:13 -0000
@@ -45,7 +45,11 @@
/* bit = ffs(value) */
+#ifdef _LIBC
WEAK_ALIAS(__ffssi2,ffs)
+#else /* KERNEL */
+#define ffs __ffssi2
+#endif
#if (!defined(__mc68010__) && !defined(__mcoldfire__)) || defined(__mcfisac__)
!DSPAM:5e664fb8246343444541299!
+--------------------+--------------------------+-----------------------+
| Paul Goyette | PGP Key fingerprint: | E-mail addresses: |
| (Retired) | FA29 0E3B 35AF E8AE 6651 | paul%whooppee.com@localhost |
| Software Developer | 0786 F758 55DE 53BA 7731 | pgoyette%netbsd.org@localhost |
+--------------------+--------------------------+-----------------------+