Commit b45a1476 authored by Kai Germaschewski's avatar Kai Germaschewski

kbuild: [PATCH] eliminate warnings in generated module files

From Richard Henderson:

> The compiler.h fragment should describe the problem well enough.

(I tested egcs 2.91.66, even there no problem)
parent 306a1aad
...@@ -377,7 +377,7 @@ cmd_kallsyms = $(NM) -n $< | scripts/kallsyms > $@ ...@@ -377,7 +377,7 @@ cmd_kallsyms = $(NM) -n $< | scripts/kallsyms > $@
$(call cmd,kallsyms) $(call cmd,kallsyms)
.tmp_vmlinux1: $(vmlinux-objs) arch/$(ARCH)/vmlinux.lds.s FORCE .tmp_vmlinux1: $(vmlinux-objs) arch/$(ARCH)/vmlinux.lds.s FORCE
$(call if_changed_rule,vmlinux__) +$(call if_changed_rule,vmlinux__)
.tmp_vmlinux2: $(vmlinux-objs) .tmp_kallsyms1.o arch/$(ARCH)/vmlinux.lds.s FORCE .tmp_vmlinux2: $(vmlinux-objs) .tmp_kallsyms1.o arch/$(ARCH)/vmlinux.lds.s FORCE
$(call if_changed_rule,vmlinux__) $(call if_changed_rule,vmlinux__)
......
...@@ -25,6 +25,23 @@ ...@@ -25,6 +25,23 @@
#define __deprecated #define __deprecated
#endif #endif
/*
* Allow us to avoid 'defined but not used' warnings on functions and data,
* as well as force them to be emitted to the assembly file.
*
* As of gcc 3.3, static functions that are not marked with attribute((used))
* may be elided from the assembly file. As of gcc 3.3, static data not so
* marked will not be elided, but this may change in a future gcc version.
*
* In prior versions of gcc, such functions and data would be emitted, but
* would be warned about except with attribute((unused)).
*/
#if __GNUC__ == 3 && __GNUC_MINOR__ >= 3 || __GNUC__ > 3
#define __attribute_used__ __attribute__((__used__))
#else
#define __attribute_used__ __attribute__((__unused__))
#endif
/* This macro obfuscates arithmetic on a variable address so that gcc /* This macro obfuscates arithmetic on a variable address so that gcc
shouldn't recognize the original var, and make assumptions about it */ shouldn't recognize the original var, and make assumptions about it */
#define RELOC_HIDE(ptr, off) \ #define RELOC_HIDE(ptr, off) \
......
...@@ -393,6 +393,7 @@ add_header(struct buffer *b) ...@@ -393,6 +393,7 @@ add_header(struct buffer *b)
{ {
buf_printf(b, "#include <linux/module.h>\n"); buf_printf(b, "#include <linux/module.h>\n");
buf_printf(b, "#include <linux/vermagic.h>\n"); buf_printf(b, "#include <linux/vermagic.h>\n");
buf_printf(b, "#include <linux/compiler.h>\n");
buf_printf(b, "\n"); buf_printf(b, "\n");
buf_printf(b, "const char vermagic[]\n"); buf_printf(b, "const char vermagic[]\n");
buf_printf(b, "__attribute__((section(\"__vermagic\"))) =\n"); buf_printf(b, "__attribute__((section(\"__vermagic\"))) =\n");
...@@ -458,6 +459,7 @@ add_depends(struct buffer *b, struct module *mod, struct module *modules) ...@@ -458,6 +459,7 @@ add_depends(struct buffer *b, struct module *mod, struct module *modules)
buf_printf(b, "\n"); buf_printf(b, "\n");
buf_printf(b, "static const char __module_depends[]\n"); buf_printf(b, "static const char __module_depends[]\n");
buf_printf(b, "__attribute_used__\n");
buf_printf(b, "__attribute__((section(\".modinfo\"))) =\n"); buf_printf(b, "__attribute__((section(\".modinfo\"))) =\n");
buf_printf(b, "\"depends="); buf_printf(b, "\"depends=");
for (s = mod->unres; s; s = s->next) { for (s = mod->unres; s; s = s->next) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment