1 /*
2  * This file is part of ltrace.
3  * Copyright (C) 2013 Petr Machata
4  * Copyright (C) 2006 Eric Vaitl
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of the
9  * License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19  * 02110-1301 USA
20  */
21 
22 #ifndef LTRACE_MIPS_ARCH_H
23 #define LTRACE_MIPS_ARCH_H
24 
25 #include <stddef.h>
26 #include <gelf.h>
27 
28 #ifdef __MIPSEL__
29 # define BREAKPOINT_VALUE { 0x0d, 0x00, 0x00, 0x00 }
30 # define ARCH_ENDIAN_LITTLE
31 #elif defined(__MIPSEB__)
32 # define BREAKPOINT_VALUE { 0x00, 0x00, 0x00, 0x0d }
33 # define ARCH_ENDIAN_BIG
34 #else
35 # error __MIPSEL__ or __MIPSEB__ must be defined
36 #endif
37 
38 #define BREAKPOINT_LENGTH 4
39 #define DECR_PC_AFTER_BREAK 0
40 
41 #define LT_ELFCLASS	ELFCLASS32
42 #define LT_ELF_MACHINE	EM_MIPS
43 
44 #define ARCH_HAVE_LTELF_DATA
45 struct arch_ltelf_data {
46 	size_t pltgot_addr;
47 	size_t mips_local_gotno;
48 	size_t mips_gotsym;
49 };
50 
51 #define ARCH_HAVE_FIND_DL_DEBUG
52 #define ARCH_HAVE_GET_SYMINFO
53 #define ARCH_HAVE_DYNLINK_DONE
54 #define ARCH_HAVE_ADD_PLT_ENTRY
55 #define ARCH_HAVE_SW_SINGLESTEP
56 #define ARCH_HAVE_SYMBOL_RET
57 
58 #define ARCH_HAVE_LIBRARY_SYMBOL_DATA
59 enum mips_plt_type
60 {
61 	MIPS_PLT_UNRESOLVED,
62 	MIPS_PLT_RESOLVED,
63 };
64 
65 struct arch_library_symbol_data {
66 	enum mips_plt_type type;
67 	GElf_Addr resolved_addr;
68 	GElf_Addr stub_addr;
69 
70 	/* Set for FUNCs that have GOT entries but not PLT entries.  */
71 	int gotonly : 1;
72 	/* Set for FUNCs that have PLT entries that are always used.  */
73 	int pltalways : 1;
74 };
75 
76 #endif /* LTRACE_MIPS_ARCH_H */
77