Message ID | 20230110072434.3863-6-w@1wt.eu |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2602733wrt; Mon, 9 Jan 2023 23:28:03 -0800 (PST) X-Google-Smtp-Source: AMrXdXvZ66qqkdmtjeJn7NCbG3rbN5UCvCXoey5xM4Bn67hUeARaI/1sZX76Z5YfED13AfRPRKbU X-Received: by 2002:a05:6a20:3b27:b0:ad:5747:a507 with SMTP id c39-20020a056a203b2700b000ad5747a507mr72094690pzh.3.1673335682907; Mon, 09 Jan 2023 23:28:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673335682; cv=none; d=google.com; s=arc-20160816; b=JiyrF2PsluHlSQWypaSFGt3n8WUOUyw8O5D1XXs5pvxeMi1Y+7Vde34p3GM6PJRHOb 3Ju+9waZVmAD1hd3JKvJgFjz+X00BwKikZF7jIwlxusXduksgJBMrXTyc1wB/Cxqe/iQ l3nrUNyMPIxDSRTgCIczHPM8CJre6VYexKEZlnaQDxxtQRfo+5GDBWQlye7ePTH496yQ 1YTXJ2mOLVLmvrkuwrTz8RipsjkpkLFmllr9DAcd5wJCYLCKmjuNkcl+fdIHm8voxWFd vLjyjZ5pIkGrO8bj7/eRTAJ0VOrznsXPRXQw2KDBWwWrHz09pwyXajDjt1lWvlUq7bTj nl2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=ePcxfWHA/VDoNR7GA64E55XohqTis3V1a5fi5+l48Hk=; b=jXb+aKmXIxR4vnWh8bKovkDD76ckjghgvBPkrPdIOk0B5rlu4zS+38/oRGXR9lhk4f YGm4phpkeoSZLEqE8YmuIoYAx3xmsFNRoclKQhZfIDzO/9IkFdy+5c6iHIlFdBrK3kWk AJT2mPO5kprrTrbJAeTxmlNZk91vgJ0enSfSBNUQhNxT6GrGINNQRLEGlWRx8OSCcGvm qFyzytq/9cYTHj9csn0btahxAG7GrtZjgU0o+9sFgcJOmsxVZyTSIhUsZ+eDINuUg3JJ 3CdgHoNY9W82M5qSF2WIC62hGq9DVVxr9xl0RiodAnYo4i9FhLEJdga6AsWX9s1/SP4X 2nPw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bc22-20020a656d96000000b00462f17e560csi10589068pgb.878.2023.01.09.23.27.50; Mon, 09 Jan 2023 23:28:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235424AbjAJH0h (ORCPT <rfc822;syz17693488234@gmail.com> + 99 others); Tue, 10 Jan 2023 02:26:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237835AbjAJHZr (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 10 Jan 2023 02:25:47 -0500 Received: from 1wt.eu (wtarreau.pck.nerim.net [62.212.114.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 21BF2496CA for <linux-kernel@vger.kernel.org>; Mon, 9 Jan 2023 23:25:30 -0800 (PST) Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 30A7Obh5003932; Tue, 10 Jan 2023 08:24:37 +0100 From: Willy Tarreau <w@1wt.eu> To: "Paul E. McKenney" <paulmck@kernel.org> Cc: linux-kernel@vger.kernel.org, Willy Tarreau <w@1wt.eu> Subject: [PATCH v2 05/22] tools/nolibc: make errno a weak symbol instead of a static one Date: Tue, 10 Jan 2023 08:24:17 +0100 Message-Id: <20230110072434.3863-6-w@1wt.eu> X-Mailer: git-send-email 2.17.5 In-Reply-To: <20230110072434.3863-1-w@1wt.eu> References: <20230110072434.3863-1-w@1wt.eu> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754619637026166825?= X-GMAIL-MSGID: =?utf-8?q?1754619637026166825?= |
Series |
nolibc: usability improvements (errno, environ, auxv)
|
|
Commit Message
Willy Tarreau
Jan. 10, 2023, 7:24 a.m. UTC
Till now errno was declared static so that it could be eliminated if
unused. While the goal is commendable for tiny executables as it allows
to eliminate any data and bss segments when not used, this comes with
some limitations, one of which being that the errno symbol seen in
different units are not the same. Even though this has never been a
real issue given the nature of the programs involved till now, it
happens that referencing the same symbol from multiple units can also
be achieved using weak symbols, with a difference being that only one
of them will be used for all of them. Compared to weak symbols, static
basically have no benefit for regular programs since there are always
at least a few variables in most of these, so the bss segment cannot
be eliminated. E.g:
$ size nolibc-test-static-errno
text data bss dec hex filename
11531 0 48 11579 2d3b nolibc-test-static-errno
Furthermore, the weak symbol doesn't use bss storage at all, resulting
in a slightly section:
$ size nolibc-test-weak-errno
text data bss dec hex filename
11531 0 40 11571 2d33 nolibc-test-weak-errno
This patch thus converts errno from static to weak.
Signed-off-by: Willy Tarreau <w@1wt.eu>
---
tools/include/nolibc/errno.h | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/tools/include/nolibc/errno.h b/tools/include/nolibc/errno.h index 9dc4919c769b..a44486ff0477 100644 --- a/tools/include/nolibc/errno.h +++ b/tools/include/nolibc/errno.h @@ -9,11 +9,9 @@ #include <asm/errno.h> -/* this way it will be removed if unused */ -static int errno; - #ifndef NOLIBC_IGNORE_ERRNO #define SET_ERRNO(v) do { errno = (v); } while (0) +int errno __attribute__((weak)); #else #define SET_ERRNO(v) do { } while (0) #endif