]> code.ossystems Code Review - openembedded-core.git/blob
9afa7f6a55c663f9976f53686aac2a8fcabe2b27
[openembedded-core.git] /
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
5  libgcc
6
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.
11
12 https://bugs.kde.org/show_bug.cgi?id=421321
13
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]
16
17 ---
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
23
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@ = \
29  endif
30  
31  
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
44  endif
45  
46 +#----------------------------------------------------------------------------
47 +# libgcc-sup-<platform>.a
48 +# Special supplemental library for functions normally supplied by glibc
49 +# used by libgcc.
50 +#----------------------------------------------------------------------------
51 +
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
55 +endif
56 +
57 +libgcc_sup_@VGCONF_ARCH_PRI@_@VGCONF_OS@_a_SOURCES = \
58 +       m_libgcc_sup.c
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 = \
65 +       m_libgcc_sup.c
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@)
70 +endif
71 +
72  #----------------------------------------------------------------------------
73  # libreplacemalloc_toolpreload-<platform>.a
74  #----------------------------------------------------------------------------
75 diff --git a/coregrind/m_libgcc_sup.c b/coregrind/m_libgcc_sup.c
76 new file mode 100644
77 index 000000000..e29325459
78 --- /dev/null
79 +++ b/coregrind/m_libgcc_sup.c
80 @@ -0,0 +1,61 @@
81 +/* -*- mode: C; c-basic-offset: 3; -*- */
82 +
83 +/*--------------------------------------------------------------------*/
84 +/*--- Supplemental functions for libgcc normally provided by glibc ---*/
85 +/*--------------------------------------------------------------------*/
86 +
87 +/*
88 +   This file is part of Valgrind, a dynamic binary instrumentation
89 +   framework.
90 +
91 +   Copyright (C) 2020 Mark Wielaard
92 +      mark@klomp.org
93 +
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.
98 +
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.
103 +
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/>.
106 +
107 +   The GNU General Public License is contained in the file COPYING.
108 +*/
109 +
110 +#include "config.h"
111 +#include "pub_core_basics.h"
112 +#include "pub_core_clientstate.h"
113 +
114 +/*====================================================================*/
115 +/*=== arm64 libgcc support function for init_have_lse_atomics      ===*/
116 +/*====================================================================*/
117 +
118 +#if defined(VGP_arm64_linux)
119 +struct auxv
120 +{
121 +   Word a_type;
122 +   union {
123 +      void *a_ptr;
124 +      Word a_val;
125 +   } u;
126 +};
127 +#define AT_NULL 0
128 +
129 +unsigned long int __getauxval (unsigned long int type);
130 +unsigned long int __getauxval (unsigned long int type)
131 +{
132 +   struct auxv *p;
133 +   for (p = (struct auxv *) VG_(client_auxv);
134 +        p != NULL && p->a_type != AT_NULL;
135 +        p++)
136 +      if (p->a_type == type)
137 +         return p->u.a_val;
138 +
139 +   return 0;
140 +}
141 +#endif
142 -- 
143 2.26.2
144