Commit e28f8379 authored by Bernardo Innocenti's avatar Bernardo Innocenti Committed by Linus Torvalds

[PATCH] GCC 3.3.x/3.4 compatiblity fix in include/linux/init.h

GCC 3.4 miscompiles the kernel because it silently optimizes away
data placed in the .init.setup section by the __setup() macro.

__attribute__((unused)) does only avoid the warning, but doesn't
mark the data as being used.

Since GCC 3.3, __attribute__((used)) should be applied to such
variables.  The __attribute_used__ macro from linux/compiler.h already
takes care of compiler differences for us.

In this patch, I've gone a step further and proactively fixed that in
all places.
parent a888efe7
......@@ -43,12 +43,12 @@
#define __init __attribute__ ((__section__ (".init.text")))
#define __initdata __attribute__ ((__section__ (".init.data")))
#define __exitdata __attribute__ ((__section__(".exit.data")))
#define __exit_call __attribute__ ((unused,__section__ (".exitcall.exit")))
#define __exit_call __attribute_used__ __attribute__ ((__section__ (".exitcall.exit")))
#ifdef MODULE
#define __exit __attribute__ ((__section__(".exit.text")))
#else
#define __exit __attribute__ ((unused,__section__(".exit.text")))
#define __exit __attribute_used__ __attribute__ ((__section__(".exit.text")))
#endif
/* For assembly routines */
......@@ -79,7 +79,8 @@ extern initcall_t __security_initcall_start, __security_initcall_end;
*/
#define __define_initcall(level,fn) \
static initcall_t __initcall_##fn __attribute__ ((unused,__section__ (".initcall" level ".init"))) = fn
static initcall_t __initcall_##fn __attribute_used__ \
__attribute__((__section__(".initcall" level ".init"))) = fn
#define core_initcall(fn) __define_initcall("1",fn)
#define postcore_initcall(fn) __define_initcall("2",fn)
......@@ -95,10 +96,12 @@ extern initcall_t __security_initcall_start, __security_initcall_end;
static exitcall_t __exitcall_##fn __exit_call = fn
#define console_initcall(fn) \
static initcall_t __initcall_##fn __attribute__ ((unused,__section__ (".con_initcall.init")))=fn
static initcall_t __initcall_##fn \
__attribute_used__ __attribute__((__section__(".con_initcall.init")))=fn
#define security_initcall(fn) \
static initcall_t __initcall_##fn __attribute__ ((unused,__section__ (".security_initcall.init"))) = fn
static initcall_t __initcall_##fn \
__attribute_used__ __attribute__((__section__(".security_initcall.init"))) = fn
struct obs_kernel_param {
const char *str;
......@@ -109,7 +112,8 @@ struct obs_kernel_param {
#define __setup(str, fn) \
static char __setup_str_##fn[] __initdata = str; \
static struct obs_kernel_param __setup_##fn \
__attribute__((unused,__section__ (".init.setup"))) \
__attribute_used__ \
__attribute__((__section__(".init.setup"))) \
= { __setup_str_##fn, fn }
#endif /* __ASSEMBLY__ */
......
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