Message ID | 20221125103740.2062285-1-vincent.whitchurch@axis.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3920811wrr; Fri, 25 Nov 2022 02:52:59 -0800 (PST) X-Google-Smtp-Source: AA0mqf4JaPo0hDOy4qmiZtLW6s27WGOrnoBcR5BB5ibkR5J8j2vpf57O/cjjwJmElZdhzjTzPpxc X-Received: by 2002:a63:4944:0:b0:46f:ec9f:dcb0 with SMTP id y4-20020a634944000000b0046fec9fdcb0mr17950946pgk.202.1669373578770; Fri, 25 Nov 2022 02:52:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669373578; cv=none; d=google.com; s=arc-20160816; b=VI63k4zon9BiYxeoUhEBcoZCKmy2nX2zxPp0OJ+Px+cbwPoc2sQMqPsoSJlBjgzw+l sGkA0mz4KA17JSCNNexI1fpkGYVw/vwlnO8koM78ws4MsbJu0GX5Pom4AB0pl214H45k Z4Bib2wY0g1/TQhEq//d+tqyBfNW3TuyCsHzFUucWon7Pl3QFNP7LdgrMKXJ+9U/2B7+ 3PNtog9CYlmt+SdtIsj0KMb40Py510u9xvyb5FCt4+VLsJPIVy/mMq/JnxNvrjTOqgyt ZiT+1J08HY4skzrnC0N9+rGeXVAqD7losKctfaynHg6hWSvBOhUFT1pMLX5t3PLKlMJH nu6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=D09VrSl7WEIOCmbG+vjrZPtMD0Rhl/PJ8YiALk/C7+o=; b=fvJj4oLcoSs0h3epAR8N4aJs3KtP5GvVpe0aN0xCRy2v8tI97KK25zHQNcymLC/vvs 6i40ttw0vHWqTTfsEsDsC/zXdFKWEHA0r5mhiQu8qRbEL0JFLY5Qk+fPLVuqP0LKmkOC SJsQBPlShLKUGCbDRk/pV4afgx/JV8Lp1tAiFDZKuhKj9jQBVoM/2tfMMA3iKgOJCC0c yWZpkIpJj/2WIHtsCaTem5gPn+6DhHRUWbBJf5Ym7zNlxi8t1NYWxm3EEelHSurSG8g1 +S0AkPGLTkXwRE2pM1M5nJSkUD57JXiDgR3JQqW+iETbVHUaJfppyH/A0Fvvcz1d3JQ/ pbiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@axis.com header.s=axis-central1 header.b="SwGO/wxL"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=axis.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id iw14-20020a170903044e00b00188fc3a3fb1si3437797plb.184.2022.11.25.02.52.45; Fri, 25 Nov 2022 02:52:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@axis.com header.s=axis-central1 header.b="SwGO/wxL"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=axis.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229648AbiKYKhr (ORCPT <rfc822;zxc52fgh@gmail.com> + 99 others); Fri, 25 Nov 2022 05:37:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229436AbiKYKhq (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 25 Nov 2022 05:37:46 -0500 Received: from smtp1.axis.com (smtp1.axis.com [195.60.68.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 342F311A26 for <linux-kernel@vger.kernel.org>; Fri, 25 Nov 2022 02:37:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1669372664; x=1700908664; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=D09VrSl7WEIOCmbG+vjrZPtMD0Rhl/PJ8YiALk/C7+o=; b=SwGO/wxLmsTVRghQQ322csv441MKRwlo0PB/axl6sKTQVVnIgCdrzJer QhlevagUNPI+VqPwOMDrwaW94C/g6G6TA4EPfQwmu+zxutWJCnik3cPYg Tj1W4j+Z3SsKnt4aAUet/KUXraDOBJM5QkoXFeXL5jZzL9pnjDHaPfHhy 17cK6epTmmFbtfb7Ayi9f2qnQ0+yKiklCgshhwSxUf/V47DCgRGQDOxbh pJ2D9DInfqIEln5GdRrTl4O0pSPOpSysN1tx3cFjcd1Enpu9YuoKmwYDd gtBlm+dXu6TaSxCCWbqzqsIWH6zUyp70S2Q90yr41IXizTp8ZPUFqTDOp w==; From: Vincent Whitchurch <vincent.whitchurch@axis.com> To: Catalin Marinas <catalin.marinas@arm.com>, Will Deacon <will@kernel.org> CC: <kernel@axis.com>, Vincent Whitchurch <vincent.whitchurch@axis.com>, Tamas Zsoldos <tamas.zsoldos@arm.com>, Szabolcs Nagy <szabolcs.nagy@arm.com>, Daniel Kiss <daniel.kiss@arm.com>, Vincenzo Frascino <vincenzo.frascino@arm.com>, Ard Biesheuvel <ardb@kernel.org>, <linux-arm-kernel@lists.infradead.org>, <linux-kernel@vger.kernel.org> Subject: [PATCH] arm64: vdso: Include .eh_frame in debug ELF Date: Fri, 25 Nov 2022 11:37:40 +0100 Message-ID: <20221125103740.2062285-1-vincent.whitchurch@axis.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750465070132638192?= X-GMAIL-MSGID: =?utf-8?q?1750465070132638192?= |
Series |
arm64: vdso: Include .eh_frame in debug ELF
|
|
Commit Message
Vincent Whitchurch
Nov. 25, 2022, 10:37 a.m. UTC
We currently strip out .eh_frame to work around crashes in libgcc when
it tries to unwind out of signal handlers, see commit 87676cfca141
("arm64: vdso: Disable dwarf unwinding through the sigreturn
trampoline").
The .eh_frame does however have correct unwind information for the
functions implemented in C in vgettimeofday.c, but currently this
information is not available even for offline unwinding using the
vdso.so.dbg. As a result of this, perf built with libdw is unable to
unwind the stack when the PC is inside one of these functions.
To fix this, strip the .eh_frame section only from the vdso.so and not
from the vdso.so.dbg. This can be used by offline unwinders with access
to the debug symbols, and will not affect libgcc since the section will
still not be present in the normal vDSO.
Cc: Tamas Zsoldos <tamas.zsoldos@arm.com>
Cc: Szabolcs Nagy <szabolcs.nagy@arm.com>
Cc: Daniel Kiss <daniel.kiss@arm.com>
Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
Cc: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
---
arch/arm64/kernel/vdso/Makefile | 2 +-
arch/arm64/kernel/vdso/vdso.lds.S | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
Comments
The 11/25/2022 11:37, Vincent Whitchurch wrote: > We currently strip out .eh_frame to work around crashes in libgcc when > it tries to unwind out of signal handlers, see commit 87676cfca141 > ("arm64: vdso: Disable dwarf unwinding through the sigreturn > trampoline"). > > The .eh_frame does however have correct unwind information for the > functions implemented in C in vgettimeofday.c, but currently this > information is not available even for offline unwinding using the > vdso.so.dbg. As a result of this, perf built with libdw is unable to > unwind the stack when the PC is inside one of these functions. > > To fix this, strip the .eh_frame section only from the vdso.so and not > from the vdso.so.dbg. This can be used by offline unwinders with access > to the debug symbols, and will not affect libgcc since the section will > still not be present in the normal vDSO. adding eh_frame to vdso.so.dbg makes sense. but if libdw correctly unwinds across a signal handler then libgcc should be able to do so too. so maybe eh_frame should be added back to vdso.so just without frame info for __kernel_rt_sigreturn+NOP to ensure unwinders use heuristics for sigreturn. (i dont know if this was considered back when eh_frame was dropped from the vdso) > > Cc: Tamas Zsoldos <tamas.zsoldos@arm.com> > Cc: Szabolcs Nagy <szabolcs.nagy@arm.com> > Cc: Daniel Kiss <daniel.kiss@arm.com> > Cc: Vincenzo Frascino <vincenzo.frascino@arm.com> > Cc: Ard Biesheuvel <ardb@kernel.org> > Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com> > --- > arch/arm64/kernel/vdso/Makefile | 2 +- > arch/arm64/kernel/vdso/vdso.lds.S | 3 ++- > 2 files changed, 3 insertions(+), 2 deletions(-) > > diff --git a/arch/arm64/kernel/vdso/Makefile b/arch/arm64/kernel/vdso/Makefile > index 619e2dc7ee14..91aac17e11bc 100644 > --- a/arch/arm64/kernel/vdso/Makefile > +++ b/arch/arm64/kernel/vdso/Makefile > @@ -65,7 +65,7 @@ $(obj)/vdso.so.dbg: $(obj)/vdso.lds $(obj-vdso) FORCE > $(call if_changed,vdsold_and_vdso_check) > > # Strip rule for the .so file > -$(obj)/%.so: OBJCOPYFLAGS := -S > +$(obj)/%.so: OBJCOPYFLAGS := -S --remove-section=.eh_frame --remove-section=.eh_frame_hdr > $(obj)/%.so: $(obj)/%.so.dbg FORCE > $(call if_changed,objcopy) > > diff --git a/arch/arm64/kernel/vdso/vdso.lds.S b/arch/arm64/kernel/vdso/vdso.lds.S > index 6028f1fe2d1c..66abf70efc58 100644 > --- a/arch/arm64/kernel/vdso/vdso.lds.S > +++ b/arch/arm64/kernel/vdso/vdso.lds.S > @@ -31,6 +31,8 @@ SECTIONS > .gnu.version : { *(.gnu.version) } > .gnu.version_d : { *(.gnu.version_d) } > .gnu.version_r : { *(.gnu.version_r) } > + .eh_frame : { *(.eh_frame) } > + .eh_frame_hdr : { *(.eh_frame_hdr) } > > /* > * Discard .note.gnu.property sections which are unused and have > @@ -78,7 +80,6 @@ SECTIONS > /DISCARD/ : { > *(.data .data.* .gnu.linkonce.d.* .sdata*) > *(.bss .sbss .dynbss .dynsbss) > - *(.eh_frame .eh_frame_hdr) > } > } > > -- > 2.34.1 >
On Fri, Nov 25, 2022 at 01:27:14PM +0100, Szabolcs Nagy wrote: > The 11/25/2022 11:37, Vincent Whitchurch wrote: > > We currently strip out .eh_frame to work around crashes in libgcc when > > it tries to unwind out of signal handlers, see commit 87676cfca141 > > ("arm64: vdso: Disable dwarf unwinding through the sigreturn > > trampoline"). > > > > The .eh_frame does however have correct unwind information for the > > functions implemented in C in vgettimeofday.c, but currently this > > information is not available even for offline unwinding using the > > vdso.so.dbg. As a result of this, perf built with libdw is unable to > > unwind the stack when the PC is inside one of these functions. > > > > To fix this, strip the .eh_frame section only from the vdso.so and not > > from the vdso.so.dbg. This can be used by offline unwinders with access > > to the debug symbols, and will not affect libgcc since the section will > > still not be present in the normal vDSO. > > adding eh_frame to vdso.so.dbg makes sense. > > but if libdw correctly unwinds across a signal handler > then libgcc should be able to do so too. I have not tested if libdw can unwind across a signal handler. It is unlikely to work since all the CFI directives in __kernel_rt_sigreturn are commented out. The CFI in .eh_frame only covers the C functions and unwinding those works with libdw. $ aarch64-linux-gnu-objdump --dwarf=frames arch/arm64/kernel/vdso/vdso.so.dbg | grep pc 00000014 000000000000001c 00000018 FDE cie=00000000 pc=0000000000000330..00000000000005cc 00000034 0000000000000014 00000038 FDE cie=00000000 pc=00000000000005d0..0000000000000784 0000004c 0000000000000018 00000050 FDE cie=00000000 pc=0000000000000784..00000000000007fc $ nm -n arch/arm64/kernel/vdso/vdso.so.dbg 0000000000000330 T __kernel_clock_gettime 00000000000005d0 T __kernel_gettimeofday 0000000000000784 T __kernel_clock_getres 0000000000000820 T __kernel_rt_sigreturn > so maybe eh_frame should be added back to vdso.so just > without frame info for __kernel_rt_sigreturn+NOP to > ensure unwinders use heuristics for sigreturn. > (i dont know if this was considered back when eh_frame > was dropped from the vdso) I don't know either why 87676cfca141 had to both remove the CFI directives from __kernel_rt_sigreturn and remove the .eh_frame section completely from vdso.so instead of only doing the former, but I assume there was a good reason for that.
diff --git a/arch/arm64/kernel/vdso/Makefile b/arch/arm64/kernel/vdso/Makefile index 619e2dc7ee14..91aac17e11bc 100644 --- a/arch/arm64/kernel/vdso/Makefile +++ b/arch/arm64/kernel/vdso/Makefile @@ -65,7 +65,7 @@ $(obj)/vdso.so.dbg: $(obj)/vdso.lds $(obj-vdso) FORCE $(call if_changed,vdsold_and_vdso_check) # Strip rule for the .so file -$(obj)/%.so: OBJCOPYFLAGS := -S +$(obj)/%.so: OBJCOPYFLAGS := -S --remove-section=.eh_frame --remove-section=.eh_frame_hdr $(obj)/%.so: $(obj)/%.so.dbg FORCE $(call if_changed,objcopy) diff --git a/arch/arm64/kernel/vdso/vdso.lds.S b/arch/arm64/kernel/vdso/vdso.lds.S index 6028f1fe2d1c..66abf70efc58 100644 --- a/arch/arm64/kernel/vdso/vdso.lds.S +++ b/arch/arm64/kernel/vdso/vdso.lds.S @@ -31,6 +31,8 @@ SECTIONS .gnu.version : { *(.gnu.version) } .gnu.version_d : { *(.gnu.version_d) } .gnu.version_r : { *(.gnu.version_r) } + .eh_frame : { *(.eh_frame) } + .eh_frame_hdr : { *(.eh_frame_hdr) } /* * Discard .note.gnu.property sections which are unused and have @@ -78,7 +80,6 @@ SECTIONS /DISCARD/ : { *(.data .data.* .gnu.linkonce.d.* .sdata*) *(.bss .sbss .dynbss .dynsbss) - *(.eh_frame .eh_frame_hdr) } }