aboutsummaryrefslogtreecommitdiff
path: root/sys/conf/kmod_syms.awk
diff options
context:
space:
mode:
authorMike Smith <msmith@FreeBSD.org>2002-01-10 03:52:01 +0000
committerMike Smith <msmith@FreeBSD.org>2002-01-10 03:52:01 +0000
commit0b3178a45cd08a2387bff09a2844deacc97ae1e7 (patch)
treea46273f1dcbfd2cfbd291fc3b4703733694f4f69 /sys/conf/kmod_syms.awk
parent9539704639fd714405e0636bb7dac477730f2a61 (diff)
downloadsrc-0b3178a45cd08a2387bff09a2844deacc97ae1e7.tar.gz
src-0b3178a45cd08a2387bff09a2844deacc97ae1e7.zip
Eliminate the use of commons in the kernel and modules,
simplifying the module linking process and eliminating the risks associated with doubly-defined variables. Cases where commons were legitimately used (detection of compiled-in subsystems) have been converted to use sysinits, and any new code should use this or an equivalent practice as a matter of course. Modules can override this behaviour by substituting -fno-common out of ${CFLAGS} in cases where commons are necessary (eg. third-party object modules). Commons will be resolved and allocated space when the kld is linked as part of the module build process, so they will not pose a risk to the kernel or other modules. Provide a mechanism for controlling the export of symbols from the module namespace. The EXPORT_SYMS variable may be set in the Makefile to NO (export no symbols), a list of symbols to export, or the name of a file containing a newline-seperated list of symbols to be exported. Non-exported symbols are converted to local symbols. If EXPORT_SYMS is not set, all global symbols are currently exported. This behaviour is expected to change (to exporting no symbols) once modules have been converted. Reviewed by: peter (in principle) Obtained from: green (kmod_syms.awk)
Notes
Notes: svn path=/head/; revision=89180
Diffstat (limited to 'sys/conf/kmod_syms.awk')
-rw-r--r--sys/conf/kmod_syms.awk27
1 files changed, 27 insertions, 0 deletions
diff --git a/sys/conf/kmod_syms.awk b/sys/conf/kmod_syms.awk
new file mode 100644
index 000000000000..3aa3eeb61f52
--- /dev/null
+++ b/sys/conf/kmod_syms.awk
@@ -0,0 +1,27 @@
+# $FreeBSD$
+
+# Read global symbols from object file.
+BEGIN {
+ while ("nm -g " ARGV[1] | getline) {
+ if (match($0, /^[^[:space:]]+ [^AU] (.*)$/)) {
+ syms[$3] = $2
+ }
+ }
+}
+
+# De-list symbols from the export list.
+// {
+ if (ARGIND == 1)
+ nextfile
+ delete syms[$0]
+}
+
+# Strip commons, make everything else local.
+END {
+ for (member in syms) {
+ if (syms[member] == "C")
+ print "-N" member
+ else
+ print "-L" member
+ }
+}