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 */
40 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)
41 /* 97e1c18e8d17bd87e1e383b2e9d9fc740332c8e2 was after 2.6.27 */
42 #include <linux/tracepoint.h>
43 #endif /* LINUX_VERSION_CODE */
45 #include <asm/uaccess.h>
48 const struct ksplice_config config
49 __attribute__((section(".ksplice_config"))) = {
50 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)
51 /* eb8f689046b857874e964463619f09df06d59fad was after 2.6.24 */
52 /* Introduction of .cpuinit, .devinit, .meminit sections */
53 #ifndef CONFIG_HOTPLUG
55 #endif /* !CONFIG_HOTPLUG */
56 #ifndef CONFIG_HOTPLUG_CPU
58 #endif /* !CONFIG_HOTPLUG_CPU */
59 #ifndef CONFIG_MEMORY_HOTPLUG
61 #endif /* !CONFIG_MEMORY_HOTPLUG */
62 #endif /* LINUX_VERSION_CODE */
65 #define FIELD_ENDOF(t, f) (offsetof(t, f) + FIELD_SIZEOF(t, f))
67 const struct table_section table_sections
[]
68 __attribute__((section(".ksplice_table_sections"))) = {
71 .sect
= ".altinstructions",
72 .entry_size
= sizeof(struct alt_instr
),
73 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)
74 .entry_contents_size
= offsetof(struct alt_instr
, pad1
),
76 /* 1d8a1f6b51f6b195dfdcf05821be97edede5664a was after 2.6.24 */
77 .entry_contents_size
= offsetof(struct alt_instr
, pad
),
79 .entry_align
= __alignof__(struct alt_instr
),
81 .addr_offset
= offsetof(struct alt_instr
, instr
),
82 .other_sect
= ".altinstr_replacement",
83 .other_offset
= offsetof(struct alt_instr
, replacement
),
85 #endif /* CONFIG_X86 */
86 #if defined CONFIG_GENERIC_BUG && LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
88 .sect
= "__bug_table",
89 .entry_size
= sizeof(struct bug_entry
),
90 .entry_contents_size
= FIELD_ENDOF(struct bug_entry
, flags
),
91 .entry_align
= __alignof__(struct bug_entry
),
93 #ifdef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
95 .addr_offset
= offsetof(struct bug_entry
, bug_addr_disp
),
97 .other_offset
= offsetof(struct bug_entry
, file_disp
),
99 .addr_offset
= offsetof(struct bug_entry
, bug_addr
),
102 #else /* !CONFIG_GENERIC_BUG || LINUX_VERSION_CODE < */
103 /* 91768d6c2bad0d2766a166f13f2f57e197de3458 was after 2.6.19 */
104 #endif /* CONFIG_GENERIC_BUG && LINUX_VERSION_CODE */
106 .sect
= "__ex_table",
107 .entry_size
= sizeof(struct exception_table_entry
),
108 .entry_align
= __alignof__(struct exception_table_entry
),
110 .addr_offset
= offsetof(struct exception_table_entry
, insn
),
111 .other_sect
= ".fixup",
112 .other_offset
= offsetof(struct exception_table_entry
, fixup
),
114 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
115 /* 8256e47cdc8923e9959eb1d7f95d80da538add80 was after 2.6.23 */
118 .entry_size
= sizeof(struct marker
),
119 .entry_align
= __alignof__(struct marker
),
120 .other_sect
= "__markers_strings",
121 .other_offset
= offsetof(struct marker
, name
),
123 #endif /* LINUX_VERSION_CODE */
124 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)
125 /* 97e1c18e8d17bd87e1e383b2e9d9fc740332c8e2 was after 2.6.27 */
127 .sect
= "__tracepoints",
128 .entry_size
= sizeof(struct tracepoint
),
129 .entry_align
= __alignof__(struct tracepoint
),
130 .other_sect
= "__tracepoints_strings",
131 .other_offset
= offsetof(struct tracepoint
, name
),
133 #endif /* LINUX_VERSION_CODE */
134 #ifdef CONFIG_PARAVIRT
136 .sect
= ".parainstructions",
137 .entry_size
= sizeof(struct paravirt_patch_site
),
138 .entry_contents_size
= FIELD_ENDOF(struct paravirt_patch_site
,
140 .entry_align
= __alignof__(struct paravirt_patch_site
),
142 .addr_offset
= offsetof(struct paravirt_patch_site
, instr
),
144 #endif /* CONFIG_PARAVIRT */
146 .sect
= ".smp_locks",
147 .entry_size
= sizeof(u8
*),
148 .entry_align
= __alignof__(u8
*),
154 .entry_size
= sizeof(struct kernel_symbol
),
155 .entry_align
= __alignof__(struct kernel_symbol
),
156 .other_offset
= offsetof(struct kernel_symbol
, name
),
157 #ifdef CONFIG_MODVERSIONS
158 .crc_size
= sizeof(unsigned long),
159 .crc_sect
= "__kcrctab",
160 #endif /* CONFIG_MODVERSIONS */
163 .sect
= "__ksymtab_gpl",
164 .entry_size
= sizeof(struct kernel_symbol
),
165 .entry_align
= __alignof__(struct kernel_symbol
),
166 .other_offset
= offsetof(struct kernel_symbol
, name
),
167 #ifdef CONFIG_MODVERSIONS
168 .crc_size
= sizeof(unsigned long),
169 .crc_sect
= "__kcrctab_gpl",
170 #endif /* CONFIG_MODVERSIONS */
172 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18) && defined(CONFIG_UNUSED_SYMBOLS)
173 /* f71d20e961474dde77e6558396efb93d6ac80a4b was after 2.6.17 */
175 .sect
= "__ksymtab_unused_gpl",
176 .entry_size
= sizeof(struct kernel_symbol
),
177 .entry_align
= __alignof__(struct kernel_symbol
),
178 .other_offset
= offsetof(struct kernel_symbol
, name
),
179 #ifdef CONFIG_MODVERSIONS
180 .crc_size
= sizeof(unsigned long),
181 .crc_sect
= "__kcrctab_unused_gpl",
182 #endif /* CONFIG_MODVERSIONS */
185 .sect
= "__ksymtab_unused",
186 .entry_size
= sizeof(struct kernel_symbol
),
187 .entry_align
= __alignof__(struct kernel_symbol
),
188 .other_offset
= offsetof(struct kernel_symbol
, name
),
189 #ifdef CONFIG_MODVERSIONS
190 .crc_size
= sizeof(unsigned long),
191 .crc_sect
= "__kcrctab_unused",
192 #endif /* CONFIG_MODVERSIONS */
194 #endif /* LINUX_VERSION_CODE */
195 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,17)
196 /* 9f28bb7e1d0188a993403ab39b774785892805e1 was after 2.6.16 */
198 .sect
= "__ksymtab_gpl_future",
199 .entry_size
= sizeof(struct kernel_symbol
),
200 .entry_align
= __alignof__(struct kernel_symbol
),
201 .other_offset
= offsetof(struct kernel_symbol
, name
),
202 #ifdef CONFIG_MODVERSIONS
203 .crc_size
= sizeof(unsigned long),
204 .crc_sect
= "__kcrctab_gpl_future",
205 #endif /* CONFIG_MODVERSIONS */
207 #endif /* LINUX_VERSION_CODE */
210 const char *__attribute__((section(".uts_sysname"))) sysname
= UTS_SYSNAME
;
211 const char *__attribute__((section(".uts_release"))) release
= UTS_RELEASE
;
212 const char *__attribute__((section(".uts_version"))) version
= UTS_VERSION
;
213 const char *__attribute__((section(".uts_machine"))) machine
= UTS_MACHINE
;