5de29b
Backport of commit f8b4877a75765b14432a6f83ead11dcecc5b1985
5de29b
Author: Marcus Shawcroft <marcus.shawcroft@linaro.org>
5de29b
Date:   Fri Jul 26 08:29:17 2013 +0100
5de29b
5de29b
    [AArch64] Provide symbol version for _mcount.
5de29b
5de29b
2013-07-26  Marcus Shawcroft  <marcus.shawcroft@linaro.org>
5de29b
5de29b
       * sysdeps/aarch64/Versions: New file.
5de29b
       * sysdeps/aarch64/machine-gmon.h: New file.
5de29b
       * sysdeps/aarch64/mcount.c: New file.
5de29b
       * sysdeps/unix/sysv/linux/aarch64/nptl/libc.abilist (_mcount): Add.
5de29b
5de29b
5de29b
12745e
diff -ruNp glibc-2.17-c758a686/ports/sysdeps/aarch64/machine-gmon.h glibc-2.17-c758a686/ports/sysdeps/aarch64/machine-gmon.h
12745e
--- glibc-2.17-c758a686/ports/sysdeps/aarch64/machine-gmon.h	2012-12-24 22:02:13.000000000 -0500
12745e
+++ glibc-2.17-c758a686/ports/sysdeps/aarch64/machine-gmon.h	2014-03-27 12:06:51.361046886 -0400
5de29b
@@ -1,5 +1,5 @@
5de29b
-/* Copyright (C) 2011-2012 Free Software Foundation, Inc.
5de29b
-
5de29b
+/* AArch64 definitions for profiling support.
5de29b
+   Copyright (C) 1996-2014 Free Software Foundation, Inc.
5de29b
    This file is part of the GNU C Library.
5de29b
 
5de29b
    The GNU C Library is free software; you can redistribute it and/or
5de29b
@@ -13,13 +13,22 @@
5de29b
    Lesser General Public License for more details.
5de29b
 
5de29b
    You should have received a copy of the GNU Lesser General Public
5de29b
-   License along with the GNU C Library.  If not, see
5de29b
+   License along with the GNU C Library; if not, see
5de29b
    <http://www.gnu.org/licenses/>.  */
5de29b
 
5de29b
-#define _MCOUNT_DECL(from, self) \
5de29b
- void __mcount_internal (u_long from, u_long self)
5de29b
-
5de29b
-/* Call __mcount_internal with our the return PC for our caller, and
5de29b
-   the return PC our caller will return to.  Empty since we use an
5de29b
-   assembly stub instead. */
5de29b
-#define MCOUNT
5de29b
+/* Accept 'frompc' address as argument from the function that calls
5de29b
+   __mcount for profiling.  Use  __builtin_return_address (0)
5de29b
+   for the 'selfpc' address.  */
5de29b
+
5de29b
+#include <sysdep.h>
5de29b
+
5de29b
+static void mcount_internal (u_long frompc, u_long selfpc);
5de29b
+
5de29b
+#define _MCOUNT_DECL(frompc, selfpc) \
5de29b
+static inline void mcount_internal (u_long frompc, u_long selfpc)
5de29b
+
5de29b
+#define MCOUNT                                                    \
5de29b
+void __mcount (void *frompc)                                      \
5de29b
+{                                                                 \
5de29b
+  mcount_internal ((u_long) frompc, (u_long) RETURN_ADDRESS (0)); \
5de29b
+}
12745e
diff -ruNp glibc-2.17-c758a686/ports/sysdeps/aarch64/mcount.c glibc-2.17-c758a686/ports/sysdeps/aarch64/mcount.c
12745e
--- glibc-2.17-c758a686/ports/sysdeps/aarch64/mcount.c	1969-12-31 19:00:00.000000000 -0500
12745e
+++ glibc-2.17-c758a686/ports/sysdeps/aarch64/mcount.c	2014-03-27 11:54:54.435418262 -0400
5de29b
@@ -0,0 +1,33 @@
5de29b
+/* Copyright (C) 2013 Free Software Foundation, Inc.
5de29b
+
5de29b
+   This file is part of the GNU C Library.
5de29b
+
5de29b
+   The GNU C Library is free software; you can redistribute it and/or
5de29b
+   modify it under the terms of the GNU Lesser General Public
5de29b
+   License as published by the Free Software Foundation; either
5de29b
+   version 2.1 of the License, or (at your option) any later version.
5de29b
+
5de29b
+   The GNU C Library is distributed in the hope that it will be useful,
5de29b
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
5de29b
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
5de29b
+   Lesser General Public License for more details.
5de29b
+
5de29b
+   You should have received a copy of the GNU Lesser General Public
5de29b
+   License along with the GNU C Library.  If not, see
5de29b
+   <http://www.gnu.org/licenses/>.  */
5de29b
+
5de29b
+#include <shlib-compat.h>
5de29b
+
5de29b
+#include <gmon/mcount.c>
5de29b
+
5de29b
+/* We forgot to add _mcount in glibc 2.17.  We added it in 2.18
5de29b
+   therefore we want it to be added with version GLIBC_2_18.  However,
5de29b
+   setting the version is not straight forward because a generic
5de29b
+   Version file includes an earlier 2.xx version for each this symbol
5de29b
+   and the linker uses the first version it sees.  */
5de29b
+
5de29b
+#if SHLIB_COMPAT (libc, GLIBC_2_17, GLIBC_2_18)
5de29b
+versioned_symbol (libc, __mcount, _mcount, GLIBC_2_18);
5de29b
+#else
5de29b
+strong_alias (__mcount, _mcount);
5de29b
+#endif
12745e
diff -ruNp glibc-2.17-c758a686/ports/sysdeps/aarch64/Versions glibc-2.17-c758a686/ports/sysdeps/aarch64/Versions
12745e
--- glibc-2.17-c758a686/ports/sysdeps/aarch64/Versions	1969-12-31 19:00:00.000000000 -0500
12745e
+++ glibc-2.17-c758a686/ports/sysdeps/aarch64/Versions	2014-03-27 11:54:54.435418262 -0400
5de29b
@@ -0,0 +1,5 @@
5de29b
+libc {
5de29b
+  GLIBC_2.18 {
5de29b
+    _mcount;
5de29b
+  }
5de29b
+}
12745e
diff -ruNp glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/aarch64/nptl/libc.abilist glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/aarch64/nptl/libc.abilist
12745e
--- glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/aarch64/nptl/libc.abilist	2012-12-24 22:02:13.000000000 -0500
12745e
+++ glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/aarch64/nptl/libc.abilist	2014-03-27 11:54:54.495412015 -0400
5de29b
@@ -2077,3 +2077,6 @@ GLIBC_2.17
5de29b
  xencrypt F
5de29b
  xprt_register F
5de29b
  xprt_unregister F
5de29b
+GLIBC_2.18
5de29b
+ GLIBC_2.18 A
5de29b
+ _mcount F
12745e
diff -ruNp glibc-2.17-c758a686/Versions.def glibc-2.17-c758a686/Versions.def
12745e
--- glibc-2.17-c758a686/Versions.def	2012-12-24 22:02:13.000000000 -0500
12745e
+++ glibc-2.17-c758a686/Versions.def	2014-03-27 11:54:54.535407851 -0400
5de29b
@@ -34,6 +34,7 @@ libc {
5de29b
   GLIBC_2.15
5de29b
   GLIBC_2.16
5de29b
   GLIBC_2.17
5de29b
+  GLIBC_2.18
5de29b
   HURD_CTHREADS_0.3
5de29b
 %ifdef EXPORT_UNWIND_FIND_FDE
5de29b
   GCC_3.0