c6d234
commit 7a02cfade80b2b6ed2562e74105bebfee90a87ec
c6d234
Author: Mike Frysinger <vapier@gentoo.org>
c6d234
Date:   Tue Dec 24 04:31:22 2013 -0500
c6d234
c6d234
    s390: implement sotruss support
c6d234
    
c6d234
    See commit 41b1792698a335d3a85381921a84a16e9635f36a for testcase.
c6d234
    
c6d234
    Note: while this works on s390x, the s390 code hangs when using -e.
c6d234
    But it hangs regardless of this code (the hang seems to occur before
c6d234
    the exit func is even called).  I didn't look too closely at it as
c6d234
    it seems to be an issue external to this file, so this code shouldn't
c6d234
    make the situation any worse.
c6d234
    
c6d234
    Reviewed-by: Carlos O'Donell <carlos@redhat.com>
c6d234
    Signed-off-by: Mike Frysinger <vapier@gentoo.org>
c6d234
c6d234
diff --git a/sysdeps/s390/sotruss-lib.c b/sysdeps/s390/sotruss-lib.c
c6d234
new file mode 100644
c6d234
index 0000000000000000..ded98db08dcf525b
c6d234
--- /dev/null
c6d234
+++ b/sysdeps/s390/sotruss-lib.c
c6d234
@@ -0,0 +1,62 @@
c6d234
+/* Override generic sotruss-lib.c to define actual functions for s390.
c6d234
+   Copyright (C) 2012-2014 Free Software Foundation, Inc.
c6d234
+
c6d234
+   This file is part of the GNU C Library.
c6d234
+
c6d234
+   The GNU C Library is free software; you can redistribute it and/or
c6d234
+   modify it under the terms of the GNU Lesser General Public
c6d234
+   License as published by the Free Software Foundation; either
c6d234
+   version 2.1 of the License, or (at your option) any later version.
c6d234
+
c6d234
+   The GNU C Library is distributed in the hope that it will be useful,
c6d234
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
c6d234
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
c6d234
+   Lesser General Public License for more details.
c6d234
+
c6d234
+   You should have received a copy of the GNU Lesser General Public
c6d234
+   License along with the GNU C Library.  If not, see
c6d234
+   <http://www.gnu.org/licenses/>.  */
c6d234
+
c6d234
+#define HAVE_ARCH_PLTENTER
c6d234
+#define HAVE_ARCH_PLTEXIT
c6d234
+
c6d234
+#include <elf/sotruss-lib.c>
c6d234
+
c6d234
+#if __ELF_NATIVE_CLASS == 32
c6d234
+# define la_s390_gnu_pltenter	la_s390_32_gnu_pltenter
c6d234
+# define la_s390_gnu_pltexit	la_s390_32_gnu_pltexit
c6d234
+# define La_s390_regs		La_s390_32_regs
c6d234
+# define La_s390_retval		La_s390_32_retval
c6d234
+#else
c6d234
+# define la_s390_gnu_pltenter	la_s390_64_gnu_pltenter
c6d234
+# define la_s390_gnu_pltexit	la_s390_64_gnu_pltexit
c6d234
+# define La_s390_regs		La_s390_64_regs
c6d234
+# define La_s390_retval		La_s390_64_retval
c6d234
+#endif
c6d234
+
c6d234
+ElfW(Addr)
c6d234
+la_s390_gnu_pltenter (ElfW(Sym) *sym,
c6d234
+		      unsigned int ndx __attribute__ ((unused)),
c6d234
+		      uintptr_t *refcook, uintptr_t *defcook,
c6d234
+		      La_s390_regs *regs, unsigned int *flags,
c6d234
+		      const char *symname, long int *framesizep)
c6d234
+{
c6d234
+  print_enter (refcook, defcook, symname,
c6d234
+	       regs->lr_r2, regs->lr_r3, regs->lr_r4, *flags);
c6d234
+
c6d234
+  /* No need to copy anything, we will not need the parameters in any case.  */
c6d234
+  *framesizep = 0;
c6d234
+
c6d234
+  return sym->st_value;
c6d234
+}
c6d234
+
c6d234
+unsigned int
c6d234
+la_s390_gnu_pltexit (ElfW(Sym) *sym, unsigned int ndx, uintptr_t *refcook,
c6d234
+		     uintptr_t *defcook,
c6d234
+		     const struct La_s390_regs *inregs,
c6d234
+		     struct La_s390_retval *outregs, const char *symname)
c6d234
+{
c6d234
+  print_exit (refcook, defcook, symname, outregs->lrv_r2);
c6d234
+
c6d234
+  return 0;
c6d234
+}