From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 706743858408 for ; Wed, 26 Jul 2023 01:51:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 706743858408 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690336295; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=p907XExfwOt7xQ0wGxSpZyInGuHm0WMNSSPY5+tI2ZQ=; b=JSO/eJMZQiInPt3BOsBwgx0RxxdqgOnmg55cwj38y/9K62hoXVX4ORVDl0TaFm56AHTbm8 V4l29FmAC0vKH678zZD2AUUWpb8usNw6MErsLx6YA7ClaRa/iaZ/FkBtoK1N3I0PKPIXjE EcHEmY1FJCWmqILoEvXumio23/V8F6c= Received: from mail-yw1-f199.google.com (mail-yw1-f199.google.com [209.85.128.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-112-9En0eTZUM7KInk4LSbH25g-1; Tue, 25 Jul 2023 21:51:34 -0400 X-MC-Unique: 9En0eTZUM7KInk4LSbH25g-1 Received: by mail-yw1-f199.google.com with SMTP id 00721157ae682-583c49018c6so48977437b3.0 for ; Tue, 25 Jul 2023 18:51:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690336293; x=1690941093; h=content-transfer-encoding:in-reply-to:organization:from:references :to:content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=p907XExfwOt7xQ0wGxSpZyInGuHm0WMNSSPY5+tI2ZQ=; b=GIcV7IDM0862EkBL6Qf3h3memHXV+Ll4VOi8DyAfy2oU06EMgDzgMzoW4Vz4+8wZaX 4s49AhaI6lREhhP8YvvPTZ4ERqS6XSRwTGgXqCoEas6RYke4JpQDCZd6Eh4jFRxLE7ZC kMfPENVSTbXyg0RkGxwCpBxtbgZW+xkNfgstVcTImF1bbqHPOzK+xr8ca3I+yXSJYI2N kdRBv18Hph8D6TowiezsTe2lOpivZo/ndK0tcpvMzL7ORqd1ocBnRjnWpNbhoZy+7LZQ NbjMHLI/tMH69CS6fbIYQb0EK95bOW/UsPdJzrzZG1nqOy5RGj7kbNt5DDcOje59erW5 dNNQ== X-Gm-Message-State: ABy/qLZ666NAor87JlPrNFL63rNp0X07krbCAU7VG/HG2DI4Ii42bWtB TqKGv8z93kqQjb5pXReUz6u+8GKMfACSXQBu3Ao2EmKePgngsdql3hFr2p/Sw87Uiwd1j1ImzRg pJ6Ys0HtI1Eroza1c0qu8kkDPsyAb X-Received: by 2002:a0d:cf83:0:b0:577:228f:467f with SMTP id r125-20020a0dcf83000000b00577228f467fmr758095ywd.36.1690336293311; Tue, 25 Jul 2023 18:51:33 -0700 (PDT) X-Google-Smtp-Source: APBJJlF8L7xQMsZ1JuIXECDCseYpcn4YS8cZB/LCr++FPAl1SNE/xstjnAe2lASqiUw55NRBJaSpXQ== X-Received: by 2002:a0d:cf83:0:b0:577:228f:467f with SMTP id r125-20020a0dcf83000000b00577228f467fmr758088ywd.36.1690336292983; Tue, 25 Jul 2023 18:51:32 -0700 (PDT) Received: from [192.168.0.241] ([198.48.244.52]) by smtp.gmail.com with ESMTPSA id i132-20020a81548a000000b005771872a8dbsm3915173ywb.132.2023.07.25.18.51.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 25 Jul 2023 18:51:32 -0700 (PDT) Message-ID: <37bebaa2-1d96-62e8-4fef-45a93e202d3f@redhat.com> Date: Tue, 25 Jul 2023 21:51:31 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH 1/4] i386: Fix build with --enable-fortify=3 To: Adhemerval Zanella , libc-alpha@sourceware.org, Frederic Berat , "Andreas K. Huettel" References: <20230725151641.923083-1-adhemerval.zanella@linaro.org> <20230725151641.923083-2-adhemerval.zanella@linaro.org> From: Carlos O'Donell Organization: Red Hat In-Reply-To: <20230725151641.923083-2-adhemerval.zanella@linaro.org> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_NUMSUBJECT,KAM_SHORT,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 7/25/23 11:16, Adhemerval Zanella via Libc-alpha wrote: > The i386 string routines provide multiple internal definitions > for memcpy, memmove, and mempcpy chk routines: > > $ objdump -t libc.a | grep __memcpy_chk > 00000000 g F .text 0000000e __memcpy_chk > 00000000 g F .text 00000013 __memcpy_chk > $ objdump -t libc.a | grep __mempcpy_chk > 00000000 g F .text 0000000e __mempcpy_chk > 00000000 g F .text 00000013 __mempcpy_chk > $ objdump -t libc.a | grep __memmove_chk > 00000000 g F .text 0000000e __memmove_chk > 00000000 g F .text 00000013 __memmove_chk > > Although is not an issue for normal static builds, with fortify=3 > glibc itself might use the fortify chk functions and thus static > build might fail with multiple definitions. For instance: > > x86_64-glibc-linux-gnu-gcc -m32 -march=i686 -o [...]math/test-signgam-uchar-static -nostdlib -nostartfiles -static -static-pie [...] > x86_64-glibc-linux-gnu/bin/ld: [...]/libc.a(mempcpy-ia32.o): > in function `__mempcpy_chk': [...]/glibc-git/string/../sysdeps/i386/i686/mempcpy.S:32: multiple definition of `__mempcpy_chk'; > [...]/libc.a(mempcpy_chk-nonshared.o):[...]/debug/../sysdeps/i386/mempcpy_chk.S:28: first defined here > collect2: error: ld returned 1 exit status > make[2]: *** [../Rules:298: > > There is no need for mem*-nonshared.S, the __mem*_chk routines > are already provided by the assembly routines. > > Checked on i686-linux-gnu with gcc 13 built with fortify=1,2,3 and > without fortify. I agree this is probably the best fix for glibc 2.38. I think we should commit this for 2.38 and I'll re-test with i686. Andreas, As the RM is this OK to push? Reviewed-by: Carlos O'Donell > --- > sysdeps/i386/i686/multiarch/Makefile | 3 +-- > .../i686/multiarch/memcpy_chk-nonshared.S | 21 ------------------- > .../i686/multiarch/memmove_chk-nonshared.S | 21 ------------------- > .../i686/multiarch/mempcpy_chk-nonshared.S | 21 ------------------- > 4 files changed, 1 insertion(+), 65 deletions(-) > delete mode 100644 sysdeps/i386/i686/multiarch/memcpy_chk-nonshared.S > delete mode 100644 sysdeps/i386/i686/multiarch/memmove_chk-nonshared.S > delete mode 100644 sysdeps/i386/i686/multiarch/mempcpy_chk-nonshared.S > > diff --git a/sysdeps/i386/i686/multiarch/Makefile b/sysdeps/i386/i686/multiarch/Makefile > index 9fe5ea8639..f48b06741f 100644 > --- a/sysdeps/i386/i686/multiarch/Makefile > +++ b/sysdeps/i386/i686/multiarch/Makefile > @@ -46,6 +46,5 @@ CFLAGS-s_fmaf-fma.c += -mavx -mfpmath=sse > endif > > ifeq ($(subdir),debug) > -sysdep_routines += memcpy_chk-nonshared mempcpy_chk-nonshared \ > - memmove_chk-nonshared memset_chk-nonshared > +sysdep_routines += memset_chk-nonshared > endif > diff --git a/sysdeps/i386/i686/multiarch/memcpy_chk-nonshared.S b/sysdeps/i386/i686/multiarch/memcpy_chk-nonshared.S > deleted file mode 100644 > index 6801893b72..0000000000 > --- a/sysdeps/i386/i686/multiarch/memcpy_chk-nonshared.S > +++ /dev/null > @@ -1,21 +0,0 @@ > -/* Non-shared version of memcpy_chk for i686. > - Copyright (C) 2017-2023 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 > - . */ > - > -#if IS_IN (libc) && !defined SHARED > -# include > -#endif > diff --git a/sysdeps/i386/i686/multiarch/memmove_chk-nonshared.S b/sysdeps/i386/i686/multiarch/memmove_chk-nonshared.S > deleted file mode 100644 > index c5de28d4a8..0000000000 > --- a/sysdeps/i386/i686/multiarch/memmove_chk-nonshared.S > +++ /dev/null > @@ -1,21 +0,0 @@ > -/* Non-shared version of memmmove_chk for i686. > - Copyright (C) 2017-2023 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 > - . */ > - > -#if IS_IN (libc) && !defined SHARED > -# include > -#endif > diff --git a/sysdeps/i386/i686/multiarch/mempcpy_chk-nonshared.S b/sysdeps/i386/i686/multiarch/mempcpy_chk-nonshared.S > deleted file mode 100644 > index c4f89e156b..0000000000 > --- a/sysdeps/i386/i686/multiarch/mempcpy_chk-nonshared.S > +++ /dev/null > @@ -1,21 +0,0 @@ > -/* Non-shared version of mempcpy_chk for i686. > - Copyright (C) 2017-2023 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 > - . */ > - > -#if IS_IN (libc) && !defined SHARED > -# include > -#endif -- Cheers, Carlos.