From patchwork Tue Aug 8 12:27:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 1818594 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=ldk8+sgg; dkim-atps=neutral Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RKssw5fgzz1yYC for ; Tue, 8 Aug 2023 22:28:20 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C21D83857838 for ; Tue, 8 Aug 2023 12:28:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C21D83857838 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1691497698; bh=gps6RjFVV6cQIqOj6+ggouqL7vS6EZl1gCjrkMJXi9Y=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=ldk8+sggWaMroxPnaD7A6EGVErwbIv+yXcUpAcCAHCNOPMMBqsb91RkVxNNrstq37 OKZaXrLAxYiiv3Rxzeb2ZGYQSrTB+PY5MaZCDbhAAlzzKLFmFifx27GR8cBEkxJtqs k0lUEFz/5KTgXI6X21QOU4DQsbNsEkAHFSvixbmE= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oi1-x230.google.com (mail-oi1-x230.google.com [IPv6:2607:f8b0:4864:20::230]) by sourceware.org (Postfix) with ESMTPS id D424F3858D39 for ; Tue, 8 Aug 2023 12:28:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D424F3858D39 Received: by mail-oi1-x230.google.com with SMTP id 5614622812f47-3a78604f47fso2939286b6e.1 for ; Tue, 08 Aug 2023 05:28:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691497681; x=1692102481; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gps6RjFVV6cQIqOj6+ggouqL7vS6EZl1gCjrkMJXi9Y=; b=aPkZRWw+NientTy6jSMGBpm8N1eTHKt13Fn0tXXFyjB043YLncU51yjpxO14thdD4C KfaRfsPLgLj0r/KD9SkcPwrXOKl16Iw7udqBYwiANbR1dCDtxeveFQ9vPx6QYguTq4tG tgXQio7Bx5mWPGgt8CeRpdWWTBVTAXEwt67Wh8wx4q0qHPg+I2SjBDX8uksVFkgnbTU8 bT5wdL4xf5u81npe7TmIP+1h1sm0x/F3hY8SiUD/2ZpB1zTLZpNtb4Gj0jpkt/zl2sb2 2zkP7+3f8B789nqhIs6bvUdjZulb0xIT0N87ZPVfFfgEdNzf29uo6lBA4kv0L33wSVC1 k9TQ== X-Gm-Message-State: AOJu0YxbQaLFB0yCxPW0BZLhcKhgPrUMTKgzNpN90DuhA1nOYjE2+uM5 fybY9HVq87DZOZvOExD6W7RWxEhDiA509J/BXj2wQQ== X-Google-Smtp-Source: AGHT+IF126P3k0JjnXrZmOva1OBqACBHef0RtAT72bJ+niXal+qYKM7faoFkZnQF0ofLuiXaNS3kOQ== X-Received: by 2002:a05:6808:20a7:b0:3a7:9c89:1b9a with SMTP id s39-20020a05680820a700b003a79c891b9amr7363074oiw.22.1691497681426; Tue, 08 Aug 2023 05:28:01 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c1:9aa9:aad7:32fb:7ea7:f8f5]) by smtp.gmail.com with ESMTPSA id j9-20020a056808118900b003a42c45c109sm5799401oil.2.2023.08.08.05.27.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Aug 2023 05:28:00 -0700 (PDT) To: libc-alpha@sourceware.org, "Andreas K . Huettel" Subject: [PATCH 1/2] x86_64: Fix build with --disable-multiarch (BZ 30721) Date: Tue, 8 Aug 2023 09:27:54 -0300 Message-Id: <20230808122755.66307-2-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230808122755.66307-1-adhemerval.zanella@linaro.org> References: <20230808122755.66307-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" With multiarch disabled, the default memmove implementation provides the fortify routines for memcpy, mempcpy, and memmove. However, it does not provide the internal hidden definitions used when building with fortify enabled. The memset has a similar issue. Checked on x86_64-linux-gnu building with different options: default and --disable-multi-arch plus default, --disable-default-pie, --enable-fortify-source={2,3}, and --enable-fortify-source={2,3} with --disable-default-pie. Tested-by: Andreas K. Huettel Reviewed-by: Siddhesh Poyarekar --- sysdeps/x86_64/memcpy.S | 2 +- sysdeps/x86_64/memmove.S | 3 +++ sysdeps/x86_64/memset.S | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/sysdeps/x86_64/memcpy.S b/sysdeps/x86_64/memcpy.S index d98500a78a..4922cba657 100644 --- a/sysdeps/x86_64/memcpy.S +++ b/sysdeps/x86_64/memcpy.S @@ -1 +1 @@ -/* Implemented in memcpy.S. */ +/* Implemented in memmove.S. */ diff --git a/sysdeps/x86_64/memmove.S b/sysdeps/x86_64/memmove.S index f0b84e3b52..c3c08165e1 100644 --- a/sysdeps/x86_64/memmove.S +++ b/sysdeps/x86_64/memmove.S @@ -46,6 +46,9 @@ weak_alias (__mempcpy, mempcpy) #ifndef USE_MULTIARCH libc_hidden_builtin_def (memmove) +libc_hidden_builtin_def (__memmove_chk) +libc_hidden_builtin_def (__memcpy_chk) +libc_hidden_builtin_def (__mempcpy_chk) # if defined SHARED && IS_IN (libc) strong_alias (memmove, __memcpy) libc_hidden_ver (memmove, memcpy) diff --git a/sysdeps/x86_64/memset.S b/sysdeps/x86_64/memset.S index 7c99df36db..c6df24e8de 100644 --- a/sysdeps/x86_64/memset.S +++ b/sysdeps/x86_64/memset.S @@ -32,6 +32,7 @@ #include "isa-default-impl.h" libc_hidden_builtin_def (memset) +libc_hidden_builtin_def (__memset_chk) #if IS_IN (libc) libc_hidden_def (__wmemset) From patchwork Tue Aug 8 12:27:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 1818595 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=IAwXACjg; dkim-atps=neutral Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RKssx5GM7z1yfh for ; Tue, 8 Aug 2023 22:28:21 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6548F385734D for ; Tue, 8 Aug 2023 12:28:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6548F385734D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1691497699; bh=luJW+/6crfyqRRMXpSyXps58WWXiTmnGdbZ5s8MLICU=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=IAwXACjgYCCXxhWtdBC9knROcx0YK8YwxZiAPyM0tb520sJyU8F8+nb9GCISlDCUb 7mNPTC++iYWF1Dun4TlmBetj6rldQnbbg+6ghNgWLvP2wg5rjmjzwu3fA9c3aUcxla qOSzL21QDDDDtoIMjrAa4j2MntWLAGlOZOXdXaQ8= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oi1-x234.google.com (mail-oi1-x234.google.com [IPv6:2607:f8b0:4864:20::234]) by sourceware.org (Postfix) with ESMTPS id 884FE3858288 for ; Tue, 8 Aug 2023 12:28:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 884FE3858288 Received: by mail-oi1-x234.google.com with SMTP id 5614622812f47-3a5ad6087a1so3117323b6e.2 for ; Tue, 08 Aug 2023 05:28:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691497683; x=1692102483; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=luJW+/6crfyqRRMXpSyXps58WWXiTmnGdbZ5s8MLICU=; b=a7hwZUb5Z0PKN7R+v5jZcyfD3x62XF1+PehluB57stAdZok/hQtffiUhRPNlAeYT76 TtUF3cLgxejvxyvxlt0nU7cWy7/dYaKqvIAW6FCzhODvXJeVHCr2bNjIwgqrZMGUC/5n Wr8JARK3j41AWTLyWvCvOHJZalLDLfzpgffG1RO3Yps2L7OmWWdI3iTZaMPxEVQSffSA +71bKX+E4je6FvNsjUW3L10uuPQX33Xvb80jO3BBDngfRCNpRRSKYq7PEOFUA8IjD/ww z5iDYiNQgQMfUVjdjVCZsMv2aQbU91ESIUDhe/8l2wQrDG71mCoUtuk1dGm5jTd13iQG YRug== X-Gm-Message-State: AOJu0YzX7HufFOn8htZWCGN0UnfSmkMV5zASCACdoVMIRL2HSSXNYwVs mpWukikd/bCSNCb9VDGDFu3UY3qRA0nfM/UP+fNT8w== X-Google-Smtp-Source: AGHT+IFXbUGM3ad5BKYwaxQuVyxc7cQbt4yQxsLVqH0w8z1mXL4ntdea+ZtBkOj/niubPwpNyaDj5Q== X-Received: by 2002:a05:6808:1382:b0:3a3:820e:2f05 with SMTP id c2-20020a056808138200b003a3820e2f05mr14278796oiw.1.1691497683165; Tue, 08 Aug 2023 05:28:03 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c1:9aa9:aad7:32fb:7ea7:f8f5]) by smtp.gmail.com with ESMTPSA id j9-20020a056808118900b003a42c45c109sm5799401oil.2.2023.08.08.05.28.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Aug 2023 05:28:02 -0700 (PDT) To: libc-alpha@sourceware.org, "Andreas K . Huettel" Subject: [PATCH 2/2] i686: Fix build with --disable-multiarch Date: Tue, 8 Aug 2023 09:27:55 -0300 Message-Id: <20230808122755.66307-3-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230808122755.66307-1-adhemerval.zanella@linaro.org> References: <20230808122755.66307-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Since i686 provides the fortified wrappers for memcpy, mempcpy, memmove, and memset on the same string implementation, the static build tries to optimized it by not tying the fortified wrappers to string routine (to avoid pulling the fortify function if they are not required). Checked on i686-linux-gnu building with different option: default and --disable-multi-arch plus default, --disable-default-pie, --enable-fortify-source={2,3}, and --enable-fortify-source={2,3} with --disable-default-pie. Reviewed-by: Siddhesh Poyarekar --- sysdeps/i386/i686/memcpy.S | 2 +- sysdeps/i386/i686/mempcpy.S | 2 +- sysdeps/i386/i686/multiarch/memcpy_chk.c | 2 ++ sysdeps/i386/i686/multiarch/memmove_chk.c | 2 ++ sysdeps/i386/i686/multiarch/mempcpy_chk.c | 2 ++ sysdeps/i386/i686/multiarch/memset_chk.c | 2 ++ 6 files changed, 10 insertions(+), 2 deletions(-) diff --git a/sysdeps/i386/i686/memcpy.S b/sysdeps/i386/i686/memcpy.S index 9b48ec0ea1..b86af4aac9 100644 --- a/sysdeps/i386/i686/memcpy.S +++ b/sysdeps/i386/i686/memcpy.S @@ -27,7 +27,7 @@ #define LEN SRC+4 .text -#if defined PIC && IS_IN (libc) +#if defined SHARED && IS_IN (libc) ENTRY_CHK (__memcpy_chk) movl 12(%esp), %eax cmpl %eax, 16(%esp) diff --git a/sysdeps/i386/i686/mempcpy.S b/sysdeps/i386/i686/mempcpy.S index 26f8501e7d..14d9dd681a 100644 --- a/sysdeps/i386/i686/mempcpy.S +++ b/sysdeps/i386/i686/mempcpy.S @@ -27,7 +27,7 @@ #define LEN SRC+4 .text -#if defined PIC && IS_IN (libc) +#if defined SHARED && IS_IN (libc) ENTRY_CHK (__mempcpy_chk) movl 12(%esp), %eax cmpl %eax, 16(%esp) diff --git a/sysdeps/i386/i686/multiarch/memcpy_chk.c b/sysdeps/i386/i686/multiarch/memcpy_chk.c index ec945dc91f..c3a8aeaf18 100644 --- a/sysdeps/i386/i686/multiarch/memcpy_chk.c +++ b/sysdeps/i386/i686/multiarch/memcpy_chk.c @@ -32,4 +32,6 @@ libc_ifunc_redirected (__redirect_memcpy_chk, __memcpy_chk, __hidden_ver1 (__memcpy_chk, __GI___memcpy_chk, __redirect_memcpy_chk) __attribute__ ((visibility ("hidden"))) __attribute_copy__ (__memcpy_chk); # endif +#else +# include #endif diff --git a/sysdeps/i386/i686/multiarch/memmove_chk.c b/sysdeps/i386/i686/multiarch/memmove_chk.c index 55c7601d5d..070dde083a 100644 --- a/sysdeps/i386/i686/multiarch/memmove_chk.c +++ b/sysdeps/i386/i686/multiarch/memmove_chk.c @@ -32,4 +32,6 @@ libc_ifunc_redirected (__redirect_memmove_chk, __memmove_chk, __hidden_ver1 (__memmove_chk, __GI___memmove_chk, __redirect_memmove_chk) __attribute__ ((visibility ("hidden"))) __attribute_copy__ (__memmove_chk); # endif +#else +# include #endif diff --git a/sysdeps/i386/i686/multiarch/mempcpy_chk.c b/sysdeps/i386/i686/multiarch/mempcpy_chk.c index 83569cf9d9..14360f1828 100644 --- a/sysdeps/i386/i686/multiarch/mempcpy_chk.c +++ b/sysdeps/i386/i686/multiarch/mempcpy_chk.c @@ -32,4 +32,6 @@ libc_ifunc_redirected (__redirect_mempcpy_chk, __mempcpy_chk, __hidden_ver1 (__mempcpy_chk, __GI___mempcpy_chk, __redirect_mempcpy_chk) __attribute__ ((visibility ("hidden"))) __attribute_copy__ (__mempcpy_chk); # endif +#else +# include #endif diff --git a/sysdeps/i386/i686/multiarch/memset_chk.c b/sysdeps/i386/i686/multiarch/memset_chk.c index 1a7503858d..8179ef7c0b 100644 --- a/sysdeps/i386/i686/multiarch/memset_chk.c +++ b/sysdeps/i386/i686/multiarch/memset_chk.c @@ -32,4 +32,6 @@ libc_ifunc_redirected (__redirect_memset_chk, __memset_chk, __hidden_ver1 (__memset_chk, __GI___memset_chk, __redirect_memset_chk) __attribute__ ((visibility ("hidden"))) __attribute_copy__ (__memset_chk); # endif +#else +# include #endif