[3/3] Add a test to check for duplicate definitions in the static library

Message ID 20240430200506.2717717-4-gabifalk@gmx.com
State Superseded
Headers
Series i586/i686: Fix multiple definitions in libc.a |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
linaro-tcwg-bot/tcwg_glibc_build--master-arm success Testing passed
redhat-pt-bot/TryBot-32bit success Build for i686
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_glibc_check--master-arm success Testing passed
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 success Testing passed

Commit Message

Gabi Falk April 30, 2024, 8:05 p.m. UTC
  This change follows two previous fixes addressing multiple definitions
of __memcpy_chk and __mempcpy_chk functions on i586, and __memmove_chk
and __memset_chk functions on i686.  The test is intended to prevent
such issues from occurring in the future.

Signed-off-by: Gabi Falk <gabifalk@gmx.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
---
 Makefile | 7 +++++++
 1 file changed, 7 insertions(+)

--
gabi
  

Comments

H.J. Lu April 30, 2024, 8:12 p.m. UTC | #1
On Tue, Apr 30, 2024 at 1:05 PM Gabi Falk <gabifalk@gmx.com> wrote:
>
> This change follows two previous fixes addressing multiple definitions
> of __memcpy_chk and __mempcpy_chk functions on i586, and __memmove_chk
> and __memset_chk functions on i686.  The test is intended to prevent
> such issues from occurring in the future.
>
> Signed-off-by: Gabi Falk <gabifalk@gmx.com>
> Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
> ---
>  Makefile | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/Makefile b/Makefile
> index b5ef98fb04..adf4749124 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -577,6 +577,13 @@ $(objpfx)lint-makefiles.out: scripts/lint-makefiles.sh
>         $(SHELL) $< "$(PYTHON)" `pwd` > $@ ; \
>         $(evaluate-test)
>
> +# Link libc.a as a whole to verify that it does not contain multiple
> +# definitions of any symbols.
> +tests-special += $(objpfx)link-static-libc.out
> +$(objpfx)link-static-libc.out:
> +       $(LINK.o) $(whole-archive) -r $(objpfx)libc.a -o /dev/null > $@ 2>&1; \
> +       $(evaluate-test)
> +
>  # Print test summary for tests in $1 .sum file;
>  # $2 is optional test identifier.
>  # Fail if there are unexpected failures in the test results.
> --
> gabi
>

LGTM.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>

Thanks.
  

Patch

diff --git a/Makefile b/Makefile
index b5ef98fb04..adf4749124 100644
--- a/Makefile
+++ b/Makefile
@@ -577,6 +577,13 @@  $(objpfx)lint-makefiles.out: scripts/lint-makefiles.sh
 	$(SHELL) $< "$(PYTHON)" `pwd` > $@ ; \
 	$(evaluate-test)

+# Link libc.a as a whole to verify that it does not contain multiple
+# definitions of any symbols.
+tests-special += $(objpfx)link-static-libc.out
+$(objpfx)link-static-libc.out:
+	$(LINK.o) $(whole-archive) -r $(objpfx)libc.a -o /dev/null > $@ 2>&1; \
+	$(evaluate-test)
+
 # Print test summary for tests in $1 .sum file;
 # $2 is optional test identifier.
 # Fail if there are unexpected failures in the test results.