module.c (29583dfcd2dd72c766422bd05c16f06c6b1fb356) | module.c (be84d8ed3f04e9154a3a55e29a27dcd416f05b31) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-or-later 2/* Kernel module help for x86. 3 Copyright (C) 2001 Rusty Russell. 4 5*/ 6 7#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 8 --- 237 unchanged lines hidden (view full) --- 246} 247 248#endif 249 250int module_finalize(const Elf_Ehdr *hdr, 251 const Elf_Shdr *sechdrs, 252 struct module *me) 253{ | 1// SPDX-License-Identifier: GPL-2.0-or-later 2/* Kernel module help for x86. 3 Copyright (C) 2001 Rusty Russell. 4 5*/ 6 7#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 8 --- 237 unchanged lines hidden (view full) --- 246} 247 248#endif 249 250int module_finalize(const Elf_Ehdr *hdr, 251 const Elf_Shdr *sechdrs, 252 struct module *me) 253{ |
254 const Elf_Shdr *s, *text = NULL, *alt = NULL, *locks = NULL, | 254 const Elf_Shdr *s, *alt = NULL, *locks = NULL, |
255 *para = NULL, *orc = NULL, *orc_ip = NULL, 256 *retpolines = NULL, *returns = NULL, *ibt_endbr = NULL; 257 char *secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset; 258 259 for (s = sechdrs; s < sechdrs + hdr->e_shnum; s++) { | 255 *para = NULL, *orc = NULL, *orc_ip = NULL, 256 *retpolines = NULL, *returns = NULL, *ibt_endbr = NULL; 257 char *secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset; 258 259 for (s = sechdrs; s < sechdrs + hdr->e_shnum; s++) { |
260 if (!strcmp(".text", secstrings + s->sh_name)) 261 text = s; | |
262 if (!strcmp(".altinstructions", secstrings + s->sh_name)) 263 alt = s; 264 if (!strcmp(".smp_locks", secstrings + s->sh_name)) 265 locks = s; 266 if (!strcmp(".parainstructions", secstrings + s->sh_name)) 267 para = s; 268 if (!strcmp(".orc_unwind", secstrings + s->sh_name)) 269 orc = s; --- 27 unchanged lines hidden (view full) --- 297 /* patch .altinstructions */ 298 void *aseg = (void *)alt->sh_addr; 299 apply_alternatives(aseg, aseg + alt->sh_size); 300 } 301 if (ibt_endbr) { 302 void *iseg = (void *)ibt_endbr->sh_addr; 303 apply_ibt_endbr(iseg, iseg + ibt_endbr->sh_size); 304 } | 260 if (!strcmp(".altinstructions", secstrings + s->sh_name)) 261 alt = s; 262 if (!strcmp(".smp_locks", secstrings + s->sh_name)) 263 locks = s; 264 if (!strcmp(".parainstructions", secstrings + s->sh_name)) 265 para = s; 266 if (!strcmp(".orc_unwind", secstrings + s->sh_name)) 267 orc = s; --- 27 unchanged lines hidden (view full) --- 295 /* patch .altinstructions */ 296 void *aseg = (void *)alt->sh_addr; 297 apply_alternatives(aseg, aseg + alt->sh_size); 298 } 299 if (ibt_endbr) { 300 void *iseg = (void *)ibt_endbr->sh_addr; 301 apply_ibt_endbr(iseg, iseg + ibt_endbr->sh_size); 302 } |
305 if (locks && text) { | 303 if (locks) { |
306 void *lseg = (void *)locks->sh_addr; | 304 void *lseg = (void *)locks->sh_addr; |
307 void *tseg = (void *)text->sh_addr; | 305 void *text = me->core_layout.base; 306 void *text_end = text + me->core_layout.text_size; |
308 alternatives_smp_module_add(me, me->name, 309 lseg, lseg + locks->sh_size, | 307 alternatives_smp_module_add(me, me->name, 308 lseg, lseg + locks->sh_size, |
310 tseg, tseg + text->sh_size); | 309 text, text_end); |
311 } 312 313 if (orc && orc_ip) 314 unwind_module_init(me, (void *)orc_ip->sh_addr, orc_ip->sh_size, 315 (void *)orc->sh_addr, orc->sh_size); 316 317 return 0; 318} 319 320void module_arch_cleanup(struct module *mod) 321{ 322 alternatives_smp_module_del(mod); 323} | 310 } 311 312 if (orc && orc_ip) 313 unwind_module_init(me, (void *)orc_ip->sh_addr, orc_ip->sh_size, 314 (void *)orc->sh_addr, orc->sh_size); 315 316 return 0; 317} 318 319void module_arch_cleanup(struct module *mod) 320{ 321 alternatives_smp_module_del(mod); 322} |