From patchwork Fri Nov 4 18:26:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 59953 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 1459E3858432 for ; Fri, 4 Nov 2022 18:27:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1459E3858432 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1667586423; bh=0+Qvu0l06sDLt0kVGy8EvSyggIqTKPjP6af4uXtIyeY=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=HJ5iHzaeku5NY4Et1MBHLwbu2UVml0ZVMNK8zvPeolz1NtUkGnuzemRT8zaQxIcmt NP3BJhhZp5ngCzcPBcVSCiMpfwM7jaeP9HORBGvrO32RdRubLpTkzeF6BvM7vMtIvW A3vHyEy1uLtfIZtvguQdJgIVyKXxARD9dqUnRzms= 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 661E23858429 for ; Fri, 4 Nov 2022 18:26:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 661E23858429 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-189-t5kB19SBMx-GpVdVtlZ6fg-1; Fri, 04 Nov 2022 14:26:35 -0400 X-MC-Unique: t5kB19SBMx-GpVdVtlZ6fg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 40C55185A79C; Fri, 4 Nov 2022 18:26:35 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 587F4140EBF5; Fri, 4 Nov 2022 18:26:34 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH] elf: Disable some subtests of ifuncmain1, ifuncmain5 for !PIE Date: Fri, 04 Nov 2022 19:26:32 +0100 Message-ID: <87fseyy3s7.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 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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 Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Tested on i686-linux-gnu, x86_64-linux-gnu (with glibc defaults on a toolchain which is not PIE-by-default). Built with build-many-glibcs.py defaults (so GCC 12 and binutils 2.39). The x86 failures are gone. Reviewed-by: Fangrui Song --- elf/ifuncmain1.c | 13 +++++++++++++ elf/ifuncmain5.c | 9 +++++++++ 2 files changed, 22 insertions(+) base-commit: 2ff48a4025515e93d722947a9eabb114f4a65b22 diff --git a/elf/ifuncmain1.c b/elf/ifuncmain1.c index 747fc02648..6effce3d77 100644 --- a/elf/ifuncmain1.c +++ b/elf/ifuncmain1.c @@ -19,7 +19,14 @@ typedef int (*foo_p) (void); #endif foo_p foo_ptr = foo; + +/* Address-significant access to protected symbols is not supported in + position-dependent mode on several architectures because GCC + generates relocations that assume that the address is local to the + main program. */ +#ifdef __PIE__ foo_p foo_procted_ptr = foo_protected; +#endif extern foo_p get_foo_p (void); extern foo_p get_foo_hidden_p (void); @@ -37,12 +44,16 @@ main (void) if ((*foo_ptr) () != -1) abort (); +#ifdef __PIE__ if (foo_procted_ptr != foo_protected) abort (); +#endif if (foo_protected () != 0) abort (); +#ifdef __PIE__ if ((*foo_procted_ptr) () != 0) abort (); +#endif p = get_foo_p (); if (p != foo) @@ -55,8 +66,10 @@ main (void) abort (); p = get_foo_protected_p (); +#ifdef __PIE__ if (p != foo_protected) abort (); +#endif if (ret_foo_protected != 0 || (*p) () != ret_foo_protected) abort (); diff --git a/elf/ifuncmain5.c b/elf/ifuncmain5.c index f398085cb4..6fda768fb6 100644 --- a/elf/ifuncmain5.c +++ b/elf/ifuncmain5.c @@ -14,12 +14,19 @@ get_foo (void) return foo; } + +/* Address-significant access to protected symbols is not supported in + position-dependent mode on several architectures because GCC + generates relocations that assume that the address is local to the + main program. */ +#ifdef __PIE__ foo_p __attribute__ ((noinline)) get_foo_protected (void) { return foo_protected; } +#endif int main (void) @@ -30,9 +37,11 @@ main (void) if ((*p) () != -1) abort (); +#ifdef __PIE__ p = get_foo_protected (); if ((*p) () != 0) abort (); +#endif return 0; }