1 /* Override generic sotruss-lib.c to define actual functions for MIPS.
2 Copyright (C) 2012-2022 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <https://www.gnu.org/licenses/>. */
18
19 #define HAVE_ARCH_PLTENTER
20 #define HAVE_ARCH_PLTEXIT
21
22 #include <elf/sotruss-lib.c>
23
24 #if _MIPS_SIM == _ABIO32
25
26 ElfW(Addr)
la_mips_o32_gnu_pltenter(ElfW (Sym)* sym,unsigned int ndx,uintptr_t * refcook,uintptr_t * defcook,La_mips_32_regs * regs,unsigned int * flags,const char * symname,long int * framesizep)27 la_mips_o32_gnu_pltenter (ElfW(Sym) *sym __attribute__ ((unused)),
28 unsigned int ndx __attribute__ ((unused)),
29 uintptr_t *refcook, uintptr_t *defcook,
30 La_mips_32_regs *regs, unsigned int *flags,
31 const char *symname, long int *framesizep)
32 {
33 print_enter (refcook, defcook, symname,
34 regs->lr_reg[0], regs->lr_reg[1], regs->lr_reg[2],
35 *flags);
36
37 /* No need to copy anything, we will not need the parameters in any case. */
38 *framesizep = 0;
39
40 return sym->st_value;
41 }
42
43 unsigned int
la_mips_o32_gnu_pltexit(ElfW (Sym)* sym,unsigned int ndx,uintptr_t * refcook,uintptr_t * defcook,const struct La_mips_32_regs * inregs,struct La_mips_32_retval * outregs,const char * symname)44 la_mips_o32_gnu_pltexit (ElfW(Sym) *sym, unsigned int ndx, uintptr_t *refcook,
45 uintptr_t *defcook,
46 const struct La_mips_32_regs *inregs,
47 struct La_mips_32_retval *outregs,
48 const char *symname)
49 {
50 print_exit (refcook, defcook, symname, outregs->lrv_v0);
51
52 return 0;
53 }
54
55 #elif _MIPS_SIM == _ABIN32
56
57 ElfW(Addr)
la_mips_n32_gnu_pltenter(ElfW (Sym)* sym,unsigned int ndx,uintptr_t * refcook,uintptr_t * defcook,La_mips_64_regs * regs,unsigned int * flags,const char * symname,long int * framesizep)58 la_mips_n32_gnu_pltenter (ElfW(Sym) *sym __attribute__ ((unused)),
59 unsigned int ndx __attribute__ ((unused)),
60 uintptr_t *refcook, uintptr_t *defcook,
61 La_mips_64_regs *regs, unsigned int *flags,
62 const char *symname, long int *framesizep)
63 {
64 print_enter (refcook, defcook, symname,
65 regs->lr_reg[0], regs->lr_reg[1], regs->lr_reg[2],
66 *flags);
67
68 /* No need to copy anything, we will not need the parameters in any case. */
69 *framesizep = 0;
70
71 return sym->st_value;
72 }
73
74 unsigned int
la_mips_n32_gnu_pltexit(ElfW (Sym)* sym,unsigned int ndx,uintptr_t * refcook,uintptr_t * defcook,const struct La_mips_64_regs * inregs,struct La_mips_64_retval * outregs,const char * symname)75 la_mips_n32_gnu_pltexit (ElfW(Sym) *sym, unsigned int ndx, uintptr_t *refcook,
76 uintptr_t *defcook,
77 const struct La_mips_64_regs *inregs,
78 struct La_mips_64_retval *outregs,
79 const char *symname)
80 {
81 print_exit (refcook, defcook, symname, outregs->lrv_v0);
82
83 return 0;
84 }
85
86 #else
87
88 ElfW(Addr)
la_mips_n64_gnu_pltenter(ElfW (Sym)* sym,unsigned int ndx,uintptr_t * refcook,uintptr_t * defcook,La_mips_64_regs * regs,unsigned int * flags,const char * symname,long int * framesizep)89 la_mips_n64_gnu_pltenter (ElfW(Sym) *sym __attribute__ ((unused)),
90 unsigned int ndx __attribute__ ((unused)),
91 uintptr_t *refcook, uintptr_t *defcook,
92 La_mips_64_regs *regs, unsigned int *flags,
93 const char *symname, long int *framesizep)
94 {
95 print_enter (refcook, defcook, symname,
96 regs->lr_reg[0], regs->lr_reg[1], regs->lr_reg[2],
97 *flags);
98
99 /* No need to copy anything, we will not need the parameters in any case. */
100 *framesizep = 0;
101
102 return sym->st_value;
103 }
104
105 unsigned int
la_mips_n64_gnu_pltexit(ElfW (Sym)* sym,unsigned int ndx,uintptr_t * refcook,uintptr_t * defcook,const struct La_mips_64_regs * inregs,struct La_mips_64_retval * outregs,const char * symname)106 la_mips_n64_gnu_pltexit (ElfW(Sym) *sym, unsigned int ndx, uintptr_t *refcook,
107 uintptr_t *defcook,
108 const struct La_mips_64_regs *inregs,
109 struct La_mips_64_retval *outregs,
110 const char *symname)
111 {
112 print_exit (refcook, defcook, symname, outregs->lrv_v0);
113
114 return 0;
115 }
116
117 #endif
118