* [PATCH v1] x86: Fix `#define STRCPY` guard in strcpy-sse2.S @ 2022-08-08 3:26 Noah Goldstein 2022-08-08 3:26 ` [PATCH v1] elf: Replace `strcpy` call with `memcpy` [BZ #29454] Noah Goldstein 2022-08-08 14:21 ` [PATCH v1] x86: Fix `#define STRCPY` guard in strcpy-sse2.S H.J. Lu 0 siblings, 2 replies; 6+ messages in thread From: Noah Goldstein @ 2022-08-08 3:26 UTC (permalink / raw) To: libc-alpha `#ifndef STPCPY` is incorrect for checking if `STRCPY` is already defined. It doesn't end up mattering as the whole check is guarded by `#if IS_IN (libc)` but is incorrect none the less. --- sysdeps/x86_64/multiarch/strcpy-sse2.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysdeps/x86_64/multiarch/strcpy-sse2.S b/sysdeps/x86_64/multiarch/strcpy-sse2.S index e29b411314..d6b9bae5f8 100644 --- a/sysdeps/x86_64/multiarch/strcpy-sse2.S +++ b/sysdeps/x86_64/multiarch/strcpy-sse2.S @@ -22,7 +22,7 @@ # include <sysdep.h> -# ifndef STPCPY +# ifndef STRCPY # define STRCPY __strcpy_sse2 # endif -- 2.34.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v1] elf: Replace `strcpy` call with `memcpy` [BZ #29454] 2022-08-08 3:26 [PATCH v1] x86: Fix `#define STRCPY` guard in strcpy-sse2.S Noah Goldstein @ 2022-08-08 3:26 ` Noah Goldstein 2022-08-08 10:19 ` Yann Droneaud 2022-08-08 14:23 ` H.J. Lu 2022-08-08 14:21 ` [PATCH v1] x86: Fix `#define STRCPY` guard in strcpy-sse2.S H.J. Lu 1 sibling, 2 replies; 6+ messages in thread From: Noah Goldstein @ 2022-08-08 3:26 UTC (permalink / raw) To: libc-alpha 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. --- 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); } -- 2.34.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1] elf: Replace `strcpy` call with `memcpy` [BZ #29454] 2022-08-08 3:26 ` [PATCH v1] elf: Replace `strcpy` call with `memcpy` [BZ #29454] Noah Goldstein @ 2022-08-08 10:19 ` Yann Droneaud 2022-08-08 14:23 ` H.J. Lu 1 sibling, 0 replies; 6+ messages in thread From: Yann Droneaud @ 2022-08-08 10:19 UTC (permalink / raw) To: Noah Goldstein, libc-alpha 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 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1] elf: Replace `strcpy` call with `memcpy` [BZ #29454] 2022-08-08 3:26 ` [PATCH v1] elf: Replace `strcpy` call with `memcpy` [BZ #29454] Noah Goldstein 2022-08-08 10:19 ` Yann Droneaud @ 2022-08-08 14:23 ` H.J. Lu 2022-08-10 3:29 ` Noah Goldstein 1 sibling, 1 reply; 6+ messages in thread From: H.J. Lu @ 2022-08-08 14:23 UTC (permalink / raw) To: Noah Goldstein; +Cc: GNU C Library, Carlos O'Donell On Sun, Aug 7, 2022 at 8:26 PM Noah Goldstein <goldstein.w.n@gmail.com> wrote: > > 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. > --- > 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); > } > > -- > 2.34.1 > LGTM. Thanks. -- H.J. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1] elf: Replace `strcpy` call with `memcpy` [BZ #29454] 2022-08-08 14:23 ` H.J. Lu @ 2022-08-10 3:29 ` Noah Goldstein 0 siblings, 0 replies; 6+ messages in thread From: Noah Goldstein @ 2022-08-10 3:29 UTC (permalink / raw) To: H.J. Lu; +Cc: GNU C Library, Carlos O'Donell On Mon, Aug 8, 2022 at 10:24 PM H.J. Lu <hjl.tools@gmail.com> wrote: > > On Sun, Aug 7, 2022 at 8:26 PM Noah Goldstein <goldstein.w.n@gmail.com> wrote: > > > > 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. > > --- > > 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); > > } > > > > -- > > 2.34.1 > > > > LGTM. > > Thanks. > > -- > H.J. Any objections to backporting this to 2.36? ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1] x86: Fix `#define STRCPY` guard in strcpy-sse2.S 2022-08-08 3:26 [PATCH v1] x86: Fix `#define STRCPY` guard in strcpy-sse2.S Noah Goldstein 2022-08-08 3:26 ` [PATCH v1] elf: Replace `strcpy` call with `memcpy` [BZ #29454] Noah Goldstein @ 2022-08-08 14:21 ` H.J. Lu 1 sibling, 0 replies; 6+ messages in thread From: H.J. Lu @ 2022-08-08 14:21 UTC (permalink / raw) To: Noah Goldstein; +Cc: GNU C Library, Carlos O'Donell On Sun, Aug 7, 2022 at 8:26 PM Noah Goldstein <goldstein.w.n@gmail.com> wrote: > > `#ifndef STPCPY` is incorrect for checking if `STRCPY` is already > defined. It doesn't end up mattering as the whole check is > guarded by `#if IS_IN (libc)` but is incorrect none the less. > --- > sysdeps/x86_64/multiarch/strcpy-sse2.S | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/sysdeps/x86_64/multiarch/strcpy-sse2.S b/sysdeps/x86_64/multiarch/strcpy-sse2.S > index e29b411314..d6b9bae5f8 100644 > --- a/sysdeps/x86_64/multiarch/strcpy-sse2.S > +++ b/sysdeps/x86_64/multiarch/strcpy-sse2.S > @@ -22,7 +22,7 @@ > > # include <sysdep.h> > > -# ifndef STPCPY > +# ifndef STRCPY > # define STRCPY __strcpy_sse2 > # endif > > -- > 2.34.1 > LGTM. Thanks. -- H.J. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-08-10 3:30 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-08-08 3:26 [PATCH v1] x86: Fix `#define STRCPY` guard in strcpy-sse2.S Noah Goldstein 2022-08-08 3:26 ` [PATCH v1] elf: Replace `strcpy` call with `memcpy` [BZ #29454] Noah Goldstein 2022-08-08 10:19 ` Yann Droneaud 2022-08-08 14:23 ` H.J. Lu 2022-08-10 3:29 ` Noah Goldstein 2022-08-08 14:21 ` [PATCH v1] x86: Fix `#define STRCPY` guard in strcpy-sse2.S H.J. Lu
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).