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