Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARC: dw2 unwind: add infrastructure for adding cfi pseudo ops to asm

1. detect whether binutils supports the cfi pseudo ops
2. define conditional macros to generate the ops
3. define new ENTRY_CFI/END_CFI to annotate hand asm code.
- Needed because we don't want to emit dwarf info in general ENTRY/END
used by lowest level trap/exception/interrutp handlers as unwinder
gets confused trying to unwind out of them. We want unwinder to
instead stop when it hits onfo those routines
- These provide minimal start/end cfi ops assuming routine doesn't
touch stack memory/regs

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>

+52 -1
+2 -1
arch/arc/Makefile
··· 65 65 66 66 endif 67 67 68 - cflags-$(CONFIG_ARC_DW2_UNWIND) += -fasynchronous-unwind-tables 68 + cfi := $(call as-instr,.cfi_startproc\n.cfi_endproc,-DARC_DW2_UNWIND_AS_CFI) 69 + cflags-$(CONFIG_ARC_DW2_UNWIND) += -fasynchronous-unwind-tables $(cfi) 69 70 70 71 ifndef CONFIG_CC_OPTIMIZE_FOR_SIZE 71 72 # Generic build system uses -O2, we want -O3
+38
arch/arc/include/asm/dwarf.h
··· 1 + /* 2 + * Copyright (C) 2016-17 Synopsys, Inc. (www.synopsys.com) 3 + * 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 as 6 + * published by the Free Software Foundation. 7 + */ 8 + 9 + #ifndef _ASM_ARC_DWARF_H 10 + #define _ASM_ARC_DWARF_H 11 + 12 + #ifdef __ASSEMBLY__ 13 + 14 + #ifdef ARC_DW2_UNWIND_AS_CFI 15 + 16 + #define CFI_STARTPROC .cfi_startproc 17 + #define CFI_ENDPROC .cfi_endproc 18 + #define CFI_DEF_CFA .cfi_def_cfa 19 + #define CFI_REGISTER .cfi_register 20 + #define CFI_REL_OFFSET .cfi_rel_offset 21 + #define CFI_UNDEFINED .cfi_undefined 22 + 23 + #else 24 + 25 + #define CFI_IGNORE # 26 + 27 + #define CFI_STARTPROC CFI_IGNORE 28 + #define CFI_ENDPROC CFI_IGNORE 29 + #define CFI_DEF_CFA CFI_IGNORE 30 + #define CFI_REGISTER CFI_IGNORE 31 + #define CFI_REL_OFFSET CFI_IGNORE 32 + #define CFI_UNDEFINED CFI_IGNORE 33 + 34 + #endif /* !ARC_DW2_UNWIND_AS_CFI */ 35 + 36 + #endif /* __ASSEMBLY__ */ 37 + 38 + #endif /* _ASM_ARC_DWARF_H */
+12
arch/arc/include/asm/linkage.h
··· 9 9 #ifndef __ASM_LINKAGE_H 10 10 #define __ASM_LINKAGE_H 11 11 12 + #include <asm/dwarf.h> 13 + 12 14 #ifdef __ASSEMBLY__ 13 15 14 16 #define ASM_NL ` /* use '`' to mark new line in macro */ ··· 33 31 .section .text, "ax",@progbits 34 32 #endif 35 33 .endm 34 + 35 + #define ENTRY_CFI(name) \ 36 + .globl name ASM_NL \ 37 + ALIGN ASM_NL \ 38 + name: ASM_NL \ 39 + CFI_STARTPROC ASM_NL 40 + 41 + #define END_CFI(name) \ 42 + CFI_ENDPROC ASM_NL \ 43 + .size name, .-name 36 44 37 45 #else /* !__ASSEMBLY__ */ 38 46