From: Kirill Tkhai <tkhai@yandex.ru>
To: mmarek@suse.cz, arnd@arndb.de, linux-kbuild@vger.kernel.org,
gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org,
oleg@redhat.com, grant.likely@secretlab.ca,
ebiederm@xmission.com, akpm@linux-foundation.org,
ktkhai@parallels.com, sam@ravnborg.org
Subject: [PATCH 2/3] core: Save list of built-in drivers names
Date: Sun, 14 Sep 2014 14:18:35 +0400 [thread overview]
Message-ID: <20140914101831.3745.78412.stgit@localhost> (raw)
In-Reply-To: <20140914100545.3745.23394.stgit@localhost>
Create section *(__builtin_drivers_list) to store the list of drivers names.
Every driver name "modname" from directory "moddir" will be stored in array:
const char moddir_modname[] __attribute__((section("__builtin_drivers_list")) = "modname";
Using moddir prefix for variables names to prevent linking breakage
on the set of all architectures where dupricate names present.
The name template should be transmormed in something like __modname__name
in the future to catch duplicates, but now it's impossible.
Signed-off-by: Kirill Tkhai <ktkhai@parallels.com>
---
include/asm-generic/vmlinux.lds.h | 3 +++
scripts/Makefile.build | 14 ++++++++++----
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 5ba0360..5bc6d56 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -237,6 +237,9 @@
*(__tracepoints_ptrs) /* Tracepoints: pointer array */\
VMLINUX_SYMBOL(__stop___tracepoints_ptrs) = .; \
*(__tracepoints_strings)/* Tracepoints: strings */ \
+ VMLINUX_SYMBOL(__start_builtin_drivers_list) = .; \
+ *(__builtin_drivers_list) \
+ VMLINUX_SYMBOL(__stop_builtin_drivers_list) = .; \
} \
\
.rodata1 : AT(ADDR(.rodata1) - LOAD_OFFSET) { \
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index bf3e677..e158a4d 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -136,6 +136,7 @@ $(obj-m) : quiet_modtag := [M]
# Default for not multi-part modules
modname = $(basetarget)
+modname_c_var = `echo $(kbuild-dir)/$(modname) | sed 's/\.\///g' | sed 's/-/_/g' | sed 's/\//__/g'`
$(multi-objs-m) : modname = $(modname-multi)
$(multi-objs-m:.o=.i) : modname = $(modname-multi)
@@ -376,11 +377,16 @@ $(filter $(addprefix $(obj)/, \
$($(subst $(obj)/,,$(@:.o=-objs))) \
$($(subst $(obj)/,,$(@:.o=-y)))), $^)
-quiet_cmd_link_multi-y = LD $@
-cmd_link_multi-y = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) $(cmd_secanalysis)
-
quiet_cmd_link_multi-m = LD [M] $@
-cmd_link_multi-m = $(cmd_link_multi-y)
+cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) $(cmd_secanalysis)
+
+quiet_cmd_link_multi-y = LD $@
+cmd_link_multi-y = \
+ echo "const char "$(modname_c_var)"[] __attribute__((section(\"__builtin_drivers_list\"))) " \
+ "__attribute__ ((aligned(sizeof(unsigned long)))) = \""$(modname)"\";" > $(kbuild-dir)/.$(modname).c; \
+ $(CC) $(c_flags) -c $(kbuild-dir)/.$(modname).c -o $(kbuild-dir)/.$(modname).o; \
+ $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) $(kbuild-dir)/.$(modname).o $(cmd_secanalysis); \
+ rm -f $(kbuild-dir)/.$(modname).c
# We would rather have a list of rules like
# foo.o: $(foo-objs)
next prev parent reply other threads:[~2014-09-14 10:19 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-14 10:18 [PATCH 0/3] Implement /proc/built-in file similar to /proc/modules Kirill Tkhai
2014-09-14 10:18 ` [PATCH 1/3] kbuild: Make targets names tree-wide unique on x86 Kirill Tkhai
2014-09-14 15:57 ` Peter Foley
2014-09-14 18:09 ` Kirill Tkhai
2014-09-14 10:18 ` Kirill Tkhai [this message]
2014-09-14 10:19 ` [PATCH 3/3] core: create /proc/built-in file to show the list of built-in drivers Kirill Tkhai
2014-09-14 15:38 ` [PATCH 0/3] Implement /proc/built-in file similar to /proc/modules Greg KH
2014-09-14 17:27 ` Oleg Nesterov
2014-09-14 17:57 ` Kirill Tkhai
2014-09-14 18:12 ` Richard Weinberger
2014-09-14 18:58 ` Kirill Tkhai
2014-09-14 20:00 ` Oleg Nesterov
2014-09-14 17:31 ` Kirill Tkhai
2014-09-14 17:39 ` Greg KH
2014-09-14 18:05 ` Kirill Tkhai
2014-09-14 18:13 ` Greg KH
2014-09-14 18:35 ` Kirill Tkhai
2014-09-14 18:56 ` Greg KH
2014-09-15 11:50 ` Kirill Tkhai
2014-09-16 15:40 ` Lucas De Marchi
2014-09-15 9:17 ` Michal Marek
2014-09-15 9:12 ` Michal Marek
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=20140914101831.3745.78412.stgit@localhost \
--to=tkhai@yandex.ru \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=ebiederm@xmission.com \
--cc=grant.likely@secretlab.ca \
--cc=gregkh@linuxfoundation.org \
--cc=ktkhai@parallels.com \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mmarek@suse.cz \
--cc=oleg@redhat.com \
--cc=sam@ravnborg.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;
as well as URLs for NNTP newsgroup(s).