8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef __ELF_FILE_HPP
26 #define __ELF_FILE_HPP
27
28 #ifndef _WINDOWS
29
30 #include <elf.h>
31 #include <stdio.h>
32
33 #ifdef _LP64
34
35 typedef Elf64_Half Elf_Half;
36 typedef Elf64_Word Elf_Word;
37 typedef Elf64_Off Elf_Off;
38 typedef Elf64_Addr Elf_Addr;
39
40 typedef Elf64_Ehdr Elf_Ehdr;
41 typedef Elf64_Shdr Elf_Shdr;
42 typedef Elf64_Sym Elf_Sym;
43
44 #define ELF_ST_TYPE ELF64_ST_TYPE
45
46 #else
47
48 typedef Elf32_Half Elf_Half;
49 typedef Elf32_Word Elf_Word;
50 typedef Elf32_Off Elf_Off;
51 typedef Elf32_Addr Elf_Addr;
52
53
54 typedef Elf32_Ehdr Elf_Ehdr;
55 typedef Elf32_Shdr Elf_Shdr;
56 typedef Elf32_Sym Elf_Sym;
57
58 #define ELF_ST_TYPE ELF32_ST_TYPE
59 #endif
60
61 #include "globalDefinitions.hpp"
62 #include "memory/allocation.hpp"
63 #include "utilities/decoder.hpp"
64
65
66 class ElfStringTable;
67 class ElfSymbolTable;
68
69
70 // On Solaris/Linux platforms, libjvm.so does contain all private symbols.
71 // ElfFile is basically an elf file parser, which can lookup the symbol
72 // that is the nearest to the given address.
73 // Beware, this code is called from vm error reporting code, when vm is already
74 // in "error" state, so there are scenarios, lookup will fail. We want this
75 // part of code to be very defensive, and bait out if anything went wrong.
76
77 class ElfFile: public CHeapObj {
78 friend class Decoder;
79 public:
120 private:
121 // file
122 const char* m_filepath;
123 FILE* m_file;
124
125 // Elf header
126 Elf_Ehdr m_elfHdr;
127
128 // symbol tables
129 ElfSymbolTable* m_symbol_tables;
130
131 // string tables
132 ElfStringTable* m_string_tables;
133
134 Decoder::decoder_status m_status;
135 };
136
137 #endif // _WINDOWS
138
139 #endif // __ELF_FILE_HPP
140
|
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef __ELF_FILE_HPP
26 #define __ELF_FILE_HPP
27
28 #if !defined(_WINDOWS) && !defined(__APPLE__)
29
30 #if defined(__OpenBSD__)
31 #include <sys/exec_elf.h>
32 #else
33 #include <elf.h>
34 #endif
35 #include <stdio.h>
36
37 #ifdef _LP64
38
39 typedef Elf64_Half Elf_Half;
40 typedef Elf64_Word Elf_Word;
41 typedef Elf64_Off Elf_Off;
42 typedef Elf64_Addr Elf_Addr;
43
44 typedef Elf64_Ehdr Elf_Ehdr;
45 typedef Elf64_Shdr Elf_Shdr;
46 typedef Elf64_Sym Elf_Sym;
47
48 #if !defined(_ALLBSD_SOURCE) || defined(__APPLE__)
49 #define ELF_ST_TYPE ELF64_ST_TYPE
50 #endif
51
52 #else
53
54 typedef Elf32_Half Elf_Half;
55 typedef Elf32_Word Elf_Word;
56 typedef Elf32_Off Elf_Off;
57 typedef Elf32_Addr Elf_Addr;
58
59
60 typedef Elf32_Ehdr Elf_Ehdr;
61 typedef Elf32_Shdr Elf_Shdr;
62 typedef Elf32_Sym Elf_Sym;
63
64 #if !defined(_ALLBSD_SOURCE) || defined(__APPLE__)
65 #define ELF_ST_TYPE ELF32_ST_TYPE
66 #endif
67 #endif
68
69 #include "globalDefinitions.hpp"
70 #include "memory/allocation.hpp"
71 #include "utilities/decoder.hpp"
72
73
74 class ElfStringTable;
75 class ElfSymbolTable;
76
77
78 // On Solaris/Linux platforms, libjvm.so does contain all private symbols.
79 // ElfFile is basically an elf file parser, which can lookup the symbol
80 // that is the nearest to the given address.
81 // Beware, this code is called from vm error reporting code, when vm is already
82 // in "error" state, so there are scenarios, lookup will fail. We want this
83 // part of code to be very defensive, and bait out if anything went wrong.
84
85 class ElfFile: public CHeapObj {
86 friend class Decoder;
87 public:
128 private:
129 // file
130 const char* m_filepath;
131 FILE* m_file;
132
133 // Elf header
134 Elf_Ehdr m_elfHdr;
135
136 // symbol tables
137 ElfSymbolTable* m_symbol_tables;
138
139 // string tables
140 ElfStringTable* m_string_tables;
141
142 Decoder::decoder_status m_status;
143 };
144
145 #endif // _WINDOWS
146
147 #endif // __ELF_FILE_HPP
|