]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
s390/kernel: emit CFI data in .debug_frame and discard .eh_frame sections
authorHendrik Brueckner <brueckner@linux.vnet.ibm.com>
Mon, 20 Nov 2017 10:41:07 +0000 (11:41 +0100)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Wed, 13 Dec 2017 09:51:35 +0000 (10:51 +0100)
Using perf probe and libdw on kernel modules failed to find CFI
data for symbols.  The CFI data is stored in the .eh_frame section.
The elfutils libdw is not able to extract the CFI data correctly,
because the .eh_frame section requires "non-simple" relocations
for kernel modules.

The suggestion is to avoid these "non-simple" relocations by emitting
the CFI data in the .debug_frame section.  Let gcc emit respective
directives by specifying the -fno-asynchronous-unwind-tables option.

Using the .debug_frame section for CFI data, the .eh_frame section
becomes unused and, thus, discard it for kernel and modules builds

The vDSO requires the .eh_frame section and, hence, emit the CFI data
in both, the .eh_frame and .debug_frame sections.

See also discussion on elfutils/libdw bugzilla:
https://sourceware.org/bugzilla/show_bug.cgi?id=22452

Suggested-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Reviewed-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
13 files changed:
arch/s390/Makefile
arch/s390/include/asm/dwarf.h [new file with mode: 0644]
arch/s390/kernel/vdso32/Makefile
arch/s390/kernel/vdso32/clock_getres.S
arch/s390/kernel/vdso32/clock_gettime.S
arch/s390/kernel/vdso32/getcpu.S
arch/s390/kernel/vdso32/gettimeofday.S
arch/s390/kernel/vdso64/Makefile
arch/s390/kernel/vdso64/clock_getres.S
arch/s390/kernel/vdso64/clock_gettime.S
arch/s390/kernel/vdso64/getcpu.S
arch/s390/kernel/vdso64/gettimeofday.S
arch/s390/kernel/vmlinux.lds.S

index de54cfc6109d833017b29b6e115549aad2601d53..494bb9ad5edfb388a6567fa597dbe7e139cb806c 100644 (file)
@@ -90,6 +90,7 @@ endif
 
 KBUILD_CFLAGS  += -mbackchain -msoft-float $(cflags-y)
 KBUILD_CFLAGS  += -pipe -fno-strength-reduce -Wno-sign-compare
+KBUILD_CFLAGS  += -fno-asynchronous-unwind-tables
 KBUILD_AFLAGS  += $(aflags-y)
 
 OBJCOPYFLAGS   := -O binary
diff --git a/arch/s390/include/asm/dwarf.h b/arch/s390/include/asm/dwarf.h
new file mode 100644 (file)
index 0000000..dffdb81
--- /dev/null
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _ASM_S390_DWARF_H
+#define _ASM_S390_DWARF_H
+
+#ifdef __ASSEMBLY__
+
+#ifndef BUILD_VDSO
+       /*
+        * Emit CFI data in .debug_frame sections and not in .eh_frame
+        * sections.  The .eh_frame CFI is used for runtime unwind
+        * information that is not being used.  Hence, vmlinux.lds.S
+        * can discard the .eh_frame sections.
+        */
+       .cfi_sections .debug_frame
+#else
+       /*
+        * For vDSO, emit CFI data in both, .eh_frame and .debug_frame
+        * sections.
+        */
+       .cfi_sections .eh_frame, .debug_frame
+#endif
+
+#endif /* __ASSEMBLY__ */
+
+#endif /* _ASM_S390_DWARF_H */
index 308564b9bf6864eb9af3ba9d17d1d900a0b1bfd1..c5c856f320bca47e9b64c0c35726881fb2394d1d 100644 (file)
@@ -10,6 +10,9 @@ obj-vdso32 = gettimeofday.o clock_getres.o clock_gettime.o note.o getcpu.o
 targets := $(obj-vdso32) vdso32.so vdso32.so.dbg
 obj-vdso32 := $(addprefix $(obj)/, $(obj-vdso32))
 
+KBUILD_AFLAGS += -DBUILD_VDSO
+KBUILD_CFLAGS += -DBUILD_VDSO
+
 KBUILD_AFLAGS_31 := $(filter-out -m64,$(KBUILD_AFLAGS))
 KBUILD_AFLAGS_31 += -m31 -s
 
index f61df5253c23c55ed26b357a645b16f4ab2e26a4..6aeddf8e4bc732bc1f0a355c382285019e8daba8 100644 (file)
@@ -9,6 +9,7 @@
 #include <asm/vdso.h>
 #include <asm/asm-offsets.h>
 #include <asm/unistd.h>
+#include <asm/dwarf.h>
 
        .text
        .align 4
index 2d6ec3abe095ea30bac898e85fd4cf4faf06bbe5..d0ac32c413e29a7ec0af766f31c8e25532a81673 100644 (file)
@@ -9,6 +9,7 @@
 #include <asm/vdso.h>
 #include <asm/asm-offsets.h>
 #include <asm/unistd.h>
+#include <asm/dwarf.h>
 
        .text
        .align 4
index 5477a2c112fb800e3c1013cb17a03a1d6aa47228..539d92a2c61b19e15ffa351b4a031d55a11cfff9 100644 (file)
@@ -8,6 +8,7 @@
  */
 #include <asm/vdso.h>
 #include <asm/asm-offsets.h>
+#include <asm/dwarf.h>
 
        .text
        .align 4
index aa8bf13a2edb1f77c861ed6de0acc2a2836e26fa..435f819c3e65ee1a06faa6a697bd3285937d8c7e 100644 (file)
@@ -9,6 +9,7 @@
 #include <asm/vdso.h>
 #include <asm/asm-offsets.h>
 #include <asm/unistd.h>
+#include <asm/dwarf.h>
 
        .text
        .align 4
index f81ae799888394cab67c4ba76743e4a901a04b44..15b1ceafc4c18fd2cf7fc52920e6c259212b1708 100644 (file)
@@ -10,6 +10,9 @@ obj-vdso64 = gettimeofday.o clock_getres.o clock_gettime.o note.o getcpu.o
 targets := $(obj-vdso64) vdso64.so vdso64.so.dbg
 obj-vdso64 := $(addprefix $(obj)/, $(obj-vdso64))
 
+KBUILD_AFLAGS += -DBUILD_VDSO
+KBUILD_CFLAGS += -DBUILD_VDSO
+
 KBUILD_AFLAGS_64 := $(filter-out -m64,$(KBUILD_AFLAGS))
 KBUILD_AFLAGS_64 += -m64 -s
 
index faf5213b15dfae9536f2583b601c1b4610558249..5b0d9c380de255f2e51816ed94fc8c5b1df35414 100644 (file)
@@ -9,6 +9,7 @@
 #include <asm/vdso.h>
 #include <asm/asm-offsets.h>
 #include <asm/unistd.h>
+#include <asm/dwarf.h>
 
        .text
        .align 4
index 6046b3bfca4622ea87bd1759bfa36e3f2d5b6d89..deccd793b2796eefc005853b17f07eeecb91d3ba 100644 (file)
@@ -9,6 +9,7 @@
 #include <asm/vdso.h>
 #include <asm/asm-offsets.h>
 #include <asm/unistd.h>
+#include <asm/dwarf.h>
 
        .text
        .align 4
index e9c34364d97b1aafdef2b0fa24c3ece518e3fe53..022acdecd5b9dd0eaa9d1751c4ef14e3a3f540db 100644 (file)
@@ -8,6 +8,7 @@
  */
 #include <asm/vdso.h>
 #include <asm/asm-offsets.h>
+#include <asm/dwarf.h>
 
        .text
        .align 4
index cc9dbc27da6fbcd22e865dd502be7f8bd515a11c..964afb1de06d301e9fd976143d9c4db1ca1aba77 100644 (file)
@@ -9,6 +9,7 @@
 #include <asm/vdso.h>
 #include <asm/asm-offsets.h>
 #include <asm/unistd.h>
+#include <asm/dwarf.h>
 
        .text
        .align 4
index a049ff005f03df571ab58a52180b42e44b63bf6d..608cf2987d1963ed65f1faa53ff35236cc47e583 100644 (file)
@@ -141,4 +141,7 @@ SECTIONS
 
        /* Sections to be discarded */
        DISCARDS
+       /DISCARD/ : {
+               *(.eh_frame)
+       }
 }