module.c (0ea5c948cb64bab5bc7a5516774eb8536f05aa0d) | module.c (cb8a2ef0848ca80d67d6d56e2df757cfdf6b3355) |
---|---|
1// SPDX-License-Identifier: GPL-2.0+ 2/* 3 * Author: Hanlu Li <lihanlu@loongson.cn> 4 * Huacai Chen <chenhuacai@loongson.cn> 5 * 6 * Copyright (C) 2020-2022 Loongson Technology Corporation Limited 7 */ 8 --- 6 unchanged lines hidden (view full) --- 15#include <linux/vmalloc.h> 16#include <linux/slab.h> 17#include <linux/fs.h> 18#include <linux/ftrace.h> 19#include <linux/string.h> 20#include <linux/kernel.h> 21#include <asm/alternative.h> 22#include <asm/inst.h> | 1// SPDX-License-Identifier: GPL-2.0+ 2/* 3 * Author: Hanlu Li <lihanlu@loongson.cn> 4 * Huacai Chen <chenhuacai@loongson.cn> 5 * 6 * Copyright (C) 2020-2022 Loongson Technology Corporation Limited 7 */ 8 --- 6 unchanged lines hidden (view full) --- 15#include <linux/vmalloc.h> 16#include <linux/slab.h> 17#include <linux/fs.h> 18#include <linux/ftrace.h> 19#include <linux/string.h> 20#include <linux/kernel.h> 21#include <asm/alternative.h> 22#include <asm/inst.h> |
23#include <asm/unwind.h> |
|
23 24static int rela_stack_push(s64 stack_value, s64 *rela_stack, size_t *rela_stack_top) 25{ 26 if (*rela_stack_top >= RELA_STACK_DEPTH) 27 return -ENOEXEC; 28 29 rela_stack[(*rela_stack_top)++] = stack_value; 30 pr_debug("%s stack_value = 0x%llx\n", __func__, stack_value); --- 479 unchanged lines hidden (view full) --- 510 511 mod->arch.ftrace_trampolines = ftrace_plts; 512#endif 513} 514 515int module_finalize(const Elf_Ehdr *hdr, 516 const Elf_Shdr *sechdrs, struct module *mod) 517{ | 24 25static int rela_stack_push(s64 stack_value, s64 *rela_stack, size_t *rela_stack_top) 26{ 27 if (*rela_stack_top >= RELA_STACK_DEPTH) 28 return -ENOEXEC; 29 30 rela_stack[(*rela_stack_top)++] = stack_value; 31 pr_debug("%s stack_value = 0x%llx\n", __func__, stack_value); --- 479 unchanged lines hidden (view full) --- 511 512 mod->arch.ftrace_trampolines = ftrace_plts; 513#endif 514} 515 516int module_finalize(const Elf_Ehdr *hdr, 517 const Elf_Shdr *sechdrs, struct module *mod) 518{ |
518 const Elf_Shdr *s, *se; | |
519 const char *secstrs = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset; | 519 const char *secstrs = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset; |
520 const Elf_Shdr *s, *alt = NULL, *orc = NULL, *orc_ip = NULL, *ftrace = NULL; |
|
520 | 521 |
521 for (s = sechdrs, se = sechdrs + hdr->e_shnum; s < se; s++) { | 522 for (s = sechdrs; s < sechdrs + hdr->e_shnum; s++) { |
522 if (!strcmp(".altinstructions", secstrs + s->sh_name)) | 523 if (!strcmp(".altinstructions", secstrs + s->sh_name)) |
523 apply_alternatives((void *)s->sh_addr, (void *)s->sh_addr + s->sh_size); | 524 alt = s; 525 if (!strcmp(".orc_unwind", secstrs + s->sh_name)) 526 orc = s; 527 if (!strcmp(".orc_unwind_ip", secstrs + s->sh_name)) 528 orc_ip = s; |
524 if (!strcmp(".ftrace_trampoline", secstrs + s->sh_name)) | 529 if (!strcmp(".ftrace_trampoline", secstrs + s->sh_name)) |
525 module_init_ftrace_plt(hdr, s, mod); | 530 ftrace = s; |
526 } 527 | 531 } 532 |
533 if (alt) 534 apply_alternatives((void *)alt->sh_addr, (void *)alt->sh_addr + alt->sh_size); 535 536 if (orc && orc_ip) 537 unwind_module_init(mod, (void *)orc_ip->sh_addr, orc_ip->sh_size, (void *)orc->sh_addr, orc->sh_size); 538 539 if (ftrace) 540 module_init_ftrace_plt(hdr, ftrace, mod); 541 |
|
528 return 0; 529} | 542 return 0; 543} |