* [PATCH 0/2] More x86 build fixes @ 2023-08-08 12:27 Adhemerval Zanella 2023-08-08 12:27 ` [PATCH 1/2] x86_64: Fix build with --disable-multiarch (BZ 30721) Adhemerval Zanella 2023-08-08 12:27 ` [PATCH 2/2] i686: Fix build with --disable-multiarch Adhemerval Zanella 0 siblings, 2 replies; 6+ messages in thread From: Adhemerval Zanella @ 2023-08-08 12:27 UTC (permalink / raw) To: libc-alpha, Andreas K . Huettel The BZ#30721 [1] shows an issue with --disable-multiarch and --enable-fortify-source, where some x86 optimized routines do not properly add internal foritfy wrapper hidden definitions. I also checked some more 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. And I also tested with different architectures that also have multiarch implementation: armv7a, aarch64, i686, s390x, powerpc (power4), powerpc64le, and sparc64. The i686 also shows build failures for some configurations. Adhemerval Zanella (2): x86_64: Fix build with --disable-multiarch (BZ 30721) i686: Fix build with --disable-multiarch 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 ++ sysdeps/x86_64/memcpy.S | 2 +- sysdeps/x86_64/memmove.S | 3 +++ sysdeps/x86_64/memset.S | 1 + 9 files changed, 15 insertions(+), 3 deletions(-) -- 2.34.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] x86_64: Fix build with --disable-multiarch (BZ 30721) 2023-08-08 12:27 [PATCH 0/2] More x86 build fixes Adhemerval Zanella @ 2023-08-08 12:27 ` Adhemerval Zanella 2023-08-08 16:00 ` Andreas K. Huettel 2023-08-08 21:16 ` Siddhesh Poyarekar 2023-08-08 12:27 ` [PATCH 2/2] i686: Fix build with --disable-multiarch Adhemerval Zanella 1 sibling, 2 replies; 6+ messages in thread From: Adhemerval Zanella @ 2023-08-08 12:27 UTC (permalink / raw) To: libc-alpha, Andreas K . Huettel 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. --- 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) -- 2.34.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] x86_64: Fix build with --disable-multiarch (BZ 30721) 2023-08-08 12:27 ` [PATCH 1/2] x86_64: Fix build with --disable-multiarch (BZ 30721) Adhemerval Zanella @ 2023-08-08 16:00 ` Andreas K. Huettel 2023-08-08 21:16 ` Siddhesh Poyarekar 1 sibling, 0 replies; 6+ messages in thread From: Andreas K. Huettel @ 2023-08-08 16:00 UTC (permalink / raw) To: libc-alpha; +Cc: Adhemerval Zanella [-- Attachment #1: Type: text/plain, Size: 2170 bytes --] Am Dienstag, 8. August 2023, 14:27:54 CEST schrieb Adhemerval Zanella via 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 <dilfridge@gentoo.org> (both on master and 2.38, thanks!!!) > --- > 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) > -- Andreas K. Hüttel dilfridge@gentoo.org Gentoo Linux developer (council, toolchain, base-system, perl, libreoffice) [-- Attachment #2: This is a digitally signed message part. --] [-- Type: application/pgp-signature, Size: 981 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] x86_64: Fix build with --disable-multiarch (BZ 30721) 2023-08-08 12:27 ` [PATCH 1/2] x86_64: Fix build with --disable-multiarch (BZ 30721) Adhemerval Zanella 2023-08-08 16:00 ` Andreas K. Huettel @ 2023-08-08 21:16 ` Siddhesh Poyarekar 1 sibling, 0 replies; 6+ messages in thread From: Siddhesh Poyarekar @ 2023-08-08 21:16 UTC (permalink / raw) To: Adhemerval Zanella, libc-alpha, Andreas K . Huettel On 2023-08-08 08:27, Adhemerval Zanella via Libc-alpha wrote: > 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. > --- LGTM. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org> > 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) ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] i686: Fix build with --disable-multiarch 2023-08-08 12:27 [PATCH 0/2] More x86 build fixes Adhemerval Zanella 2023-08-08 12:27 ` [PATCH 1/2] x86_64: Fix build with --disable-multiarch (BZ 30721) Adhemerval Zanella @ 2023-08-08 12:27 ` Adhemerval Zanella 2023-08-08 21:59 ` Siddhesh Poyarekar 1 sibling, 1 reply; 6+ messages in thread From: Adhemerval Zanella @ 2023-08-08 12:27 UTC (permalink / raw) To: libc-alpha, Andreas K . Huettel 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. --- 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 <debug/memcpy_chk.c> #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 <debug/memmove_chk.c> #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 <debug/mempcpy_chk.c> #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 <debug/memset_chk.c> #endif -- 2.34.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] i686: Fix build with --disable-multiarch 2023-08-08 12:27 ` [PATCH 2/2] i686: Fix build with --disable-multiarch Adhemerval Zanella @ 2023-08-08 21:59 ` Siddhesh Poyarekar 0 siblings, 0 replies; 6+ messages in thread From: Siddhesh Poyarekar @ 2023-08-08 21:59 UTC (permalink / raw) To: Adhemerval Zanella, libc-alpha, Andreas K . Huettel On 2023-08-08 08:27, Adhemerval Zanella via Libc-alpha wrote: > 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. > --- LGTM, also tested with: ../configure CC="gcc -m32" CXX="g++ -m32" --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --prefix=/usr --enable-fortify-source --disable-default-pie Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org> > 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 <debug/memcpy_chk.c> > #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 <debug/memmove_chk.c> > #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 <debug/mempcpy_chk.c> > #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 <debug/memset_chk.c> > #endif ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-08-08 21:59 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-08-08 12:27 [PATCH 0/2] More x86 build fixes Adhemerval Zanella 2023-08-08 12:27 ` [PATCH 1/2] x86_64: Fix build with --disable-multiarch (BZ 30721) Adhemerval Zanella 2023-08-08 16:00 ` Andreas K. Huettel 2023-08-08 21:16 ` Siddhesh Poyarekar 2023-08-08 12:27 ` [PATCH 2/2] i686: Fix build with --disable-multiarch Adhemerval Zanella 2023-08-08 21:59 ` Siddhesh Poyarekar
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).