aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndi Kleen <ak@suse.de>2006-09-26 04:52:30 -0400
committerAndi Kleen <andi@basil.nowhere.org>2006-09-26 04:52:30 -0400
commite2414910f212c52d9d7c64c99a22863488ac5b48 (patch)
tree5a7e55191ace4aa755c0684bcefc9cf1b124128c
parentfe7414a2882c953788af13a7f2c9d570ed8f71c5 (diff)
[PATCH] x86: Detect CFI support in the assembler at runtime
... instead of using a CONFIG option. The config option still controls if the resulting executable actually has unwind information. This is useful to prevent compilation errors when users select CONFIG_STACK_UNWIND on old binutils and also allows to use CFI in the future for non kernel debugging applications. Cc: jbeulich@novell.com Cc: sam@ravnborg.org Signed-off-by: Andi Kleen <ak@suse.de>
-rw-r--r--Documentation/kbuild/makefiles.txt5
-rw-r--r--arch/i386/Makefile4
-rw-r--r--arch/x86_64/Makefile3
-rw-r--r--include/asm-x86_64/dwarf2.h2
-rw-r--r--scripts/Kbuild.include7
5 files changed, 20 insertions, 1 deletions
diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
index b7d6abb501a6..e2cbd59cf2d0 100644
--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
@@ -421,6 +421,11 @@ more details, with real examples.
421 The second argument is optional, and if supplied will be used 421 The second argument is optional, and if supplied will be used
422 if first argument is not supported. 422 if first argument is not supported.
423 423
424 as-instr
425 as-instr checks if the assembler reports a specific instruction
426 and then outputs either option1 or option2
427 C escapes are supported in the test instruction
428
424 cc-option 429 cc-option
425 cc-option is used to check if $(CC) supports a given option, and not 430 cc-option is used to check if $(CC) supports a given option, and not
426 supported to use an optional second option. 431 supported to use an optional second option.
diff --git a/arch/i386/Makefile b/arch/i386/Makefile
index 3e4adb1e2244..508cdbeb3a09 100644
--- a/arch/i386/Makefile
+++ b/arch/i386/Makefile
@@ -46,6 +46,10 @@ cflags-y += -ffreestanding
46# a lot more stack due to the lack of sharing of stacklots: 46# a lot more stack due to the lack of sharing of stacklots:
47CFLAGS += $(shell if [ $(call cc-version) -lt 0400 ] ; then echo $(call cc-option,-fno-unit-at-a-time); fi ;) 47CFLAGS += $(shell if [ $(call cc-version) -lt 0400 ] ; then echo $(call cc-option,-fno-unit-at-a-time); fi ;)
48 48
49# do binutils support CFI?
50cflags-y += $(call as-instr,.cfi_startproc\n.cfi_endproc,-DCONFIG_AS_CFI=1,)
51AFLAGS += $(call as-instr,.cfi_startproc\n.cfi_endproc,-DCONFIG_AS_CFI=1,)
52
49CFLAGS += $(cflags-y) 53CFLAGS += $(cflags-y)
50 54
51# Default subarch .c files 55# Default subarch .c files
diff --git a/arch/x86_64/Makefile b/arch/x86_64/Makefile
index 431bb4bc36cd..d6472ddf5f6e 100644
--- a/arch/x86_64/Makefile
+++ b/arch/x86_64/Makefile
@@ -54,6 +54,9 @@ endif
54cflags-y += $(call cc-option,-funit-at-a-time) 54cflags-y += $(call cc-option,-funit-at-a-time)
55# prevent gcc from generating any FP code by mistake 55# prevent gcc from generating any FP code by mistake
56cflags-y += $(call cc-option,-mno-sse -mno-mmx -mno-sse2 -mno-3dnow,) 56cflags-y += $(call cc-option,-mno-sse -mno-mmx -mno-sse2 -mno-3dnow,)
57# do binutils support CFI?
58cflags-y += $(call as-instr,.cfi_startproc\n.cfi_endproc,-DCONFIG_AS_CFI=1,)
59AFLAGS += $(call as-instr,.cfi_startproc\n.cfi_endproc,-DCONFIG_AS_CFI=1,)
57 60
58CFLAGS += $(cflags-y) 61CFLAGS += $(cflags-y)
59CFLAGS_KERNEL += $(cflags-kernel-y) 62CFLAGS_KERNEL += $(cflags-kernel-y)
diff --git a/include/asm-x86_64/dwarf2.h b/include/asm-x86_64/dwarf2.h
index 0744db777676..2b9368365fad 100644
--- a/include/asm-x86_64/dwarf2.h
+++ b/include/asm-x86_64/dwarf2.h
@@ -13,7 +13,7 @@
13 away for older version. 13 away for older version.
14 */ 14 */
15 15
16#ifdef CONFIG_UNWIND_INFO 16#ifdef CONFIG_AS_CFI
17 17
18#define CFI_STARTPROC .cfi_startproc 18#define CFI_STARTPROC .cfi_startproc
19#define CFI_ENDPROC .cfi_endproc 19#define CFI_ENDPROC .cfi_endproc
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 3d523899fdc0..7adef12a0c26 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -63,6 +63,13 @@ as-option = $(shell if $(CC) $(CFLAGS) $(1) -Wa,-Z -c -o /dev/null \
63 -xassembler /dev/null > /dev/null 2>&1; then echo "$(1)"; \ 63 -xassembler /dev/null > /dev/null 2>&1; then echo "$(1)"; \
64 else echo "$(2)"; fi ;) 64 else echo "$(2)"; fi ;)
65 65
66# as-instr
67# Usage: cflags-y += $(call as-instr, instr, option1, option2)
68
69as-instr = $(shell if echo -e "$(1)" | $(AS) -Z -o astest$$$$.out \
70 2>&1 >/dev/null ; then echo "$(2)"; else echo "$(3)"; fi; \
71 rm -f astest$$$$.out)
72
66# cc-option 73# cc-option
67# Usage: cflags-y += $(call cc-option, -march=winchip-c6, -march=i586) 74# Usage: cflags-y += $(call cc-option, -march=winchip-c6, -march=i586)
68 75