From patchwork Thu Dec 16 19:31:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 49019 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A5F393858003 for ; Thu, 16 Dec 2021 19:32:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A5F393858003 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1639683153; bh=f/MeAhMPU2feveovMyDrLNcMfSb4glCDfN5lc5KVoDg=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=Hb9OOgUC4Nt06LI3KNtGeqn3a1n6eqZTlR/zzW2qGVETPj5bm2II5qfpkdK3hTcM3 KZoDWkUzV6OCOJ6aj2hiTPj2oTs6mCW3CajIaNc84Lc/WgA1EvPp5+06/7vf2IRwIF bf58oYk3iZUb6TZaT4F/iawQxlKu+84QMBkiqtnk= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 39B2F3858D35 for ; Thu, 16 Dec 2021 19:32:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 39B2F3858D35 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-313-7hHwZ_MqMPeo7CPFmUEdpw-1; Thu, 16 Dec 2021 14:32:03 -0500 X-MC-Unique: 7hHwZ_MqMPeo7CPFmUEdpw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 92ADC801B2A; Thu, 16 Dec 2021 19:32:02 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.17.223]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 775745F92C; Thu, 16 Dec 2021 19:32:01 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH] arm: Guard ucontext _rtld_global_ro access by SHARED, not PIC macro Date: Thu, 16 Dec 2021 20:31:59 +0100 Message-ID: <87r1acgxcg.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_STOCKGEN, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Florian Weimer via Libc-alpha From: Florian Weimer Reply-To: Florian Weimer Cc: Szabolcs Nagy , Siddhesh Poyarekar Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Due to PIE-by-default, PIC is now defined in more cases. libc.a does not have _rtld_global_ro, and statically linking setcontext fails. SHARED is the right condition to use, so that libc.a references _dl_hwcap instead of _rtld_global_ro. For static PIE support, the !SHARED case would still have to be made PIC. This patch does not achieve that. Fixes commit 23645707f12f2dd9d80b51effb2d9618a7b65565 ("Replace --enable-static-pie with --disable-default-pie"). Please not that I have not been able to test/build this change so far. Thanks, Florian Reviewed-by: Siddhesh Poyarekar Reviewed-by: Szabolcs Nagy --- sysdeps/unix/sysv/linux/arm/getcontext.S | 4 ++-- sysdeps/unix/sysv/linux/arm/setcontext.S | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sysdeps/unix/sysv/linux/arm/getcontext.S b/sysdeps/unix/sysv/linux/arm/getcontext.S index 3aa581c4da..11bfcbe5f5 100644 --- a/sysdeps/unix/sysv/linux/arm/getcontext.S +++ b/sysdeps/unix/sysv/linux/arm/getcontext.S @@ -50,7 +50,7 @@ ENTRY(__getcontext) /* Store FP regs. Much of the FP code is copied from arm/setjmp.S. */ -#ifdef PIC +#ifdef SHARED ldr r2, 1f ldr r1, .Lrtld_global_ro 0: add r2, pc, r2 @@ -102,7 +102,7 @@ ENTRY(__getcontext) END(__getcontext) -#ifdef PIC +#ifdef SHARED 1: .long _GLOBAL_OFFSET_TABLE_ - 0b - PC_OFS .Lrtld_global_ro: .long C_SYMBOL_NAME(_rtld_global_ro)(GOT) diff --git a/sysdeps/unix/sysv/linux/arm/setcontext.S b/sysdeps/unix/sysv/linux/arm/setcontext.S index 8be8beefea..4c7c6e5509 100644 --- a/sysdeps/unix/sysv/linux/arm/setcontext.S +++ b/sysdeps/unix/sysv/linux/arm/setcontext.S @@ -32,7 +32,7 @@ ENTRY(__setcontext) add r0, r0, #UCONTEXT_REGSPACE /* Restore the VFP registers. Copied from arm/__longjmp.S. */ -#ifdef PIC +#ifdef SHARED ldr r2, 1f ldr r1, .Lrtld_global_ro 0: add r2, pc, r2 @@ -101,7 +101,7 @@ ENTRY(__startcontext) .fnend END(__startcontext) -#ifdef PIC +#ifdef SHARED 1: .long _GLOBAL_OFFSET_TABLE_ - 0b - PC_OFS .Lrtld_global_ro: .long C_SYMBOL_NAME(_rtld_global_ro)(GOT)