Skip to content

Commit bc3703f

Browse files
hbruecknerMartin Schwidefsky
authored andcommitted
s390/kernel: emit CFI data in .debug_frame and discard .eh_frame sections
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>
1 parent a5f1005 commit bc3703f

13 files changed

Lines changed: 43 additions & 0 deletions

File tree

‎arch/s390/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ endif
9090

9191
KBUILD_CFLAGS += -mbackchain -msoft-float $(cflags-y)
9292
KBUILD_CFLAGS += -pipe -fno-strength-reduce -Wno-sign-compare
93+
KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
9394
KBUILD_AFLAGS += $(aflags-y)
9495

9596
OBJCOPYFLAGS := -O binary

‎arch/s390/include/asm/dwarf.h‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef _ASM_S390_DWARF_H
3+
#define _ASM_S390_DWARF_H
4+
5+
#ifdef __ASSEMBLY__
6+
7+
#ifndef BUILD_VDSO
8+
/*
9+
* Emit CFI data in .debug_frame sections and not in .eh_frame
10+
* sections. The .eh_frame CFI is used for runtime unwind
11+
* information that is not being used. Hence, vmlinux.lds.S
12+
* can discard the .eh_frame sections.
13+
*/
14+
.cfi_sections .debug_frame
15+
#else
16+
/*
17+
* For vDSO, emit CFI data in both, .eh_frame and .debug_frame
18+
* sections.
19+
*/
20+
.cfi_sections .eh_frame, .debug_frame
21+
#endif
22+
23+
#endif /* __ASSEMBLY__ */
24+
25+
#endif /* _ASM_S390_DWARF_H */

‎arch/s390/kernel/vdso32/Makefile‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ obj-vdso32 = gettimeofday.o clock_getres.o clock_gettime.o note.o getcpu.o
1010
targets := $(obj-vdso32) vdso32.so vdso32.so.dbg
1111
obj-vdso32 := $(addprefix $(obj)/, $(obj-vdso32))
1212

13+
KBUILD_AFLAGS += -DBUILD_VDSO
14+
KBUILD_CFLAGS += -DBUILD_VDSO
15+
1316
KBUILD_AFLAGS_31 := $(filter-out -m64,$(KBUILD_AFLAGS))
1417
KBUILD_AFLAGS_31 += -m31 -s
1518

‎arch/s390/kernel/vdso32/clock_getres.S‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <asm/vdso.h>
1010
#include <asm/asm-offsets.h>
1111
#include <asm/unistd.h>
12+
#include <asm/dwarf.h>
1213

1314
.text
1415
.align 4

‎arch/s390/kernel/vdso32/clock_gettime.S‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <asm/vdso.h>
1010
#include <asm/asm-offsets.h>
1111
#include <asm/unistd.h>
12+
#include <asm/dwarf.h>
1213

1314
.text
1415
.align 4

‎arch/s390/kernel/vdso32/getcpu.S‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99
#include <asm/vdso.h>
1010
#include <asm/asm-offsets.h>
11+
#include <asm/dwarf.h>
1112

1213
.text
1314
.align 4

‎arch/s390/kernel/vdso32/gettimeofday.S‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <asm/vdso.h>
1010
#include <asm/asm-offsets.h>
1111
#include <asm/unistd.h>
12+
#include <asm/dwarf.h>
1213

1314
.text
1415
.align 4

‎arch/s390/kernel/vdso64/Makefile‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ obj-vdso64 = gettimeofday.o clock_getres.o clock_gettime.o note.o getcpu.o
1010
targets := $(obj-vdso64) vdso64.so vdso64.so.dbg
1111
obj-vdso64 := $(addprefix $(obj)/, $(obj-vdso64))
1212

13+
KBUILD_AFLAGS += -DBUILD_VDSO
14+
KBUILD_CFLAGS += -DBUILD_VDSO
15+
1316
KBUILD_AFLAGS_64 := $(filter-out -m64,$(KBUILD_AFLAGS))
1417
KBUILD_AFLAGS_64 += -m64 -s
1518

‎arch/s390/kernel/vdso64/clock_getres.S‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <asm/vdso.h>
1010
#include <asm/asm-offsets.h>
1111
#include <asm/unistd.h>
12+
#include <asm/dwarf.h>
1213

1314
.text
1415
.align 4

‎arch/s390/kernel/vdso64/clock_gettime.S‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <asm/vdso.h>
1010
#include <asm/asm-offsets.h>
1111
#include <asm/unistd.h>
12+
#include <asm/dwarf.h>
1213

1314
.text
1415
.align 4

0 commit comments

Comments
 (0)