From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp1-g21.free.fr (smtp1-g21.free.fr [212.27.42.1]) by sourceware.org (Postfix) with ESMTPS id 865C13858281 for ; Mon, 8 Aug 2022 10:19:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 865C13858281 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=opteya.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=opteya.com Received: from [IPV6:2a01:e35:39f2:1220:c5f7:a326:d9a9:f579] (unknown [IPv6:2a01:e35:39f2:1220:c5f7:a326:d9a9:f579]) by smtp1-g21.free.fr (Postfix) with ESMTPS id 965D0B0072E; Mon, 8 Aug 2022 12:19:43 +0200 (CEST) Message-ID: <23ddde33-44ce-4421-64d6-d119bddef8ff@opteya.com> Date: Mon, 8 Aug 2022 12:19:43 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 From: Yann Droneaud Subject: Re: [PATCH v1] elf: Replace `strcpy` call with `memcpy` [BZ #29454] To: Noah Goldstein , libc-alpha@sourceware.org References: <20220808032622.3804534-1-goldstein.w.n@gmail.com> <20220808032622.3804534-2-goldstein.w.n@gmail.com> Content-Language: fr-FR Organization: OPTEYA In-Reply-To: <20220808032622.3804534-2-goldstein.w.n@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, 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 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: Mon, 08 Aug 2022 10:19:48 -0000 Hi, Le 08/08/2022 à 05:26, Noah Goldstein via Libc-alpha a écrit : > GCC normally does this optimization for us in > strlen_pass::handle_builtin_strcpy but only for optimized > build. To avoid needing to include strcpy.S in the rtld build to > support the debug build, just do the optimization by hand. It does fixes this build issue I had when using -Og (using gcc 11.2, on amd64):     gcc   -nostdlib -nostartfiles -shared -o .../build/elf/ld.so.new        \           -Wl,-z,relro -Wl,-z,defs     \           -Wl,-z,pack-relative-relocs \           .../build/elf/librtld.os -Wl,--version-script=.../build/ld.map        \           -Wl,-soname=ld-linux-x86-64.so.2     /usr/bin/ld: .../build/elf/librtld.os: in function `_dl_load_cache_lookup':     .../elf/dl-cache.c:513: undefined reference to `strcpy'   collect2: error: ld returned 1 exit status     make[2]: *** [Makefile:1347: .../build/elf/ld.so] Error 1     make[2]: Leaving directory '.../elf'     make[1]: *** [Makefile:484: elf/subdir_lib] Error 2     make[1]: Leaving directory '...'     make: *** [Makefile:9: all] Error 2 Thanks. > --- > elf/dl-cache.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/elf/dl-cache.c b/elf/dl-cache.c > index 8bbf110d02..b97c17b3a9 100644 > --- a/elf/dl-cache.c > +++ b/elf/dl-cache.c > @@ -509,8 +509,9 @@ _dl_load_cache_lookup (const char *name) > we are accessing. Therefore we must make the copy of the > mapping data without using malloc. */ > char *temp; > - temp = alloca (strlen (best) + 1); > - strcpy (temp, best); > + size_t best_len = strlen (best) + 1; > + temp = alloca (best_len); > + memcpy (temp, best, best_len); > return __strdup (temp); > } > Regards. -- Yann Droneaud OPTEYA