From patchwork Mon May 2 19:15:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 53400 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 C57AA3857C6F for ; Mon, 2 May 2022 19:16:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C57AA3857C6F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1651519003; bh=9DdnXeZOd0bKhAOEv7xuwCgUPkmSNqeILkmEDMDPRPw=; h=To:Subject:In-Reply-To:References:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=mryH4y5rrBEGNbiunmC5Z5saZQrFk4rfr98debV4q9QjLhOLi+rgz4JBHgx0d8TKc oZ1pxsyoyMr4cgAinA/bwKj3uRzQBdJLarHQZfYGmYfHhiR+3kLGhCqv1nCQ10eWLu gVeQ6/pbCipdlt0dtl2dALV9Dpg2IDmwoQoxE9HU= 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.133.124]) by sourceware.org (Postfix) with ESMTPS id 8A0793858427 for ; Mon, 2 May 2022 19:15:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8A0793858427 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-292-rBmYov74Ofm2-VOUONkpyA-1; Mon, 02 May 2022 15:15:36 -0400 X-MC-Unique: rBmYov74Ofm2-VOUONkpyA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0944829AB45B for ; Mon, 2 May 2022 19:15:36 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.59]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6206AC27EB2 for ; Mon, 2 May 2022 19:15:35 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH 1/5] Linux: Implement a useful version of _startup_fatal In-Reply-To: References: X-From-Line: 7a6a51b346a81484046ba392a9854a88568a92aa Mon Sep 17 00:00:00 2001 Message-Id: <7a6a51b346a81484046ba392a9854a88568a92aa.1651518694.git.fweimer@redhat.com> Date: Mon, 02 May 2022 21:15:33 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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 Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" --- sysdeps/unix/sysv/linux/i386/startup.h | 17 ++---------- sysdeps/unix/sysv/linux/startup.h | 38 ++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 15 deletions(-) create mode 100644 sysdeps/unix/sysv/linux/startup.h diff --git a/sysdeps/unix/sysv/linux/i386/startup.h b/sysdeps/unix/sysv/linux/i386/startup.h index 67c9310f3a..694d6cf4e7 100644 --- a/sysdeps/unix/sysv/linux/i386/startup.h +++ b/sysdeps/unix/sysv/linux/i386/startup.h @@ -19,19 +19,6 @@ #if BUILD_PIE_DEFAULT /* Can't use "call *%gs:SYSINFO_OFFSET" during statup in static PIE. */ # define I386_USE_SYSENTER 0 - -# include -# include - -__attribute__ ((__noreturn__)) -static inline void -_startup_fatal (const char *message __attribute__ ((unused))) -{ - /* This is only called very early during startup in static PIE. - FIXME: How can it be improved? */ - ABORT_INSTRUCTION; - __builtin_unreachable (); -} -#else -# include_next #endif + +#include_next diff --git a/sysdeps/unix/sysv/linux/startup.h b/sysdeps/unix/sysv/linux/startup.h new file mode 100644 index 0000000000..a5de941759 --- /dev/null +++ b/sysdeps/unix/sysv/linux/startup.h @@ -0,0 +1,38 @@ +/* Linux definitions of functions used by static libc main startup. + Copyright (C) 2017-2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifdef SHARED +# include_next +#else +# include + +/* Avoid a run-time invocation of strlen. */ +#define _startup_fatal(message) \ + do \ + { \ + size_t message_length = __builtin_strlen (message); \ + if (! __builtin_constant_p (message_length)) \ + { \ + extern void _startup_fatal_not_constant (void); \ + _startup_fatal_not_constant (); \ + } \ + INTERNAL_SYSCALL_CALL (write, STDERR_FILENO, message, message_length); \ + INTERNAL_SYSCALL_CALL (exit_group, 127); \ + } \ + while (0) +#endif /* !SHARED */