tables.h: make DECLARE_LINKTABLE() .data by default Upon review with hpa its better to have the shorter version for what we expect linker tables to be used for mostly, and that is data. DECLARE_LINKTABLE_TEXT() is then required for .text. Expand documentation on that we have then only two declarations also: o DECLARE_LINKTABLE() for data o DECLARE_LINKTABLE_RO() for read-only data The definitions are used to associate these with actual sections on the code that implements support for the table. Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
diff --git a/README b/README index 93e2d7e..f831932 100644 --- a/README +++ b/README
@@ -69,17 +69,27 @@ SECTION_TYPE_TABLES |.ranges | DECLARE_LINKTABLE*() | DEFINE_LINKTABLE*() ------------------------------------------------------------------------------- +There are only two declarations for linker tables, which would be used in +header files: + + o DECLARE_LINKTABLE() for data + o DECLARE_LINKTABLE_RO() for read-only data + The tables have a series of definitions (DEFINE_LINKTABLE_*()) given to help -with setup for the different supported Linux sections used. The definitions for -tables then are: +with setup for the different supported Linux sections used. The definitions +would be used in the code defining the use of tables -- the actual +implementation. + +The definitions currently supported for tables are: ------------------------------------------------------------------------------- Linux section | const-or-not | Definition ------------------------------------------------------------------------------- -.text | const | DEFINE_LINKTABLE() -.data | non-const | DEFINE_LINKTABLE_DATA() -.init | const | LINKTABLE_INIT() -.init.data | non-const | LINKTABLE_INIT_DATA() +.data | non-const | DEFINE_LINKTABLE() +.text | const | DEFINE_LINKTABLE_TEXT() +.init | const | DEFINE_LINKTABLE_INIT() +.init.data | non-const | DEFINE_LINKTABLE_INIT_DATA() +.rodata | const | DEFINE_LINKTABLE_RO() ------------------------------------------------------------------------------- x86 bzimage parser
diff --git a/arch/x86/include/asm/x86_init_fn.h b/arch/x86/include/asm/x86_init_fn.h index c035a89..2490dc7 100644 --- a/arch/x86/include/asm/x86_init_fn.h +++ b/arch/x86/include/asm/x86_init_fn.h
@@ -111,7 +111,7 @@ void (*early_init)(void); }; -DECLARE_LINKTABLE_DATA(struct x86_init_fn, x86_init_fns); +DECLARE_LINKTABLE(struct x86_init_fn, x86_init_fns); /* Init order levels, we can start at 0000 but reserve 0000-0999 for now */
diff --git a/include/linux/init.h b/include/linux/init.h index 14c6422..1951514 100644 --- a/include/linux/init.h +++ b/include/linux/init.h
@@ -11,8 +11,8 @@ typedef int (*initcall_t)(void); typedef void (*exitcall_t)(void); -DECLARE_LINKTABLE_DATA(initcall_t, init_calls); -DECLARE_LINKTABLE_DATA(exitcall_t, exit_calls); +DECLARE_LINKTABLE(initcall_t, init_calls); +DECLARE_LINKTABLE(exitcall_t, exit_calls); #define __define_initcall(fn, id) \ static LINKTABLE_INIT_DATA(init_calls, id) \
diff --git a/include/linux/tables.h b/include/linux/tables.h index 9b161ff..fce59fc 100644 --- a/include/linux/tables.h +++ b/include/linux/tables.h
@@ -33,14 +33,14 @@ (addr >= (unsigned long) LINUX_SECTION_START(tbl) && \ addr < (unsigned long) LINUX_SECTION_END(tbl)) -#define LINKTABLE_DATA_WEAK(name, level) \ +#define LINKTABLE_WEAK(name, level) \ __typeof__(name[0]) \ __attribute__((used, \ weak, \ __aligned__(LINUX_SECTION_ALIGN_STRUCT), \ section(SECTION_TBL(SECTION_DATA, name, level)))) -#define LINKTABLE_WEAK(name, level) \ +#define LINKTABLE_TEXT_WEAK(name, level) \ const __typeof__(name[0]) \ __attribute__((used, \ weak, \ @@ -70,16 +70,17 @@ section(SECTION_TBL(SECTION_INIT_DATA, name, level)))) #define LINKTABLE(name, level) \ + __typeof__(name[0]) \ + __attribute__((used, \ + __aligned__(LINUX_SECTION_ALIGN_FUNC), \ + section(SECTION_TBL(SECTION_DATA, name, level)))) + +#define LINKTABLE_TEXT(name, level) \ const __typeof__(name[0]) \ __attribute__((used, \ __aligned__(LINUX_SECTION_ALIGN_FUNC), \ section(SECTION_TBL(SECTION_TEXT, name, level)))) -#define LINKTABLE_DATA(name, level) \ - __typeof__(name[0]) \ - __attribute__((used, \ - __aligned__(LINUX_SECTION_ALIGN_FUNC), \ - section(SECTION_TBL(SECTION_DATA, name, level)))) #define LINKTABLE_RO(name, level) \ const __typeof__(name[0]) \ __attribute__((used, \ @@ -98,11 +99,11 @@ section(SECTION_TBL(SECTION_INIT_DATA, name, level)))) #define DECLARE_LINKTABLE(type, name) \ - DECLARE_LINUX_SECTION_RO(type, name) - -#define DECLARE_LINKTABLE_DATA(type, name) \ DECLARE_LINUX_SECTION(type, name) +#define DECLARE_LINKTABLE_RO(type, name) \ + DECLARE_LINUX_SECTION_RO(type, name) + #define DEFINE_LINKTABLE(type, name) \ DECLARE_LINKTABLE(type, name); \ LINKTABLE_WEAK(name, ) VMLINUX_SYMBOL(name)[0] = {}; \ @@ -110,36 +111,36 @@ LINKTABLE(name, ~) VMLINUX_SYMBOL(name##__end)[0] = {}; \ LTO_REFERENCE_INITCALL(name##__end); -#define DEFINE_LINKTABLE_DATA(type, name) \ - DECLARE_LINKTABLE_DATA(type, name); \ - LINKTABLE_DATA_WEAK(name, ) VMLINUX_SYMBOL(name)[0] = {}; \ +#define DEFINE_LINKTABLE_TEXT(type, name) \ + DECLARE_LINKTABLE_RO(type, name); \ + LINKTABLE_WEAK_TEXT(name, ) VMLINUX_SYMBOL(name)[0] = {}; \ LTO_REFERENCE_INITCALL(name); \ - LINKTABLE_DATA(name, ~) VMLINUX_SYMBOL(name##__end)[0] = {};\ + LINKTABLE_TEXT(name, ~) VMLINUX_SYMBOL(name##__end)[0] = {}; \ LTO_REFERENCE_INITCALL(name##__end); #define DEFINE_LINKTABLE_RO(type, name) \ - DECLARE_LINKTABLE(type, name); \ + DECLARE_LINKTABLE_RO(type, name); \ LINKTABLE_RO_WEAK(name, ) VMLINUX_SYMBOL(name)[0] = {}; \ LTO_REFERENCE_INITCALL(name); \ LINKTABLE_RO(name, ~) VMLINUX_SYMBOL(name##__end)[0] = {}; \ LTO_REFERENCE_INITCALL(name##__end); -#define DEFINE_LINKTABLE_INIT(type, name) \ - DECLARE_LINKTABLE(type, name); \ - LINKTABLE_INIT_WEAK(name, ) VMLINUX_SYMBOL(name)[0] = {}; \ - LTO_REFERENCE_INITCALL(name); \ +#define DEFINE_LINKTABLE_INIT(type, name) \ + DECLARE_LINKTABLE(type, name); \ + LINKTABLE_INIT_WEAK(name, ) VMLINUX_SYMBOL(name)[0] = {}; \ + LTO_REFERENCE_INITCALL(name); \ LINKTABLE_INIT(name, ~) VMLINUX_SYMBOL(name##__end)[0] = {}; \ LTO_REFERENCE_INITCALL(name##__end); -#define DEFINE_LINKTABLE_INIT_DATA(type, name) \ - DECLARE_LINKTABLE_DATA(type, name); \ - LINKTABLE_INIT_DATA_WEAK(name, ) VMLINUX_SYMBOL(name)[0] = {}; \ - LTO_REFERENCE_INITCALL(name); \ - LINKTABLE_INIT_DATA(name, ~) VMLINUX_SYMBOL(name##__end)[0] = {}; \ +#define DEFINE_LINKTABLE_INIT_DATA(type, name) \ + DECLARE_LINKTABLE(type, name); \ + LINKTABLE_INIT_DATA_WEAK(name, ) VMLINUX_SYMBOL(name)[0] = {}; \ + LTO_REFERENCE_INITCALL(name); \ + LINKTABLE_INIT_DATA(name, ~) VMLINUX_SYMBOL(name##__end)[0] = {};\ LTO_REFERENCE_INITCALL(name##__end); #define LINKTABLE_FOR_EACH(pointer, tbl) \ - for (pointer = LINUX_SECTION_START(tbl); \ + for (pointer = LINUX_SECTION_START(tbl); \ pointer < LINUX_SECTION_END(tbl); \ pointer++)