From patchwork Wed Aug 9 11:46:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 22006 Received: (qmail 49922 invoked by alias); 9 Aug 2017 11:46:12 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 49912 invoked by uid 89); 9 Aug 2017 11:46:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LOTSOFHASH, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: EUR03-VE1-obe.outbound.protection.outlook.com From: Wilco Dijkstra To: "libc-alpha@sourceware.org" CC: nd , Andreas Schwab Subject: [PATCH] Enable unwind info in libc-start.c and backtrace.c Date: Wed, 9 Aug 2017 11:46:05 +0000 Message-ID: References: , , In-Reply-To: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Wilco.Dijkstra@arm.com; x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB6PR0801MB2053; 6:OfJ04q24GRYzE5+GIg+acOWgurAIFNDesMCuOu3PIeOZGM8PVA285Im179LJ80An90u4EX0hCH8NaKJdGgDw4DlIEbUKoD1UX8GHgpx/oGgjOnxmvWXdhNYMhVcW4MOLVihGbcmrQquNsoqPaGsga6ROIaA5VrFKIkeYWeAa716mT/LuiYDMm9FBRsiekUGU7hRM4b+NDse6pESYSvkj2KaLXPjerbuEsArUdxPC2mPX0PVRHL5+sjR7XHEtSJ6i7C5ZnfPU6XGfOs2I4h87gEz86m2jDmbsY6gR93bGTgyk0G1LDwcpZB0kt4gzCcO5Ciugc+2gi8ElJUcx6tm94w==; 5:UTXAsn2ltGvJ2yt0JZpUIN8ozqEgxxXtw8DCltCfeRbLaQeYiQrYBYdSRNhxAAyFnvfExq2jKWpeFfQO7nujZ/Vv5sY1t3x/etN0u5FnpHZv1eikerW7KxJh4xAUFzwFADMg8SB8LWVZDDR+5PA0jA==; 24:ORwSf3iHOMC7+8Khr46qIrtbr77KDad0N4PvhNTSPu/Po1013QD8GiaeH1JnaAIb/qscNfk3ioHCyZzJQvX+SmDLonu3lLgeUbPUUk8S4Hk=; 7:0qmCMprXLvSzLvZFuYnoMpSflPWbF+1lsQB7FthjV2vqsDhHkr7DVE/8MgLBI2kHOiktbAaNgRNvE4U+GYXq2xMILIv0yDqNvRBr4wmUvPiVkD5G2oMGyWBF7g/LzQBGUZWEXp+T+EH2H1u+TqPVm2y63olRswlnGTyIFPmF8ZqtsA7tiqA2Frc4eOEIM1SVfIsqNNqcbdcpxbgrbYvW3o7N5TcgVlGnWRvByZrMZoQ= x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: 3e834cbf-e610-4196-a8d6-08d4df1c37b3 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(2017052603031)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DB6PR0801MB2053; x-ms-traffictypediagnostic: DB6PR0801MB2053: nodisclaimer: True x-exchange-antispam-report-test: UriScan:(180628864354917); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(100000703101)(100105400095)(93006095)(93001095)(3002001)(10201501046)(6055026)(6041248)(20161123560025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123555025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DB6PR0801MB2053; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DB6PR0801MB2053; x-forefront-prvs: 0394259C80 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(39400400002)(39850400002)(39840400002)(39450400003)(39860400002)(39410400002)(189002)(199003)(377424004)(54534003)(81166006)(2501003)(6116002)(2906002)(5640700003)(6306002)(102836003)(68736007)(110136004)(189998001)(55016002)(54906002)(25786009)(6436002)(3660700001)(6506006)(575784001)(3280700002)(4326008)(99286003)(66066001)(3846002)(5250100002)(38730400002)(86362001)(2351001)(14454004)(2900100001)(5660300001)(74316002)(7696004)(8676002)(53936002)(54356999)(9686003)(101416001)(105586002)(50986999)(97736004)(33656002)(478600001)(6916009)(2950100002)(76176999)(81156014)(72206003)(305945005)(966005)(106356001)(7736002)(8936002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6PR0801MB2053; H:DB6PR0801MB2053.eurprd08.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Aug 2017 11:46:05.1275 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB2053 After feedback on https://sourceware.org/ml/libc-alpha/2017-07/msg01010.html here is the updated patch: Add unwind info to __libc_start_main so that unwinding continues one extra level to _start. Similarly add unwind info to backtrace. Given many targets require this, do this in a general way and remove -funwind-tables (or -fexceptions - which is identical in C) from several target makefiles. ChangeLog: 2017-08-09 Wilco Dijkstra * sysdeps/aarch64/Makefile: Build libc-start.c with -fexceptions. * csu/Makefile: Add -funwind-tables to libc-start.c. * debug/Makefile: Add -funwind-tables to backtrace.c. * sysdeps/aarch64/Makefile: Remove CFLAGS-backtrace.c. * sysdeps/arm/Makefile: Likewise. * sysdeps/i386/Makefile: Likewise. * sysdeps/m68k/Makefile: Likewise. * sysdeps/mips/Makefile: Likewise. * sysdeps/nios2/Makefile: Likewise. * sysdeps/sh/Makefile: Likewise. * sysdeps/sparc/Makefile: Likewise. diff --git a/csu/Makefile b/csu/Makefile index 88646b6e8f068c09c5743fd908b08d15064294ee..490d0b0f3b63318381e59fc35038801f682d20a2 100644 --- a/csu/Makefile +++ b/csu/Makefile @@ -82,6 +82,9 @@ extra-objs += $(crtstuff:=.o) extra-objs += abi-note.o init.o asm-CPPFLAGS += -I$(objpfx). +# Enable unwinding so backtrace unwinds to __libc_start_main +CFLAGS-libc-start.c += -funwind-tables + include ../Rules # Make these in the lib pass so they're available in time to link things with. diff --git a/debug/Makefile b/debug/Makefile index cd4975c35b70fe4c52fc6bbedb0f88179463af9c..620a0b71f5919d41cc5cb41d0943193d8e7b6ac5 100644 --- a/debug/Makefile +++ b/debug/Makefile @@ -59,7 +59,7 @@ static-only-routines := warning-nop stack_chk_fail_local CFLAGS-stack_chk_fail.c = $(no-stack-protector) CFLAGS-stack_chk_fail_local.c = $(no-stack-protector) -CFLAGS-backtrace.c = -fno-omit-frame-pointer +CFLAGS-backtrace.c = -fno-omit-frame-pointer -funwind-tables CFLAGS-sprintf_chk.c = $(libio-mtsafe) CFLAGS-snprintf_chk.c = $(libio-mtsafe) CFLAGS-vsprintf_chk.c = $(libio-mtsafe) diff --git a/sysdeps/aarch64/Makefile b/sysdeps/aarch64/Makefile index 562c1373aebee6ffb4ff5c2071a23d007a8e07ba..5f3e20371accfb001de6dff342bb323b424324ca 100644 --- a/sysdeps/aarch64/Makefile +++ b/sysdeps/aarch64/Makefile @@ -1,9 +1,5 @@ long-double-fcts = yes -ifeq ($(subdir),debug) -CFLAGS-backtrace.c += -funwind-tables -endif - ifeq ($(subdir),elf) sysdep-dl-routines += tlsdesc dl-tlsdesc gen-as-const-headers += dl-link.sym diff --git a/sysdeps/arm/Makefile b/sysdeps/arm/Makefile index 2849aeda4238997975c5a8096da474e54da26932..ad2042b93a156867f586bedaaba4b120a93f676c 100644 --- a/sysdeps/arm/Makefile +++ b/sysdeps/arm/Makefile @@ -51,11 +51,6 @@ sysdep_routines += $(aeabi_constants) $(aeabi_routines) static-only-routines += $(aeabi_constants) aeabi_read_tp shared-only-routines += libc-aeabi_read_tp -# In order for unwinding to fail when it falls out of main, we need a -# cantunwind marker. There's one in start.S. To make sure we reach it, add -# unwind tables for __libc_start_main. -CFLAGS-libc-start.c += -fexceptions - sysdep_routines += arm-unwind-resume shared-only-routines += arm-unwind-resume endif @@ -64,10 +59,6 @@ ifeq ($(subdir),gmon) sysdep_routines += arm-mcount endif -ifeq ($(subdir),debug) -CFLAGS-backtrace.c += -funwind-tables -endif - ifeq ($(subdir),rt) librt-sysdep_routines += rt-aeabi_unwind_cpp_pr1 rt-arm-unwind-resume librt-shared-only-routines += rt-aeabi_unwind_cpp_pr1 rt-arm-unwind-resume diff --git a/sysdeps/i386/Makefile b/sysdeps/i386/Makefile index e30e1339f0554dd53be1ab881cb4df04de820792..a1500454e5a977415b8bd120326f3db104d18df2 100644 --- a/sysdeps/i386/Makefile +++ b/sysdeps/i386/Makefile @@ -19,10 +19,6 @@ CFLAGS-dl-load.c += -Wno-unused CFLAGS-dl-reloc.c += -Wno-unused endif -ifeq ($(subdir),debug) -CFLAGS-backtrace.c += -fexceptions -endif - # Most of the glibc routines don't ever call user defined callbacks # nor use any FPU or SSE* and as such don't need bigger %esp alignment # than 4 bytes. diff --git a/sysdeps/m68k/Makefile b/sysdeps/m68k/Makefile index 26539fa01d38a5ba1260cb1fda153470513d2e29..b6910014f8fe75591026381d4b6a9e02301740d7 100644 --- a/sysdeps/m68k/Makefile +++ b/sysdeps/m68k/Makefile @@ -40,10 +40,6 @@ ifeq ($(subdir),setjmp) CFLAGS-setjmp.c := -fno-omit-frame-pointer endif -ifeq ($(subdir),debug) -CFLAGS-backtrace.c += -funwind-tables -endif - ifeq ($(subdir),elf) CFLAGS-rtld.c += -Wno-uninitialized -Wno-unused endif diff --git a/sysdeps/mips/Makefile b/sysdeps/mips/Makefile index 7c1d77941ec154b460af9b2581cec7e82141acdf..fd891ddf09855adaac3d50f57ca9bd245fbc16e2 100644 --- a/sysdeps/mips/Makefile +++ b/sysdeps/mips/Makefile @@ -12,10 +12,6 @@ librt-sysdep_routines += rt-sysdep librt-shared-only-routines += rt-sysdep endif -ifeq ($(subdir),debug) -CFLAGS-backtrace.c += -funwind-tables -endif - ifeq ($(subdir),csu) CPPFLAGS-crti.S += $(pic-ccflag) CPPFLAGS-crtn.S += $(pic-ccflag) diff --git a/sysdeps/nios2/Makefile b/sysdeps/nios2/Makefile index 75cab5e5b8fc04e916ced8e1b9c3a8ecc657b85d..9ceab11297a7d215e3a30d3ecf2210029a89a51b 100644 --- a/sysdeps/nios2/Makefile +++ b/sysdeps/nios2/Makefile @@ -29,7 +29,3 @@ endif ifeq ($(subdir),csu) gen-as-const-headers += tcb-offsets.sym endif - -ifeq ($(subdir),debug) -CFLAGS-backtrace.c += -funwind-tables -endif diff --git a/sysdeps/sh/Makefile b/sysdeps/sh/Makefile index 0c6db9a9d41d56defb946fcc31e0767c7a853611..de8fa0bc0e81e8b7e1ef946b7106408cf4ac7cd1 100644 --- a/sysdeps/sh/Makefile +++ b/sysdeps/sh/Makefile @@ -5,7 +5,3 @@ endif ifeq ($(subdir),gmon) sysdep_routines += _mcount endif - -ifeq ($(subdir),debug) -CFLAGS-backtrace.c += -funwind-tables -endif diff --git a/sysdeps/sparc/Makefile b/sysdeps/sparc/Makefile index 31aaeaed8f8e601b578908e13a6f99352346f753..3f0c0964002560f03817905f390821aef176d52c 100644 --- a/sysdeps/sparc/Makefile +++ b/sysdeps/sparc/Makefile @@ -3,10 +3,6 @@ long-double-fcts = yes pie-ccflag = -fPIE -ifeq ($(subdir),debug) -CFLAGS-backtrace.c += -funwind-tables -endif - ifeq ($(subdir),gmon) sysdep_routines += sparc-mcount endif