1 From abbc0761fa0349d49b10dc8c0f10af6bc0578c40 Mon Sep 17 00:00:00 2001
2 From: Mark Wielaard <mark@klomp.org>
3 Date: Tue, 12 May 2020 16:58:36 +0200
4 Subject: [PATCH 1/2] gcc10 arm64 build needs __getauxval for linking with
7 Provide a new library libgcc-sup-<platform>.a that contains symbols
8 needed by libgcc. This needs to be linked after -lgcc to provide
9 any symbols missing which would normally be provided by glibc.
10 At the moment this only provides __getauxval on arm64 linux.
12 https://bugs.kde.org/show_bug.cgi?id=421321
14 Signed-off-by: Khem Raj <raj.khem@gmail.com>
15 Upstream-Status: Backport [https://sourceware.org/git/?p=valgrind.git;a=commit;h=abbc0761fa0349d49b10dc8c0f10af6bc0578c40]
18 Makefile.tool.am | 3 +-
19 coregrind/Makefile.am | 26 +++++++++++++++++
20 coregrind/m_libgcc_sup.c | 61 ++++++++++++++++++++++++++++++++++++++++
21 3 files changed, 89 insertions(+), 1 deletion(-)
22 create mode 100644 coregrind/m_libgcc_sup.c
24 diff --git a/Makefile.tool.am b/Makefile.tool.am
25 index cc2fa0ee6..2bf90de5d 100644
26 --- a/Makefile.tool.am
27 +++ b/Makefile.tool.am
28 @@ -17,7 +17,8 @@ TOOL_DEPENDENCIES_@VGCONF_PLATFORM_SEC_CAPS@ = \
32 -TOOL_LDADD_COMMON = -lgcc
33 +TOOL_LDADD_COMMON = -lgcc \
34 + $(top_builddir)/coregrind/libgcc-sup-@VGCONF_ARCH_PRI@-@VGCONF_OS@.a
35 TOOL_LDADD_@VGCONF_PLATFORM_PRI_CAPS@ = \
36 $(TOOL_DEPENDENCIES_@VGCONF_PLATFORM_PRI_CAPS@) $(TOOL_LDADD_COMMON)
37 if VGCONF_HAVE_PLATFORM_SEC
38 diff --git a/coregrind/Makefile.am b/coregrind/Makefile.am
39 index 6a1a925fb..1753fb633 100644
40 --- a/coregrind/Makefile.am
41 +++ b/coregrind/Makefile.am
42 @@ -542,6 +542,32 @@ libcoregrind_@VGCONF_ARCH_SEC@_@VGCONF_OS@_a_DEPENDENCIES = \
43 libnolto_coregrind-@VGCONF_ARCH_SEC@-@VGCONF_OS@.a
46 +#----------------------------------------------------------------------------
47 +# libgcc-sup-<platform>.a
48 +# Special supplemental library for functions normally supplied by glibc
50 +#----------------------------------------------------------------------------
52 +pkglib_LIBRARIES += libgcc-sup-@VGCONF_ARCH_PRI@-@VGCONF_OS@.a
53 +if VGCONF_HAVE_PLATFORM_SEC
54 +pkglib_LIBRARIES += libgcc-sup-@VGCONF_ARCH_SEC@-@VGCONF_OS@.a
57 +libgcc_sup_@VGCONF_ARCH_PRI@_@VGCONF_OS@_a_SOURCES = \
59 +libgcc_sup_@VGCONF_ARCH_PRI@_@VGCONF_OS@_a_CPPFLAGS = \
60 + $(AM_CPPFLAGS_@VGCONF_PLATFORM_PRI_CAPS@)
61 +libgcc_sup_@VGCONF_ARCH_PRI@_@VGCONF_OS@_a_CFLAGS = \
62 + $(AM_CFLAGS_PSO_@VGCONF_PLATFORM_PRI_CAPS@)
63 +if VGCONF_HAVE_PLATFORM_SEC
64 +libgcc_sup_@VGCONF_ARCH_SEC@_@VGCONF_OS@_a_SOURCES = \
66 +libgcc_sup_@VGCONF_ARCH_SEC@_@VGCONF_OS@_a_CPPFLAGS = \
67 + $(AM_CPPFLAGS_@VGCONF_PLATFORM_SEC_CAPS@)
68 +libgcc_sup_@VGCONF_ARCH_SEC@_@VGCONF_OS@_a_CFLAGS = \
69 + $(AM_CFLAGS_PSO_@VGCONF_PLATFORM_SEC_CAPS@)
72 #----------------------------------------------------------------------------
73 # libreplacemalloc_toolpreload-<platform>.a
74 #----------------------------------------------------------------------------
75 diff --git a/coregrind/m_libgcc_sup.c b/coregrind/m_libgcc_sup.c
77 index 000000000..e29325459
79 +++ b/coregrind/m_libgcc_sup.c
81 +/* -*- mode: C; c-basic-offset: 3; -*- */
83 +/*--------------------------------------------------------------------*/
84 +/*--- Supplemental functions for libgcc normally provided by glibc ---*/
85 +/*--------------------------------------------------------------------*/
88 + This file is part of Valgrind, a dynamic binary instrumentation
91 + Copyright (C) 2020 Mark Wielaard
94 + This program is free software; you can redistribute it and/or
95 + modify it under the terms of the GNU General Public License as
96 + published by the Free Software Foundation; either version 2 of the
97 + License, or (at your option) any later version.
99 + This program is distributed in the hope that it will be useful, but
100 + WITHOUT ANY WARRANTY; without even the implied warranty of
101 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
102 + General Public License for more details.
104 + You should have received a copy of the GNU General Public License
105 + along with this program; if not, see <http://www.gnu.org/licenses/>.
107 + The GNU General Public License is contained in the file COPYING.
111 +#include "pub_core_basics.h"
112 +#include "pub_core_clientstate.h"
114 +/*====================================================================*/
115 +/*=== arm64 libgcc support function for init_have_lse_atomics ===*/
116 +/*====================================================================*/
118 +#if defined(VGP_arm64_linux)
129 +unsigned long int __getauxval (unsigned long int type);
130 +unsigned long int __getauxval (unsigned long int type)
133 + for (p = (struct auxv *) VG_(client_auxv);
134 + p != NULL && p->a_type != AT_NULL;
136 + if (p->a_type == type)