public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Brian Gerst <bgerst@didntduck.org>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] Move __this_module to modpost
Date: Thu, 25 Mar 2004 21:22:52 -0500	[thread overview]
Message-ID: <406393FC.2090306@quark.didntduck.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 183 bytes --]

Move the __this_module structure to the modpost code where it really 
belongs.  Also change the section to __module, which module-init-tools 
already knows about.

--
				Brian Gerst

[-- Attachment #2: this_module-1 --]
[-- Type: text/plain, Size: 3766 bytes --]

diff -urN linux-bk/arch/v850/Makefile linux/arch/v850/Makefile
--- linux-bk/arch/v850/Makefile	2003-12-17 22:00:01.000000000 -0500
+++ linux/arch/v850/Makefile	2004-03-25 16:21:12.000000000 -0500
@@ -22,11 +22,6 @@
 CFLAGS += -fno-builtin
 CFLAGS += -D__linux__ -DUTS_SYSNAME=\"uClinux\"
 
-# This prevents the linker from consolidating the .gnu.linkonce.this_module
-# section into .text (which the v850 default linker script for -r does for
-# some reason)
-LDFLAGS_MODULE += --unique=.gnu.linkonce.this_module
-
 OBJCOPY_FLAGS_BLOB := -I binary -O elf32-little -B v850e
 
 
diff -urN linux-bk/include/linux/module.h linux/include/linux/module.h
--- linux-bk/include/linux/module.h	2004-03-10 22:49:45.000000000 -0500
+++ linux/include/linux/module.h	2004-03-25 16:21:12.000000000 -0500
@@ -70,6 +70,7 @@
 extern const struct gtype##_id __mod_##gtype##_table		\
   __attribute__ ((unused, alias(__stringify(name))))
 
+extern struct module __this_module;
 #define THIS_MODULE (&__this_module)
 
 #else  /* !MODULE */
@@ -481,21 +482,6 @@
 
 #endif /* CONFIG_MODULES */
 
-#ifdef MODULE
-extern struct module __this_module;
-#ifdef KBUILD_MODNAME
-/* We make the linker do some of the work. */
-struct module __this_module
-__attribute__((section(".gnu.linkonce.this_module"))) = {
-	.name = __stringify(KBUILD_MODNAME),
-	.init = init_module,
-#ifdef CONFIG_MODULE_UNLOAD
-	.exit = cleanup_module,
-#endif
-};
-#endif /* KBUILD_MODNAME */
-#endif /* MODULE */
-
 #define symbol_request(x) try_then_request_module(symbol_get(x), "symbol:" #x)
 
 /* BELOW HERE ALL THESE ARE OBSOLETE AND WILL VANISH */
diff -urN linux-bk/kernel/module.c linux/kernel/module.c
--- linux-bk/kernel/module.c	2004-03-25 13:54:27.000000000 -0500
+++ linux/kernel/module.c	2004-03-25 16:25:06.000000000 -0500
@@ -1328,8 +1328,10 @@
 #endif
 	}
 
-	modindex = find_sec(hdr, sechdrs, secstrings,
-			    ".gnu.linkonce.this_module");
+	modindex = find_sec(hdr, sechdrs, secstrings, "__module");
+	if (!modindex) /* To be removed in 2.7.x */
+		modindex = find_sec(hdr, sechdrs, secstrings,
+				    ".gnu.linkonce.this_module");
 	if (!modindex) {
 		printk(KERN_WARNING "No module found in object\n");
 		err = -ENOEXEC;
diff -urN linux-bk/scripts/Makefile.modpost linux/scripts/Makefile.modpost
--- linux-bk/scripts/Makefile.modpost	2004-03-10 22:49:49.000000000 -0500
+++ linux/scripts/Makefile.modpost	2004-03-25 16:21:12.000000000 -0500
@@ -35,6 +35,8 @@
 
 # Compile version info for unresolved symbols
 
+modname = $(*F)
+
 quiet_cmd_cc_o_c = CC      $@
       cmd_cc_o_c = $(CC) $(c_flags) $(CFLAGS_MODULE)	\
 		   -c -o $@ $<
diff -urN linux-bk/scripts/modpost.c linux/scripts/modpost.c
--- linux-bk/scripts/modpost.c	2004-03-25 13:54:28.000000000 -0500
+++ linux/scripts/modpost.c	2004-03-25 21:16:24.024332688 -0500
@@ -355,6 +355,9 @@
 		/* ignore global offset table */
 		if (strcmp(symname, "_GLOBAL_OFFSET_TABLE_") == 0)
 			break;
+		/* ignore __this_module, it will be resolved shortly */
+		if (strcmp(symname, MODULE_SYMBOL_PREFIX "__this_module") == 0)
+			break;
 #ifdef STT_REGISTER
 		if (info->hdr->e_machine == EM_SPARC ||
 		    info->hdr->e_machine == EM_SPARCV9) {
@@ -480,6 +483,15 @@
 	buf_printf(b, "#include <linux/compiler.h>\n");
 	buf_printf(b, "\n");
 	buf_printf(b, "MODULE_INFO(vermagic, VERMAGIC_STRING);\n");
+	buf_printf(b, "\n");
+	buf_printf(b, "struct module __this_module\n");
+	buf_printf(b, "__attribute__((section(\"__module\"))) = {\n");
+	buf_printf(b, " .name = __stringify(KBUILD_MODNAME),\n");
+	buf_printf(b, " .init = init_module,\n");
+	buf_printf(b, "#ifdef CONFIG_MODULE_UNLOAD\n");
+	buf_printf(b, " .exit = cleanup_module,\n");
+	buf_printf(b, "#endif\n");
+	buf_printf(b, "};\n");
 }
 
 /* Record CRCs for unresolved symbols */

                 reply	other threads:[~2004-03-26  2:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=406393FC.2090306@quark.didntduck.org \
    --to=bgerst@didntduck.org \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.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