1 /* Copyright (C) 2008-2009 Ksplice, Inc.
2 * Authors: Anders Kaseorg, Tim Abbott, Jeff Arnold
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License, version 2.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
18 #include <linux/compile.h>
19 #include <linux/kernel.h>
20 #include <linux/version.h>
21 #include <linux/module.h>
22 #include <linux/uts.h>
23 #include <linux/utsname.h>
24 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
25 /* 63104eec234bdecb55fd9c15467ae00d0a3f42ac was after 2.6.17 */
26 #include <linux/utsrelease.h>
27 #endif /* LINUX_VERSION_CODE */
29 #ifdef CONFIG_PARAVIRT
30 #include <asm/paravirt.h>
31 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
32 /* 98de032b681d8a7532d44dfc66aa5c0c1c755a9d was after 2.6.21 */
33 #define paravirt_patch_site paravirt_patch
34 #endif /* LINUX_VERSION_CODE */
35 #endif /* CONFIG_PARAVIRT */
36 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
37 /* 8256e47cdc8923e9959eb1d7f95d80da538add80 was after 2.6.23 */
38 #include <linux/marker.h>
39 #endif /* LINUX_VERSION_CODE */
41 #include <asm/uaccess.h>
44 const struct ksplice_config config
45 __attribute__((section(".ksplice_config"))) = {
46 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)
47 /* eb8f689046b857874e964463619f09df06d59fad was after 2.6.24 */
48 /* Introduction of .cpuinit, .devinit, .meminit sections */
49 #ifndef CONFIG_HOTPLUG
51 #endif /* !CONFIG_HOTPLUG */
52 #ifndef CONFIG_HOTPLUG_CPU
54 #endif /* !CONFIG_HOTPLUG_CPU */
55 #ifndef CONFIG_MEMORY_HOTPLUG
57 #endif /* !CONFIG_MEMORY_HOTPLUG */
58 #endif /* LINUX_VERSION_CODE */
61 #define FIELD_ENDOF(t, f) (offsetof(t, f) + FIELD_SIZEOF(t, f))
63 const struct table_section table_sections
[]
64 __attribute__((section(".ksplice_table_sections"))) = {
67 .sect
= ".altinstructions",
68 .entry_size
= sizeof(struct alt_instr
),
69 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)
70 .entry_contents_size
= offsetof(struct alt_instr
, pad1
),
72 /* 1d8a1f6b51f6b195dfdcf05821be97edede5664a was after 2.6.24 */
73 .entry_contents_size
= offsetof(struct alt_instr
, pad
),
75 .entry_align
= __alignof__(struct alt_instr
),
77 .addr_offset
= offsetof(struct alt_instr
, instr
),
78 .other_sect
= ".altinstr_replacement",
79 .other_offset
= offsetof(struct alt_instr
, replacement
),
81 #endif /* CONFIG_X86 */
82 #if defined CONFIG_GENERIC_BUG && LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
84 .sect
= "__bug_table",
85 .entry_size
= sizeof(struct bug_entry
),
86 .entry_contents_size
= FIELD_ENDOF(struct bug_entry
, flags
),
87 .entry_align
= __alignof__(struct bug_entry
),
89 .addr_offset
= offsetof(struct bug_entry
, bug_addr
),
90 .other_offset
= offsetof(struct bug_entry
, line
),
92 #else /* !CONFIG_GENERIC_BUG || LINUX_VERSION_CODE < */
93 /* 91768d6c2bad0d2766a166f13f2f57e197de3458 was after 2.6.19 */
94 #endif /* CONFIG_GENERIC_BUG && LINUX_VERSION_CODE */
97 .entry_size
= sizeof(struct exception_table_entry
),
98 .entry_align
= __alignof__(struct exception_table_entry
),
100 .addr_offset
= offsetof(struct exception_table_entry
, insn
),
101 .other_sect
= ".fixup",
102 .other_offset
= offsetof(struct exception_table_entry
, fixup
),
104 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
105 /* 8256e47cdc8923e9959eb1d7f95d80da538add80 was after 2.6.23 */
108 .entry_size
= sizeof(struct marker
),
109 .entry_align
= __alignof__(struct marker
),
110 .other_sect
= "__markers_strings",
111 .other_offset
= offsetof(struct marker
, name
),
113 #endif /* LINUX_VERSION_CODE */
114 #ifdef CONFIG_PARAVIRT
116 .sect
= ".parainstructions",
117 .entry_size
= sizeof(struct paravirt_patch_site
),
118 .entry_contents_size
= FIELD_ENDOF(struct paravirt_patch_site
,
120 .entry_align
= __alignof__(struct paravirt_patch_site
),
122 .addr_offset
= offsetof(struct paravirt_patch_site
, instr
),
124 #endif /* CONFIG_PARAVIRT */
126 .sect
= ".smp_locks",
127 .entry_size
= sizeof(u8
*),
128 .entry_align
= __alignof__(u8
*),
134 .entry_size
= sizeof(struct kernel_symbol
),
135 .entry_align
= __alignof__(struct kernel_symbol
),
136 .other_offset
= offsetof(struct kernel_symbol
, name
),
137 #ifdef CONFIG_MODVERSIONS
138 .crc_size
= sizeof(unsigned long),
139 .crc_sect
= "__kcrctab",
140 #endif /* CONFIG_MODVERSIONS */
143 .sect
= "__ksymtab_gpl",
144 .entry_size
= sizeof(struct kernel_symbol
),
145 .entry_align
= __alignof__(struct kernel_symbol
),
146 .other_offset
= offsetof(struct kernel_symbol
, name
),
147 #ifdef CONFIG_MODVERSIONS
148 .crc_size
= sizeof(unsigned long),
149 .crc_sect
= "__kcrctab_gpl",
150 #endif /* CONFIG_MODVERSIONS */
152 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18) && defined(CONFIG_UNUSED_SYMBOLS)
153 /* f71d20e961474dde77e6558396efb93d6ac80a4b was after 2.6.17 */
155 .sect
= "__ksymtab_unused_gpl",
156 .entry_size
= sizeof(struct kernel_symbol
),
157 .entry_align
= __alignof__(struct kernel_symbol
),
158 .other_offset
= offsetof(struct kernel_symbol
, name
),
159 #ifdef CONFIG_MODVERSIONS
160 .crc_size
= sizeof(unsigned long),
161 .crc_sect
= "__kcrctab_unused_gpl",
162 #endif /* CONFIG_MODVERSIONS */
165 .sect
= "__ksymtab_unused",
166 .entry_size
= sizeof(struct kernel_symbol
),
167 .entry_align
= __alignof__(struct kernel_symbol
),
168 .other_offset
= offsetof(struct kernel_symbol
, name
),
169 #ifdef CONFIG_MODVERSIONS
170 .crc_size
= sizeof(unsigned long),
171 .crc_sect
= "__kcrctab_unused",
172 #endif /* CONFIG_MODVERSIONS */
174 #endif /* LINUX_VERSION_CODE */
175 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,17)
176 /* 9f28bb7e1d0188a993403ab39b774785892805e1 was after 2.6.16 */
178 .sect
= "__ksymtab_gpl_future",
179 .entry_size
= sizeof(struct kernel_symbol
),
180 .entry_align
= __alignof__(struct kernel_symbol
),
181 .other_offset
= offsetof(struct kernel_symbol
, name
),
182 #ifdef CONFIG_MODVERSIONS
183 .crc_size
= sizeof(unsigned long),
184 .crc_sect
= "__kcrctab_gpl_future",
185 #endif /* CONFIG_MODVERSIONS */
187 #endif /* LINUX_VERSION_CODE */
190 const char *__attribute__((section(".uts_sysname"))) sysname
= UTS_SYSNAME
;
191 const char *__attribute__((section(".uts_release"))) release
= UTS_RELEASE
;
192 const char *__attribute__((section(".uts_version"))) version
= UTS_VERSION
;
193 const char *__attribute__((section(".uts_machine"))) machine
= UTS_MACHINE
;