From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) by sourceware.org (Postfix) with ESMTPS id 24F4E385840F for ; Thu, 5 May 2022 17:29:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 24F4E385840F Received: by mail-oi1-x22f.google.com with SMTP id e189so5022904oia.8 for ; Thu, 05 May 2022 10:29:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=veWe3o2QCBkxVPaOUgXCmgDdU0dzAlM5ONvRsmCqb4o=; b=MuO5h4gLc0X5Bn2Rx2hOYWO3njO6G42P6WzZZ44QQn4Xu5fYxtBHN1Hb7U9/9XDdtm M7OBC9ytVdiaEyzjqzKX9fvRiDwDfqn1uOwfYOloyqvhO5PKnqOC/CwT1ccqRp2JbGHw OChAks/vey5+7BKRvbT8LaQ0UL8ehRZUQWLqfBGK+9/vMQVoatS1bMZahoGtn7GepetI vkXXTiKzmUYnhpm40xZfLDLos3GqzCxSlRVw9Kr2Lk3wiiCLtoPzsRU74hdFsysFpsbg I/gq3z15Lt9iYh2I4IyJdlByyTTPEHT2GtOSvzoogUqMqx6iS8851z5Km0Lko2mPRGRv 4MEw== X-Gm-Message-State: AOAM533tlYddnV2tXb3hbG2JXwrWkjFKZMnorfNZD5MQNBBPvOjZx8sS d6dyKKKhlcSeHcEEwTYWOm+Qfs2SfcFd3Q== X-Google-Smtp-Source: ABdhPJz/50WmUfoPiYmWGtRAcWBOlRfzFvqD1lhXpAsJeVgntPlmv6QpMfKO3ok1gEtPwJeLZsO9qQ== X-Received: by 2002:aca:3e41:0:b0:2ec:f51d:946 with SMTP id l62-20020aca3e41000000b002ecf51d0946mr3086493oia.138.1651771754791; Thu, 05 May 2022 10:29:14 -0700 (PDT) Received: from ?IPV6:2804:431:c7cb:726:f51f:3382:ab1c:b594? ([2804:431:c7cb:726:f51f:3382:ab1c:b594]) by smtp.gmail.com with ESMTPSA id bj34-20020a05680819a200b00325cda1ffa7sm709139oib.38.2022.05.05.10.29.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 05 May 2022 10:29:13 -0700 (PDT) Message-ID: <655165a2-dd15-7372-9421-73c178b8b509@linaro.org> Date: Thu, 5 May 2022 14:29:11 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH v4 2/3] Linux: Implement a useful version of _startup_fatal Content-Language: en-US To: Florian Weimer , libc-alpha@sourceware.org References: <71808d9fc272aa3cfb78c905dd5aedd39bb903f6.1651762968.git.fweimer@redhat.com> From: Adhemerval Zanella In-Reply-To: <71808d9fc272aa3cfb78c905dd5aedd39bb903f6.1651762968.git.fweimer@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-14.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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-List-Received-Date: Thu, 05 May 2022 17:29:17 -0000 On 05/05/2022 12:07, Florian Weimer via Libc-alpha wrote: > On i386 and ia64, the TCB is not available at this point. LGTM, thanks. Reviewed-by: Adhemerval Zanella > --- > v4: Unchanged. > v3: Use 2022 copyright year. Fix “statup” typo. Use __message_length > local variable in _startup_fatal. > sysdeps/unix/sysv/linux/i386/startup.h | 23 +++------------ > sysdeps/unix/sysv/linux/ia64/startup.h | 22 +++++++++++++++ > sysdeps/unix/sysv/linux/startup.h | 39 ++++++++++++++++++++++++++ > 3 files changed, 65 insertions(+), 19 deletions(-) > create mode 100644 sysdeps/unix/sysv/linux/ia64/startup.h > 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..213805d7d2 100644 > --- a/sysdeps/unix/sysv/linux/i386/startup.h > +++ b/sysdeps/unix/sysv/linux/i386/startup.h > @@ -1,5 +1,5 @@ > /* Linux/i386 definitions of functions used by static libc main startup. > - Copyright (C) 2017-2022 Free Software Foundation, Inc. > + Copyright (C) 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 > @@ -16,22 +16,7 @@ > License along with the GNU C Library; if not, see > . */ > > -#if BUILD_PIE_DEFAULT > -/* Can't use "call *%gs:SYSINFO_OFFSET" during statup in static PIE. */ > -# define I386_USE_SYSENTER 0 > +/* Can't use "call *%gs:SYSINFO_OFFSET" during startup. */ > +#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/ia64/startup.h b/sysdeps/unix/sysv/linux/ia64/startup.h > new file mode 100644 > index 0000000000..77f29f15a2 > --- /dev/null > +++ b/sysdeps/unix/sysv/linux/ia64/startup.h > @@ -0,0 +1,22 @@ > +/* Linux/ia64 definitions of functions used by static libc main startup. > + Copyright (C) 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 > + . */ > + > +/* This code is used before the TCB is set up. */ > +#define IA64_USE_NEW_STUB 0 > + > +#include_next > diff --git a/sysdeps/unix/sysv/linux/startup.h b/sysdeps/unix/sysv/linux/startup.h > new file mode 100644 > index 0000000000..39859b404a > --- /dev/null > +++ b/sysdeps/unix/sysv/linux/startup.h > @@ -0,0 +1,39 @@ > +/* 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 */