1 /* PowerPC specific sotruss-lib functions.
2    Copyright (C) 2013-2022 Free Software Foundation, Inc.
3 
4    This file is part of the GNU C Library.
5 
6    The GNU C Library is free software; you can redistribute it and/or
7    modify it under the terms of the GNU Lesser General Public
8    License as published by the Free Software Foundation; either
9    version 2.1 of the License, or (at your option) any later version.
10 
11    The GNU C Library is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14    Lesser General Public License for more details.
15 
16    You should have received a copy of the GNU Lesser General Public
17    License along with the GNU C Library.  If not, see
18    <https://www.gnu.org/licenses/>.  */
19 
20 #define HAVE_ARCH_PLTENTER
21 #define HAVE_ARCH_PLTEXIT
22 
23 #include <elf/sotruss-lib.c>
24 
25 #ifdef __powerpc64__
26 # if _CALL_ELF != 2
27 #  define LA_PPC_REGS          La_ppc64_regs
28 #  define LA_PPC_RETVAL        La_ppc64_retval
29 #  define LA_PPC_GNU_PLTENTER  la_ppc64_gnu_pltenter
30 #  define LA_PPC_GNU_PLTEXIT   la_ppc64_gnu_pltexit
31 # else
32 #  define LA_PPC_REGS          La_ppc64v2_regs
33 #  define LA_PPC_RETVAL        La_ppc64v2_retval
34 #  define LA_PPC_GNU_PLTENTER  la_ppc64v2_gnu_pltenter
35 #  define LA_PPC_GNU_PLTEXIT   la_ppc64v2_gnu_pltexit
36 # endif
37 # else
38 # define LA_PPC_REGS           La_ppc32_regs
39 # define LA_PPC_RETVAL         La_ppc32_retval
40 # define LA_PPC_GNU_PLTENTER   la_ppc32_gnu_pltenter
41 # define LA_PPC_GNU_PLTEXIT    la_ppc32_gnu_pltexit
42 #endif
43 
44 ElfW(Addr)
LA_PPC_GNU_PLTENTER(ElfW (Sym)* sym,unsigned int ndx,uintptr_t * refcook,uintptr_t * defcook,LA_PPC_REGS * regs,unsigned int * flags,const char * symname,long int * framesizep)45 LA_PPC_GNU_PLTENTER (ElfW(Sym) *sym __attribute__ ((unused)),
46 		     unsigned int ndx __attribute__ ((unused)),
47 		     uintptr_t *refcook, uintptr_t *defcook,
48 		     LA_PPC_REGS *regs, unsigned int *flags,
49 		     const char *symname, long int *framesizep)
50 {
51   print_enter (refcook, defcook, symname,
52 	       regs->lr_reg[0], regs->lr_reg[1], regs->lr_reg[2], *flags);
53 
54   /* No need to copy anything, we will not need the parameters in any case.  */
55   *framesizep = 0;
56 
57   return sym->st_value;
58 }
59 
60 unsigned int
LA_PPC_GNU_PLTEXIT(ElfW (Sym)* sym,unsigned int ndx,uintptr_t * refcook,uintptr_t * defcook,const struct LA_PPC_REGS * inregs,struct LA_PPC_RETVAL * outregs,const char * symname)61 LA_PPC_GNU_PLTEXIT (ElfW(Sym) *sym, unsigned int ndx, uintptr_t *refcook,
62 		    uintptr_t *defcook,
63 		    const struct LA_PPC_REGS *inregs,
64 		    struct LA_PPC_RETVAL *outregs, const char *symname)
65 {
66   print_exit (refcook, defcook, symname, outregs->lrv_r3);
67 
68   return 0;
69 }
70