···2525 select HAVE_ARCH_TRACEHOOK2626 select HAVE_GENERIC_HARDIRQS2727 select HAVE_MEMBLOCK2828+ select HAVE_MOD_ARCH_SPECIFIC if ARC_DW2_UNWIND2829 select HAVE_OPROFILE2930 select IRQ_DOMAIN3031 select MODULES_USE_ELF_RELA···344343menuconfig ARC_DBG345344 bool "ARC debugging"346345 default y346346+347347+config ARC_DW2_UNWIND348348+ bool "Enable DWARF specific kernel stack unwind"349349+ depends on ARC_DBG350350+ default y351351+ select KALLSYMS352352+ help353353+ Compiles the kernel with DWARF unwind information and can be used354354+ to get stack backtraces.355355+356356+ If you say Y here the resulting kernel image will be slightly larger357357+ but not slower, and it will give very useful debugging information.358358+ If you don't debug the kernel, you can say N, but we may not be able359359+ to solve problems without frame unwind information347360348361config ARC_DBG_TLB_PARANOIA349362 bool "Paranoia Checks in Low Level TLB Handlers"
···815815816816 b ret_from_system_call817817ARC_EXIT sys_clone_wrapper818818+819819+#ifdef CONFIG_ARC_DW2_UNWIND820820+; Workaround for bug 94179 (STAR ):821821+; Despite -fasynchronous-unwind-tables, linker is not making dwarf2 unwinder822822+; section (.debug_frame) as loadable. So we force it here.823823+; This also fixes STAR 9000487933 where the prev-workaround (objcopy --setflag)824824+; would not work after a clean build due to kernel build system dependencies.825825+.section .debug_frame, "wa",@progbits826826+#endif
+58
arch/arc/kernel/module.c
···1414#include <linux/slab.h>1515#include <linux/fs.h>1616#include <linux/string.h>1717+#include <asm/unwind.h>17181819static inline void arc_write_me(unsigned short *addr, unsigned long value)1920{2021 *addr = (value & 0xffff0000) >> 16;2122 *(addr + 1) = (value & 0xffff);2323+}2424+2525+/* ARC specific section quirks - before relocation loop in generic loader2626+ *2727+ * For dwarf unwinding out of modules, this needs to2828+ * 1. Ensure the .debug_frame is allocatable (ARC Linker bug: despite2929+ * -fasynchronous-unwind-tables it doesn't).3030+ * 2. Since we are iterating thru sec hdr tbl anyways, make a note of3131+ * the exact section index, for later use.3232+ */3333+int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,3434+ char *secstr, struct module *mod)3535+{3636+#ifdef CONFIG_ARC_DW2_UNWIND3737+ int i;3838+3939+ mod->arch.unw_sec_idx = 0;4040+ mod->arch.unw_info = NULL;4141+4242+ for (i = 1; i < hdr->e_shnum; i++) {4343+ if (strcmp(secstr+sechdrs[i].sh_name, ".debug_frame") == 0) {4444+ sechdrs[i].sh_flags |= SHF_ALLOC;4545+ mod->arch.unw_sec_idx = i;4646+ break;4747+ }4848+ }4949+#endif5050+ return 0;5151+}5252+5353+void module_arch_cleanup(struct module *mod)5454+{5555+#ifdef CONFIG_ARC_DW2_UNWIND5656+ if (mod->arch.unw_info)5757+ unwind_remove_table(mod->arch.unw_info, 0);5858+#endif2259}23602461int apply_relocate_add(Elf32_Shdr *sechdrs,···12184 module->name, ELF32_R_TYPE(rel_entry[i].r_info));12285 return -ENOEXEC;123868787+}8888+8989+/* Just before lift off: After sections have been relocated, we add the9090+ * dwarf section to unwinder table pool9191+ * This couldn't be done in module_frob_arch_sections() because9292+ * relocations had not been applied by then9393+ */9494+int module_finalize(const Elf32_Ehdr *hdr, const Elf_Shdr *sechdrs,9595+ struct module *mod)9696+{9797+#ifdef CONFIG_ARC_DW2_UNWIND9898+ void *unw;9999+ int unwsec = mod->arch.unw_sec_idx;100100+101101+ if (unwsec) {102102+ unw = unwind_add_table(mod, (void *)sechdrs[unwsec].sh_addr,103103+ sechdrs[unwsec].sh_size);104104+ mod->arch.unw_info = unw;105105+ }106106+#endif107107+ return 0;124108}