ARC: dw2 unwind: add infrastructure for adding cfi pseudo ops to asm
authorVineet Gupta <vgupta@synopsys.com>
Sat, 17 Sep 2016 00:23:26 +0000 (17:23 -0700)
committerVineet Gupta <vgupta@synopsys.com>
Fri, 30 Sep 2016 21:48:22 +0000 (14:48 -0700)
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>
arch/arc/Makefile
arch/arc/include/asm/dwarf.h [new file with mode: 0644]
arch/arc/include/asm/linkage.h

index a2a6a46..aa82d13 100644 (file)
@@ -65,7 +65,8 @@ endif
 
 endif
 
 
 endif
 
-cflags-$(CONFIG_ARC_DW2_UNWIND)                += -fasynchronous-unwind-tables
+cfi := $(call as-instr,.cfi_startproc\n.cfi_endproc,-DARC_DW2_UNWIND_AS_CFI)
+cflags-$(CONFIG_ARC_DW2_UNWIND)                += -fasynchronous-unwind-tables $(cfi)
 
 ifndef CONFIG_CC_OPTIMIZE_FOR_SIZE
 # Generic build system uses -O2, we want -O3
 
 ifndef CONFIG_CC_OPTIMIZE_FOR_SIZE
 # Generic build system uses -O2, we want -O3
diff --git a/arch/arc/include/asm/dwarf.h b/arch/arc/include/asm/dwarf.h
new file mode 100644 (file)
index 0000000..bb7bdbc
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2016-17 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef _ASM_ARC_DWARF_H
+#define _ASM_ARC_DWARF_H
+
+#ifdef __ASSEMBLY__
+
+#ifdef ARC_DW2_UNWIND_AS_CFI
+
+#define CFI_STARTPROC  .cfi_startproc
+#define CFI_ENDPROC    .cfi_endproc
+#define CFI_DEF_CFA    .cfi_def_cfa
+#define CFI_REGISTER   .cfi_register
+#define CFI_REL_OFFSET .cfi_rel_offset
+#define CFI_UNDEFINED  .cfi_undefined
+
+#else
+
+#define CFI_IGNORE     #
+
+#define CFI_STARTPROC  CFI_IGNORE
+#define CFI_ENDPROC    CFI_IGNORE
+#define CFI_DEF_CFA    CFI_IGNORE
+#define CFI_REGISTER   CFI_IGNORE
+#define CFI_REL_OFFSET CFI_IGNORE
+#define CFI_UNDEFINED  CFI_IGNORE
+
+#endif /* !ARC_DW2_UNWIND_AS_CFI */
+
+#endif /* __ASSEMBLY__ */
+
+#endif /* _ASM_ARC_DWARF_H */
index 5faad17..b29f1a9 100644 (file)
@@ -9,6 +9,8 @@
 #ifndef __ASM_LINKAGE_H
 #define __ASM_LINKAGE_H
 
 #ifndef __ASM_LINKAGE_H
 #define __ASM_LINKAGE_H
 
+#include <asm/dwarf.h>
+
 #ifdef __ASSEMBLY__
 
 #define ASM_NL          `      /* use '`' to mark new line in macro */
 #ifdef __ASSEMBLY__
 
 #define ASM_NL          `      /* use '`' to mark new line in macro */
 #endif
 .endm
 
 #endif
 .endm
 
+#define ENTRY_CFI(name)                \
+       .globl name ASM_NL      \
+       ALIGN ASM_NL            \
+       name: ASM_NL            \
+       CFI_STARTPROC ASM_NL
+
+#define END_CFI(name)          \
+       CFI_ENDPROC ASM_NL      \
+       .size name, .-name
+
 #else  /* !__ASSEMBLY__ */
 
 #ifdef CONFIG_ARC_HAS_ICCM
 #else  /* !__ASSEMBLY__ */
 
 #ifdef CONFIG_ARC_HAS_ICCM