aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/kern_linker.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern/kern_linker.c')
-rw-r--r--sys/kern/kern_linker.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c
index 08b85867d781..3f34bb12aeaa 100644
--- a/sys/kern/kern_linker.c
+++ b/sys/kern/kern_linker.c
@@ -906,6 +906,20 @@ linker_file_lookup_symbol_internal(linker_file_t file, const char *name,
KLD_DPF(SYM, ("linker_file_lookup_symbol: file=%p, name=%s, deps=%d\n",
file, name, deps));
+ /*
+ * Treat the __this_linker_file as a special symbol. This is a
+ * global that linuxkpi uses to populate the THIS_MODULE
+ * value. In this case we can simply return the linker_file_t.
+ *
+ * Modules compiled statically into the kernel are assigned NULL.
+ */
+ if (strcmp(name, "__this_linker_file") == 0) {
+ address = (file == linker_kernel_file) ? NULL : (caddr_t)file;
+ KLD_DPF(SYM, ("linker_file_lookup_symbol: resolving special "
+ "symbol __this_linker_file to %p\n", address));
+ return (address);
+ }
+
if (LINKER_LOOKUP_SYMBOL(file, name, &sym) == 0) {
LINKER_SYMBOL_VALUES(file, sym, &symval);
if (symval.value == 0)