|
@@
-1,823
+1,846
|
|
1
|
/*------------------------------------------------------------------------------
|
|
1
|
/*------------------------------------------------------------------------------
|
|
2
|
-- This file is a part of the SocExplorer Software
|
|
2
|
-- This file is a part of the SocExplorer Software
|
|
3
|
-- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
|
|
3
|
-- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
|
|
4
|
--
|
|
4
|
--
|
|
5
|
-- This program is free software; you can redistribute it and/or modify
|
|
5
|
-- This program is free software; you can redistribute it and/or modify
|
|
6
|
-- it under the terms of the GNU General Public License as published by
|
|
6
|
-- it under the terms of the GNU General Public License as published by
|
|
7
|
-- the Free Software Foundation; either version 2 of the License, or
|
|
7
|
-- the Free Software Foundation; either version 2 of the License, or
|
|
8
|
-- (at your option) any later version.
|
|
8
|
-- (at your option) any later version.
|
|
9
|
--
|
|
9
|
--
|
|
10
|
-- This program is distributed in the hope that it will be useful,
|
|
10
|
-- This program is distributed in the hope that it will be useful,
|
|
11
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-- GNU General Public License for more details.
|
|
13
|
-- GNU General Public License for more details.
|
|
14
|
--
|
|
14
|
--
|
|
15
|
-- You should have received a copy of the GNU General Public License
|
|
15
|
-- You should have received a copy of the GNU General Public License
|
|
16
|
-- along with this program; if not, write to the Free Software
|
|
16
|
-- along with this program; if not, write to the Free Software
|
|
17
|
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
17
|
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
18
|
-------------------------------------------------------------------------------*/
|
|
18
|
-------------------------------------------------------------------------------*/
|
|
19
|
/*-- Author :
|
|
19
|
/*-- Author :
|
|
20
|
Alexis Jeandet
|
|
20
|
Alexis Jeandet
|
|
21
|
-- Mail :
|
|
21
|
-- Mail :
|
|
22
|
alexis.jeandet@member.fsf.org
|
|
22
|
alexis.jeandet@member.fsf.org
|
|
23
|
----------------------------------------------------------------------------*/
|
|
23
|
----------------------------------------------------------------------------*/
|
|
24
|
#include "elffile.h"
|
|
24
|
#include "elffile.h"
|
|
25
|
|
|
25
|
|
|
26
|
ElfFile::ElfFile()
|
|
26
|
ElfFile::ElfFile()
|
|
27
|
:abstractExecFile()
|
|
27
|
:abstractExecFile()
|
|
28
|
{
|
|
28
|
{
|
|
29
|
this->opened = false;
|
|
29
|
this->opened = false;
|
|
30
|
this->type_elf = false;
|
|
30
|
this->type_elf = false;
|
|
31
|
this->elfFile = NULL;
|
|
31
|
this->elfFile = NULL;
|
|
32
|
this->e = NULL;
|
|
32
|
this->e = NULL;
|
|
33
|
}
|
|
33
|
}
|
|
34
|
|
|
34
|
|
|
35
|
ElfFile::ElfFile(const QString &File)
|
|
35
|
ElfFile::ElfFile(const QString &File)
|
|
36
|
:abstractExecFile()
|
|
36
|
:abstractExecFile()
|
|
37
|
{
|
|
37
|
{
|
|
38
|
this->opened = false;
|
|
38
|
this->opened = false;
|
|
39
|
this->type_elf = false;
|
|
39
|
this->type_elf = false;
|
|
40
|
this->elfFile = NULL;
|
|
40
|
this->elfFile = NULL;
|
|
41
|
this->e = NULL;
|
|
41
|
this->e = NULL;
|
|
42
|
this->p_fileName = File;
|
|
42
|
this->p_fileName = File;
|
|
43
|
openFile(File);
|
|
43
|
openFile(File);
|
|
44
|
}
|
|
44
|
}
|
|
45
|
|
|
45
|
|
|
46
|
bool ElfFile::openFile(const QString &File)
|
|
46
|
bool ElfFile::openFile(const QString &File)
|
|
47
|
{
|
|
47
|
{
|
|
48
|
this->p_fileName = File;
|
|
48
|
this->p_fileName = File;
|
|
49
|
this->closeFile();
|
|
49
|
this->closeFile();
|
|
50
|
if(elf_version(EV_CURRENT)==EV_NONE)return 0;
|
|
50
|
if(elf_version(EV_CURRENT)==EV_NONE)return 0;
|
|
51
|
#ifdef _ELF_WINDOWS_
|
|
51
|
#ifdef _ELF_WINDOWS_
|
|
52
|
this->elfFile = open(File.toStdString().c_str(),O_RDONLY|O_BINARY ,0);
|
|
52
|
this->elfFile = open(File.toStdString().c_str(),O_RDONLY|O_BINARY ,0);
|
|
53
|
#else
|
|
53
|
#else
|
|
54
|
this->elfFile = open(File.toStdString().c_str(),O_RDONLY ,0);
|
|
54
|
this->elfFile = open(File.toStdString().c_str(),O_RDONLY ,0);
|
|
55
|
#endif
|
|
55
|
#endif
|
|
56
|
if(this->elfFile==NULL)return 0;
|
|
56
|
if(this->elfFile==NULL)return 0;
|
|
57
|
this->e = elf_begin(this->elfFile,ELF_C_READ,NULL);
|
|
57
|
this->e = elf_begin(this->elfFile,ELF_C_READ,NULL);
|
|
58
|
if(this->e==NULL)return 0;
|
|
58
|
if(this->e==NULL)return 0;
|
|
59
|
this->ek = elf_kind(this->e);
|
|
59
|
this->ek = elf_kind(this->e);
|
|
60
|
gelf_getehdr (this->e, &this->ehdr );
|
|
60
|
gelf_getehdr (this->e, &this->ehdr );
|
|
61
|
elf_getshdrstrndx (this->e, &this->shstrndx);
|
|
61
|
elf_getshdrstrndx (this->e, &this->shstrndx);
|
|
62
|
this->updateSegments();
|
|
62
|
this->updateSegments();
|
|
63
|
this->updateSections();
|
|
63
|
this->updateSections();
|
|
|
|
|
64
|
this->updateSymbols();
|
|
64
|
this->opened = true;
|
|
65
|
this->opened = true;
|
|
65
|
return 1;
|
|
66
|
return 1;
|
|
66
|
}
|
|
67
|
}
|
|
67
|
|
|
68
|
|
|
68
|
bool ElfFile::isopened()
|
|
69
|
bool ElfFile::isopened()
|
|
69
|
{
|
|
70
|
{
|
|
70
|
return this->opened;
|
|
71
|
return this->opened;
|
|
71
|
}
|
|
72
|
}
|
|
72
|
|
|
73
|
|
|
73
|
int ElfFile::closeFile()
|
|
74
|
int ElfFile::closeFile()
|
|
74
|
{
|
|
75
|
{
|
|
75
|
if(this->elfFile!=NULL)
|
|
76
|
if(this->elfFile!=NULL)
|
|
76
|
{
|
|
77
|
{
|
|
77
|
if(this->e!=NULL)
|
|
78
|
if(this->e!=NULL)
|
|
78
|
{
|
|
79
|
{
|
|
79
|
elf_end(this->e);
|
|
80
|
elf_end(this->e);
|
|
80
|
this->e = NULL;
|
|
81
|
this->e = NULL;
|
|
81
|
}
|
|
82
|
}
|
|
82
|
close(this->elfFile);
|
|
83
|
close(this->elfFile);
|
|
83
|
this->elfFile = NULL;
|
|
84
|
this->elfFile = NULL;
|
|
84
|
}
|
|
85
|
}
|
|
85
|
this->opened = false;
|
|
86
|
this->opened = false;
|
|
86
|
return 0;
|
|
87
|
return 0;
|
|
87
|
}
|
|
88
|
}
|
|
88
|
|
|
89
|
|
|
89
|
|
|
90
|
|
|
90
|
QList<codeFragment*> ElfFile::getFragments(QStringList fragmentList)
|
|
91
|
QList<codeFragment*> ElfFile::getFragments(QStringList fragmentList)
|
|
91
|
{
|
|
92
|
{
|
|
92
|
QList<codeFragment*> fragments;
|
|
93
|
QList<codeFragment*> fragments;
|
|
93
|
if (isopened())
|
|
94
|
if (isopened())
|
|
94
|
{
|
|
95
|
{
|
|
95
|
for(int i =0;i<fragmentList.count();i++)
|
|
96
|
for(int i =0;i<fragmentList.count();i++)
|
|
96
|
{
|
|
97
|
{
|
|
97
|
fragments.append(getFragment(fragmentList.at(i)));
|
|
98
|
fragments.append(getFragment(fragmentList.at(i)));
|
|
98
|
}
|
|
99
|
}
|
|
99
|
}
|
|
100
|
}
|
|
100
|
return fragments;
|
|
101
|
return fragments;
|
|
101
|
}
|
|
102
|
}
|
|
102
|
|
|
103
|
|
|
103
|
QList<codeFragment*> ElfFile::getFragments()
|
|
104
|
QList<codeFragment*> ElfFile::getFragments()
|
|
104
|
{
|
|
105
|
{
|
|
105
|
return getFragments(QStringList()<<".data"<<".text");
|
|
106
|
return getFragments(QStringList()<<".data"<<".text");
|
|
106
|
}
|
|
107
|
}
|
|
107
|
|
|
108
|
|
|
108
|
codeFragment *ElfFile::getFragment(const QString &name)
|
|
109
|
codeFragment *ElfFile::getFragment(const QString &name)
|
|
109
|
{
|
|
110
|
{
|
|
110
|
codeFragment* fragment= new codeFragment();
|
|
111
|
codeFragment* fragment= new codeFragment();
|
|
111
|
for(int i=0;i<getSectionCount();i++)
|
|
112
|
for(int i=0;i<getSectionCount();i++)
|
|
112
|
{
|
|
113
|
{
|
|
113
|
if(getSectionName(i) == name)
|
|
114
|
if(getSectionName(i) == name)
|
|
114
|
{
|
|
115
|
{
|
|
115
|
fragment->data =NULL;
|
|
116
|
fragment->data =NULL;
|
|
116
|
fragment->size = getSectionDatasz(i);
|
|
117
|
fragment->size = getSectionDatasz(i);
|
|
117
|
fragment->address = getSectionPaddr(i);
|
|
118
|
fragment->address = getSectionPaddr(i);
|
|
118
|
getSectionData(i,&fragment->data);
|
|
119
|
getSectionData(i,&fragment->data);
|
|
119
|
}
|
|
120
|
}
|
|
120
|
}
|
|
121
|
}
|
|
121
|
|
|
122
|
|
|
122
|
}
|
|
123
|
}
|
|
123
|
|
|
124
|
|
|
124
|
|
|
125
|
|
|
125
|
|
|
126
|
|
|
126
|
|
|
127
|
|
|
127
|
|
|
128
|
|
|
128
|
|
|
129
|
|
|
129
|
|
|
130
|
|
|
130
|
QString elfresolveMachine(Elf64_Half e_machine)
|
|
131
|
QString elfresolveMachine(Elf64_Half e_machine)
|
|
131
|
{
|
|
132
|
{
|
|
132
|
QString machineName;
|
|
133
|
QString machineName;
|
|
133
|
//Update from with bash script don't write it by yourself!
|
|
134
|
//Update from with bash script don't write it by yourself!
|
|
134
|
switch(e_machine)
|
|
135
|
switch(e_machine)
|
|
135
|
{
|
|
136
|
{
|
|
136
|
case EM_NONE:
|
|
137
|
case EM_NONE:
|
|
137
|
machineName = " No machine ";
|
|
138
|
machineName = " No machine ";
|
|
138
|
break;
|
|
139
|
break;
|
|
139
|
case EM_M32:
|
|
140
|
case EM_M32:
|
|
140
|
machineName = " AT&T WE 32100 ";
|
|
141
|
machineName = " AT&T WE 32100 ";
|
|
141
|
break;
|
|
142
|
break;
|
|
142
|
case EM_SPARC:
|
|
143
|
case EM_SPARC:
|
|
143
|
machineName = " SUN SPARC ";
|
|
144
|
machineName = " SUN SPARC ";
|
|
144
|
break;
|
|
145
|
break;
|
|
145
|
case EM_386:
|
|
146
|
case EM_386:
|
|
146
|
machineName = " Intel 80386 ";
|
|
147
|
machineName = " Intel 80386 ";
|
|
147
|
break;
|
|
148
|
break;
|
|
148
|
case EM_68K:
|
|
149
|
case EM_68K:
|
|
149
|
machineName = " Motorola m68k family ";
|
|
150
|
machineName = " Motorola m68k family ";
|
|
150
|
break;
|
|
151
|
break;
|
|
151
|
case EM_88K:
|
|
152
|
case EM_88K:
|
|
152
|
machineName = " Motorola m88k family ";
|
|
153
|
machineName = " Motorola m88k family ";
|
|
153
|
break;
|
|
154
|
break;
|
|
154
|
case EM_860:
|
|
155
|
case EM_860:
|
|
155
|
machineName = " Intel 80860 ";
|
|
156
|
machineName = " Intel 80860 ";
|
|
156
|
break;
|
|
157
|
break;
|
|
157
|
case EM_MIPS:
|
|
158
|
case EM_MIPS:
|
|
158
|
machineName = " MIPS R3000 big-endian ";
|
|
159
|
machineName = " MIPS R3000 big-endian ";
|
|
159
|
break;
|
|
160
|
break;
|
|
160
|
case EM_S370:
|
|
161
|
case EM_S370:
|
|
161
|
machineName = " IBM System/370 ";
|
|
162
|
machineName = " IBM System/370 ";
|
|
162
|
break;
|
|
163
|
break;
|
|
163
|
case EM_MIPS_RS3_LE:
|
|
164
|
case EM_MIPS_RS3_LE:
|
|
164
|
machineName = " MIPS R3000 little-endian ";
|
|
165
|
machineName = " MIPS R3000 little-endian ";
|
|
165
|
break;
|
|
166
|
break;
|
|
166
|
case EM_PARISC:
|
|
167
|
case EM_PARISC:
|
|
167
|
machineName = " HPPA ";
|
|
168
|
machineName = " HPPA ";
|
|
168
|
break;
|
|
169
|
break;
|
|
169
|
case EM_VPP500:
|
|
170
|
case EM_VPP500:
|
|
170
|
machineName = " Fujitsu VPP500 ";
|
|
171
|
machineName = " Fujitsu VPP500 ";
|
|
171
|
break;
|
|
172
|
break;
|
|
172
|
case EM_SPARC32PLUS:
|
|
173
|
case EM_SPARC32PLUS:
|
|
173
|
machineName = " Sun's \"v8plus\" ";
|
|
174
|
machineName = " Sun's \"v8plus\" ";
|
|
174
|
break;
|
|
175
|
break;
|
|
175
|
case EM_960:
|
|
176
|
case EM_960:
|
|
176
|
machineName = " Intel 80960 ";
|
|
177
|
machineName = " Intel 80960 ";
|
|
177
|
break;
|
|
178
|
break;
|
|
178
|
case EM_PPC:
|
|
179
|
case EM_PPC:
|
|
179
|
machineName = " PowerPC ";
|
|
180
|
machineName = " PowerPC ";
|
|
180
|
break;
|
|
181
|
break;
|
|
181
|
case EM_PPC64:
|
|
182
|
case EM_PPC64:
|
|
182
|
machineName = " PowerPC 64-bit ";
|
|
183
|
machineName = " PowerPC 64-bit ";
|
|
183
|
break;
|
|
184
|
break;
|
|
184
|
case EM_S390:
|
|
185
|
case EM_S390:
|
|
185
|
machineName = " IBM S390 ";
|
|
186
|
machineName = " IBM S390 ";
|
|
186
|
break;
|
|
187
|
break;
|
|
187
|
case EM_V800:
|
|
188
|
case EM_V800:
|
|
188
|
machineName = " NEC V800 series ";
|
|
189
|
machineName = " NEC V800 series ";
|
|
189
|
break;
|
|
190
|
break;
|
|
190
|
case EM_FR20:
|
|
191
|
case EM_FR20:
|
|
191
|
machineName = " Fujitsu FR20 ";
|
|
192
|
machineName = " Fujitsu FR20 ";
|
|
192
|
break;
|
|
193
|
break;
|
|
193
|
case EM_RH32:
|
|
194
|
case EM_RH32:
|
|
194
|
machineName = " TRW RH-32 ";
|
|
195
|
machineName = " TRW RH-32 ";
|
|
195
|
break;
|
|
196
|
break;
|
|
196
|
case EM_RCE:
|
|
197
|
case EM_RCE:
|
|
197
|
machineName = " Motorola RCE ";
|
|
198
|
machineName = " Motorola RCE ";
|
|
198
|
break;
|
|
199
|
break;
|
|
199
|
case EM_ARM:
|
|
200
|
case EM_ARM:
|
|
200
|
machineName = " ARM ";
|
|
201
|
machineName = " ARM ";
|
|
201
|
break;
|
|
202
|
break;
|
|
202
|
case EM_FAKE_ALPHA:
|
|
203
|
case EM_FAKE_ALPHA:
|
|
203
|
machineName = " Digital Alpha ";
|
|
204
|
machineName = " Digital Alpha ";
|
|
204
|
break;
|
|
205
|
break;
|
|
205
|
case EM_SH:
|
|
206
|
case EM_SH:
|
|
206
|
machineName = " Hitachi SH ";
|
|
207
|
machineName = " Hitachi SH ";
|
|
207
|
break;
|
|
208
|
break;
|
|
208
|
case EM_SPARCV9:
|
|
209
|
case EM_SPARCV9:
|
|
209
|
machineName = " SPARC v9 64-bit ";
|
|
210
|
machineName = " SPARC v9 64-bit ";
|
|
210
|
break;
|
|
211
|
break;
|
|
211
|
case EM_TRICORE:
|
|
212
|
case EM_TRICORE:
|
|
212
|
machineName = " Siemens Tricore ";
|
|
213
|
machineName = " Siemens Tricore ";
|
|
213
|
break;
|
|
214
|
break;
|
|
214
|
case EM_ARC:
|
|
215
|
case EM_ARC:
|
|
215
|
machineName = " Argonaut RISC Core ";
|
|
216
|
machineName = " Argonaut RISC Core ";
|
|
216
|
break;
|
|
217
|
break;
|
|
217
|
case EM_H8_300:
|
|
218
|
case EM_H8_300:
|
|
218
|
machineName = " Hitachi H8/300 ";
|
|
219
|
machineName = " Hitachi H8/300 ";
|
|
219
|
break;
|
|
220
|
break;
|
|
220
|
case EM_H8_300H:
|
|
221
|
case EM_H8_300H:
|
|
221
|
machineName = " Hitachi H8/300H ";
|
|
222
|
machineName = " Hitachi H8/300H ";
|
|
222
|
break;
|
|
223
|
break;
|
|
223
|
case EM_H8S:
|
|
224
|
case EM_H8S:
|
|
224
|
machineName = " Hitachi H8S ";
|
|
225
|
machineName = " Hitachi H8S ";
|
|
225
|
break;
|
|
226
|
break;
|
|
226
|
case EM_H8_500:
|
|
227
|
case EM_H8_500:
|
|
227
|
machineName = " Hitachi H8/500 ";
|
|
228
|
machineName = " Hitachi H8/500 ";
|
|
228
|
break;
|
|
229
|
break;
|
|
229
|
case EM_IA_64:
|
|
230
|
case EM_IA_64:
|
|
230
|
machineName = " Intel Merced ";
|
|
231
|
machineName = " Intel Merced ";
|
|
231
|
break;
|
|
232
|
break;
|
|
232
|
case EM_MIPS_X:
|
|
233
|
case EM_MIPS_X:
|
|
233
|
machineName = " Stanford MIPS-X ";
|
|
234
|
machineName = " Stanford MIPS-X ";
|
|
234
|
break;
|
|
235
|
break;
|
|
235
|
case EM_COLDFIRE:
|
|
236
|
case EM_COLDFIRE:
|
|
236
|
machineName = " Motorola Coldfire ";
|
|
237
|
machineName = " Motorola Coldfire ";
|
|
237
|
break;
|
|
238
|
break;
|
|
238
|
case EM_68HC12:
|
|
239
|
case EM_68HC12:
|
|
239
|
machineName = " Motorola M68HC12 ";
|
|
240
|
machineName = " Motorola M68HC12 ";
|
|
240
|
break;
|
|
241
|
break;
|
|
241
|
case EM_MMA:
|
|
242
|
case EM_MMA:
|
|
242
|
machineName = " Fujitsu MMA Multimedia Accelerator";
|
|
243
|
machineName = " Fujitsu MMA Multimedia Accelerator";
|
|
243
|
break;
|
|
244
|
break;
|
|
244
|
case EM_PCP:
|
|
245
|
case EM_PCP:
|
|
245
|
machineName = " Siemens PCP ";
|
|
246
|
machineName = " Siemens PCP ";
|
|
246
|
break;
|
|
247
|
break;
|
|
247
|
case EM_NCPU:
|
|
248
|
case EM_NCPU:
|
|
248
|
machineName = " Sony nCPU embeeded RISC ";
|
|
249
|
machineName = " Sony nCPU embeeded RISC ";
|
|
249
|
break;
|
|
250
|
break;
|
|
250
|
case EM_NDR1:
|
|
251
|
case EM_NDR1:
|
|
251
|
machineName = " Denso NDR1 microprocessor ";
|
|
252
|
machineName = " Denso NDR1 microprocessor ";
|
|
252
|
break;
|
|
253
|
break;
|
|
253
|
case EM_STARCORE:
|
|
254
|
case EM_STARCORE:
|
|
254
|
machineName = " Motorola Start*Core processor ";
|
|
255
|
machineName = " Motorola Start*Core processor ";
|
|
255
|
break;
|
|
256
|
break;
|
|
256
|
case EM_ME16:
|
|
257
|
case EM_ME16:
|
|
257
|
machineName = " Toyota ME16 processor ";
|
|
258
|
machineName = " Toyota ME16 processor ";
|
|
258
|
break;
|
|
259
|
break;
|
|
259
|
case EM_ST100:
|
|
260
|
case EM_ST100:
|
|
260
|
machineName = " STMicroelectronic ST100 processor ";
|
|
261
|
machineName = " STMicroelectronic ST100 processor ";
|
|
261
|
break;
|
|
262
|
break;
|
|
262
|
case EM_TINYJ:
|
|
263
|
case EM_TINYJ:
|
|
263
|
machineName = " Advanced Logic Corp. Tinyj emb.fam";
|
|
264
|
machineName = " Advanced Logic Corp. Tinyj emb.fam";
|
|
264
|
break;
|
|
265
|
break;
|
|
265
|
case EM_X86_64:
|
|
266
|
case EM_X86_64:
|
|
266
|
machineName = " AMD x86-64 architecture ";
|
|
267
|
machineName = " AMD x86-64 architecture ";
|
|
267
|
break;
|
|
268
|
break;
|
|
268
|
case EM_PDSP:
|
|
269
|
case EM_PDSP:
|
|
269
|
machineName = " Sony DSP Processor ";
|
|
270
|
machineName = " Sony DSP Processor ";
|
|
270
|
break;
|
|
271
|
break;
|
|
271
|
case EM_FX66:
|
|
272
|
case EM_FX66:
|
|
272
|
machineName = " Siemens FX66 microcontroller ";
|
|
273
|
machineName = " Siemens FX66 microcontroller ";
|
|
273
|
break;
|
|
274
|
break;
|
|
274
|
case EM_ST9PLUS:
|
|
275
|
case EM_ST9PLUS:
|
|
275
|
machineName = " STMicroelectronics ST9+ 8/16 mc ";
|
|
276
|
machineName = " STMicroelectronics ST9+ 8/16 mc ";
|
|
276
|
break;
|
|
277
|
break;
|
|
277
|
case EM_ST7:
|
|
278
|
case EM_ST7:
|
|
278
|
machineName = " STmicroelectronics ST7 8 bit mc ";
|
|
279
|
machineName = " STmicroelectronics ST7 8 bit mc ";
|
|
279
|
break;
|
|
280
|
break;
|
|
280
|
case EM_68HC16:
|
|
281
|
case EM_68HC16:
|
|
281
|
machineName = " Motorola MC68HC16 microcontroller ";
|
|
282
|
machineName = " Motorola MC68HC16 microcontroller ";
|
|
282
|
break;
|
|
283
|
break;
|
|
283
|
case EM_68HC11:
|
|
284
|
case EM_68HC11:
|
|
284
|
machineName = " Motorola MC68HC11 microcontroller ";
|
|
285
|
machineName = " Motorola MC68HC11 microcontroller ";
|
|
285
|
break;
|
|
286
|
break;
|
|
286
|
case EM_68HC08:
|
|
287
|
case EM_68HC08:
|
|
287
|
machineName = " Motorola MC68HC08 microcontroller ";
|
|
288
|
machineName = " Motorola MC68HC08 microcontroller ";
|
|
288
|
break;
|
|
289
|
break;
|
|
289
|
case EM_68HC05:
|
|
290
|
case EM_68HC05:
|
|
290
|
machineName = " Motorola MC68HC05 microcontroller ";
|
|
291
|
machineName = " Motorola MC68HC05 microcontroller ";
|
|
291
|
break;
|
|
292
|
break;
|
|
292
|
case EM_SVX:
|
|
293
|
case EM_SVX:
|
|
293
|
machineName = " Silicon Graphics SVx ";
|
|
294
|
machineName = " Silicon Graphics SVx ";
|
|
294
|
break;
|
|
295
|
break;
|
|
295
|
case EM_ST19:
|
|
296
|
case EM_ST19:
|
|
296
|
machineName = " STMicroelectronics ST19 8 bit mc ";
|
|
297
|
machineName = " STMicroelectronics ST19 8 bit mc ";
|
|
297
|
break;
|
|
298
|
break;
|
|
298
|
case EM_VAX:
|
|
299
|
case EM_VAX:
|
|
299
|
machineName = " Digital VAX ";
|
|
300
|
machineName = " Digital VAX ";
|
|
300
|
break;
|
|
301
|
break;
|
|
301
|
case EM_CRIS:
|
|
302
|
case EM_CRIS:
|
|
302
|
machineName = " Axis Communications 32-bit embedded processor ";
|
|
303
|
machineName = " Axis Communications 32-bit embedded processor ";
|
|
303
|
break;
|
|
304
|
break;
|
|
304
|
case EM_JAVELIN:
|
|
305
|
case EM_JAVELIN:
|
|
305
|
machineName = " Infineon Technologies 32-bit embedded processor ";
|
|
306
|
machineName = " Infineon Technologies 32-bit embedded processor ";
|
|
306
|
break;
|
|
307
|
break;
|
|
307
|
case EM_FIREPATH:
|
|
308
|
case EM_FIREPATH:
|
|
308
|
machineName = " Element 14 64-bit DSP Processor ";
|
|
309
|
machineName = " Element 14 64-bit DSP Processor ";
|
|
309
|
break;
|
|
310
|
break;
|
|
310
|
case EM_ZSP:
|
|
311
|
case EM_ZSP:
|
|
311
|
machineName = " LSI Logic 16-bit DSP Processor ";
|
|
312
|
machineName = " LSI Logic 16-bit DSP Processor ";
|
|
312
|
break;
|
|
313
|
break;
|
|
313
|
case EM_MMIX:
|
|
314
|
case EM_MMIX:
|
|
314
|
machineName = " Donald Knuth's educational 64-bit processor ";
|
|
315
|
machineName = " Donald Knuth's educational 64-bit processor ";
|
|
315
|
break;
|
|
316
|
break;
|
|
316
|
case EM_HUANY:
|
|
317
|
case EM_HUANY:
|
|
317
|
machineName = " Harvard University machine-independent object files ";
|
|
318
|
machineName = " Harvard University machine-independent object files ";
|
|
318
|
break;
|
|
319
|
break;
|
|
319
|
case EM_PRISM:
|
|
320
|
case EM_PRISM:
|
|
320
|
machineName = " SiTera Prism ";
|
|
321
|
machineName = " SiTera Prism ";
|
|
321
|
break;
|
|
322
|
break;
|
|
322
|
case EM_AVR:
|
|
323
|
case EM_AVR:
|
|
323
|
machineName = " Atmel AVR 8-bit microcontroller ";
|
|
324
|
machineName = " Atmel AVR 8-bit microcontroller ";
|
|
324
|
break;
|
|
325
|
break;
|
|
325
|
case EM_FR30:
|
|
326
|
case EM_FR30:
|
|
326
|
machineName = " Fujitsu FR30 ";
|
|
327
|
machineName = " Fujitsu FR30 ";
|
|
327
|
break;
|
|
328
|
break;
|
|
328
|
case EM_D10V:
|
|
329
|
case EM_D10V:
|
|
329
|
machineName = " Mitsubishi D10V ";
|
|
330
|
machineName = " Mitsubishi D10V ";
|
|
330
|
break;
|
|
331
|
break;
|
|
331
|
case EM_D30V:
|
|
332
|
case EM_D30V:
|
|
332
|
machineName = " Mitsubishi D30V ";
|
|
333
|
machineName = " Mitsubishi D30V ";
|
|
333
|
break;
|
|
334
|
break;
|
|
334
|
case EM_V850:
|
|
335
|
case EM_V850:
|
|
335
|
machineName = " NEC v850 ";
|
|
336
|
machineName = " NEC v850 ";
|
|
336
|
break;
|
|
337
|
break;
|
|
337
|
case EM_M32R:
|
|
338
|
case EM_M32R:
|
|
338
|
machineName = " Mitsubishi M32R ";
|
|
339
|
machineName = " Mitsubishi M32R ";
|
|
339
|
break;
|
|
340
|
break;
|
|
340
|
case EM_MN10300:
|
|
341
|
case EM_MN10300:
|
|
341
|
machineName = " Matsushita MN10300 ";
|
|
342
|
machineName = " Matsushita MN10300 ";
|
|
342
|
break;
|
|
343
|
break;
|
|
343
|
case EM_MN10200:
|
|
344
|
case EM_MN10200:
|
|
344
|
machineName = " Matsushita MN10200 ";
|
|
345
|
machineName = " Matsushita MN10200 ";
|
|
345
|
break;
|
|
346
|
break;
|
|
346
|
case EM_PJ:
|
|
347
|
case EM_PJ:
|
|
347
|
machineName = " picoJava ";
|
|
348
|
machineName = " picoJava ";
|
|
348
|
break;
|
|
349
|
break;
|
|
349
|
case EM_OPENRISC:
|
|
350
|
case EM_OPENRISC:
|
|
350
|
machineName = " OpenRISC 32-bit embedded processor ";
|
|
351
|
machineName = " OpenRISC 32-bit embedded processor ";
|
|
351
|
break;
|
|
352
|
break;
|
|
352
|
case EM_ARC_A5:
|
|
353
|
case EM_ARC_A5:
|
|
353
|
machineName = " ARC Cores Tangent-A5 ";
|
|
354
|
machineName = " ARC Cores Tangent-A5 ";
|
|
354
|
break;
|
|
355
|
break;
|
|
355
|
case EM_XTENSA:
|
|
356
|
case EM_XTENSA:
|
|
356
|
machineName = " Tensilica Xtensa Architecture ";
|
|
357
|
machineName = " Tensilica Xtensa Architecture ";
|
|
357
|
break;
|
|
358
|
break;
|
|
358
|
case EM_AARCH64:
|
|
359
|
case EM_AARCH64:
|
|
359
|
machineName = " ARM AARCH64 ";
|
|
360
|
machineName = " ARM AARCH64 ";
|
|
360
|
break;
|
|
361
|
break;
|
|
361
|
case EM_TILEPRO:
|
|
362
|
case EM_TILEPRO:
|
|
362
|
machineName = " Tilera TILEPro ";
|
|
363
|
machineName = " Tilera TILEPro ";
|
|
363
|
break;
|
|
364
|
break;
|
|
364
|
case EM_MICROBLAZE:
|
|
365
|
case EM_MICROBLAZE:
|
|
365
|
machineName = " Xilinx MicroBlaze ";
|
|
366
|
machineName = " Xilinx MicroBlaze ";
|
|
366
|
break;
|
|
367
|
break;
|
|
367
|
case EM_TILEGX:
|
|
368
|
case EM_TILEGX:
|
|
368
|
machineName = " Tilera TILE-Gx ";
|
|
369
|
machineName = " Tilera TILE-Gx ";
|
|
369
|
break;
|
|
370
|
break;
|
|
370
|
case EM_NUM:
|
|
371
|
case EM_NUM:
|
|
371
|
machineName = "";
|
|
372
|
machineName = "";
|
|
372
|
break;
|
|
373
|
break;
|
|
373
|
default:
|
|
374
|
default:
|
|
374
|
machineName ="Unknow Machine";
|
|
375
|
machineName ="Unknow Machine";
|
|
375
|
break;
|
|
376
|
break;
|
|
376
|
}
|
|
377
|
}
|
|
377
|
return machineName;
|
|
378
|
return machineName;
|
|
378
|
}
|
|
379
|
}
|
|
379
|
|
|
380
|
|
|
380
|
|
|
381
|
|
|
381
|
|
|
382
|
|
|
382
|
|
|
383
|
|
|
383
|
QString ElfFile::getClass()
|
|
384
|
QString ElfFile::getClass()
|
|
384
|
{
|
|
385
|
{
|
|
385
|
if(this->e!=NULL)
|
|
386
|
if(this->e!=NULL)
|
|
386
|
{
|
|
387
|
{
|
|
387
|
int eclass = gelf_getclass(this->e);
|
|
388
|
int eclass = gelf_getclass(this->e);
|
|
388
|
if(eclass==ELFCLASS32)return "ELF32";
|
|
389
|
if(eclass==ELFCLASS32)return "ELF32";
|
|
389
|
if(eclass==ELFCLASS64)return "ELF64";
|
|
390
|
if(eclass==ELFCLASS64)return "ELF64";
|
|
390
|
}
|
|
391
|
}
|
|
391
|
return "none";
|
|
392
|
return "none";
|
|
392
|
}
|
|
393
|
}
|
|
393
|
|
|
394
|
|
|
394
|
|
|
395
|
|
|
395
|
bool ElfFile::iself()
|
|
396
|
bool ElfFile::iself()
|
|
396
|
{
|
|
397
|
{
|
|
397
|
return (this->getType()!="Unknow");
|
|
398
|
return (this->getType()!="Unknow");
|
|
398
|
}
|
|
399
|
}
|
|
399
|
|
|
400
|
|
|
400
|
QString ElfFile::getArchitecture()
|
|
401
|
QString ElfFile::getArchitecture()
|
|
401
|
{
|
|
402
|
{
|
|
402
|
if(this->e!=NULL)
|
|
403
|
if(this->e!=NULL)
|
|
403
|
{
|
|
404
|
{
|
|
404
|
return elfresolveMachine(this->ehdr.e_machine);
|
|
405
|
return elfresolveMachine(this->ehdr.e_machine);
|
|
405
|
}
|
|
406
|
}
|
|
406
|
return "";
|
|
407
|
return "";
|
|
407
|
}
|
|
408
|
}
|
|
408
|
|
|
409
|
|
|
409
|
|
|
410
|
|
|
410
|
QString ElfFile::getType()
|
|
411
|
QString ElfFile::getType()
|
|
411
|
{
|
|
412
|
{
|
|
412
|
QString kind("");
|
|
413
|
QString kind("");
|
|
413
|
if(this->e!=NULL)
|
|
414
|
if(this->e!=NULL)
|
|
414
|
{
|
|
415
|
{
|
|
415
|
switch(this->ek)
|
|
416
|
switch(this->ek)
|
|
416
|
{
|
|
417
|
{
|
|
417
|
case ELF_K_AR:
|
|
418
|
case ELF_K_AR:
|
|
418
|
kind = "Archive";
|
|
419
|
kind = "Archive";
|
|
419
|
break;
|
|
420
|
break;
|
|
420
|
case ELF_K_ELF:
|
|
421
|
case ELF_K_ELF:
|
|
421
|
kind = "Elf";
|
|
422
|
kind = "Elf";
|
|
422
|
break;
|
|
423
|
break;
|
|
423
|
case ELF_K_COFF:
|
|
424
|
case ELF_K_COFF:
|
|
424
|
kind = "COFF";
|
|
425
|
kind = "COFF";
|
|
425
|
break;
|
|
426
|
break;
|
|
426
|
case ELF_K_NUM:
|
|
427
|
case ELF_K_NUM:
|
|
427
|
kind = "NUM";
|
|
428
|
kind = "NUM";
|
|
428
|
break;
|
|
429
|
break;
|
|
429
|
case ELF_K_NONE:
|
|
430
|
case ELF_K_NONE:
|
|
430
|
kind = "Data";
|
|
431
|
kind = "Data";
|
|
431
|
break;
|
|
432
|
break;
|
|
432
|
default:
|
|
433
|
default:
|
|
433
|
kind = "Unknow";
|
|
434
|
kind = "Unknow";
|
|
434
|
break;
|
|
435
|
break;
|
|
435
|
}
|
|
436
|
}
|
|
436
|
}
|
|
437
|
}
|
|
437
|
return kind;
|
|
438
|
return kind;
|
|
438
|
}
|
|
439
|
}
|
|
439
|
|
|
440
|
|
|
440
|
QString ElfFile::getEndianness()
|
|
441
|
QString ElfFile::getEndianness()
|
|
441
|
{
|
|
442
|
{
|
|
442
|
if(this->e!=NULL)
|
|
443
|
if(this->e!=NULL)
|
|
443
|
{
|
|
444
|
{
|
|
444
|
if(this->ehdr.e_ident[EI_DATA]==ELFDATA2LSB)return "2's complement, little endian";
|
|
445
|
if(this->ehdr.e_ident[EI_DATA]==ELFDATA2LSB)return "2's complement, little endian";
|
|
445
|
if(this->ehdr.e_ident[EI_DATA]==ELFDATA2MSB)return "2's complement, big endian";
|
|
446
|
if(this->ehdr.e_ident[EI_DATA]==ELFDATA2MSB)return "2's complement, big endian";
|
|
446
|
}
|
|
447
|
}
|
|
447
|
return "none";
|
|
448
|
return "none";
|
|
448
|
}
|
|
449
|
}
|
|
449
|
|
|
450
|
|
|
450
|
QString ElfFile::getABI()
|
|
451
|
QString ElfFile::getABI()
|
|
451
|
{
|
|
452
|
{
|
|
452
|
if(this->e!=NULL)
|
|
453
|
if(this->e!=NULL)
|
|
453
|
{
|
|
454
|
{
|
|
454
|
if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_NONE)return "UNIX System V ABI";
|
|
455
|
if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_NONE)return "UNIX System V ABI";
|
|
455
|
if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_SYSV)return "Alias";
|
|
456
|
if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_SYSV)return "Alias";
|
|
456
|
if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_HPUX)return "HP-UX";
|
|
457
|
if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_HPUX)return "HP-UX";
|
|
457
|
if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_NETBSD)return "NetBSD";
|
|
458
|
if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_NETBSD)return "NetBSD";
|
|
458
|
if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_GNU)return "Object uses GNU ELF extensions";
|
|
459
|
if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_GNU)return "Object uses GNU ELF extensions";
|
|
459
|
if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_LINUX)return "Compatibility alias";
|
|
460
|
if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_LINUX)return "Compatibility alias";
|
|
460
|
if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_SOLARIS)return "Sun Solaris";
|
|
461
|
if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_SOLARIS)return "Sun Solaris";
|
|
461
|
if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_AIX)return "IBM AIX";
|
|
462
|
if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_AIX)return "IBM AIX";
|
|
462
|
if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_IRIX)return "SGI Irix";
|
|
463
|
if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_IRIX)return "SGI Irix";
|
|
463
|
if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_FREEBSD)return "FreeBSD";
|
|
464
|
if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_FREEBSD)return "FreeBSD";
|
|
464
|
if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_TRU64)return "Compaq TRU64 UNIX";
|
|
465
|
if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_TRU64)return "Compaq TRU64 UNIX";
|
|
465
|
if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_MODESTO)return " Novell Modesto";
|
|
466
|
if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_MODESTO)return " Novell Modesto";
|
|
466
|
if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_OPENBSD)return "OpenBSD";
|
|
467
|
if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_OPENBSD)return "OpenBSD";
|
|
467
|
if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_ARM_AEABI)return "ARM EABI";
|
|
468
|
if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_ARM_AEABI)return "ARM EABI";
|
|
468
|
if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_ARM)return "ARM";
|
|
469
|
if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_ARM)return "ARM";
|
|
469
|
if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_STANDALONE)return "Standalone (embedded) application";
|
|
470
|
if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_STANDALONE)return "Standalone (embedded) application";
|
|
470
|
}
|
|
471
|
}
|
|
471
|
return "none";
|
|
472
|
return "none";
|
|
472
|
}
|
|
473
|
}
|
|
473
|
|
|
474
|
|
|
474
|
|
|
475
|
|
|
475
|
qint64 ElfFile::getVersion()
|
|
476
|
qint64 ElfFile::getVersion()
|
|
476
|
{
|
|
477
|
{
|
|
477
|
if(this->e!=NULL)
|
|
478
|
if(this->e!=NULL)
|
|
478
|
{
|
|
479
|
{
|
|
479
|
return this->ehdr.e_version;
|
|
480
|
return this->ehdr.e_version;
|
|
480
|
}
|
|
481
|
}
|
|
481
|
}
|
|
482
|
}
|
|
482
|
|
|
483
|
|
|
483
|
qint64 ElfFile::getEntryPointAddress()
|
|
484
|
qint64 ElfFile::getEntryPointAddress()
|
|
484
|
{
|
|
485
|
{
|
|
485
|
if(this->e!=NULL)
|
|
486
|
if(this->e!=NULL)
|
|
486
|
{
|
|
487
|
{
|
|
487
|
return this->ehdr.e_entry;
|
|
488
|
return this->ehdr.e_entry;
|
|
488
|
}
|
|
489
|
}
|
|
489
|
}
|
|
490
|
}
|
|
490
|
|
|
491
|
|
|
491
|
|
|
492
|
|
|
492
|
int ElfFile::getSectionCount()
|
|
493
|
int ElfFile::getSectionCount()
|
|
493
|
{
|
|
494
|
{
|
|
494
|
return (int)this->SectionCount;
|
|
495
|
return (int)this->SectionCount;
|
|
495
|
}
|
|
496
|
}
|
|
496
|
|
|
497
|
|
|
497
|
int ElfFile::getSymbolCount()
|
|
498
|
int ElfFile::getSymbolCount()
|
|
498
|
{
|
|
499
|
{
|
|
499
|
return (int)this->SymbolCount;
|
|
500
|
return (int)this->SymbolCount;
|
|
500
|
}
|
|
501
|
}
|
|
501
|
|
|
502
|
|
|
502
|
|
|
503
|
|
|
503
|
int ElfFile::getSegmentCount()
|
|
504
|
int ElfFile::getSegmentCount()
|
|
504
|
{
|
|
505
|
{
|
|
505
|
return (int)this->SegmentCount;
|
|
506
|
return (int)this->SegmentCount;
|
|
506
|
}
|
|
507
|
}
|
|
507
|
|
|
508
|
|
|
508
|
|
|
509
|
|
|
509
|
QString ElfFile::getSegmentType(int index)
|
|
510
|
QString ElfFile::getSegmentType(int index)
|
|
510
|
{
|
|
511
|
{
|
|
511
|
QString type("");
|
|
512
|
QString type("");
|
|
512
|
if(this->e!=NULL)
|
|
513
|
if(this->e!=NULL)
|
|
513
|
{
|
|
514
|
{
|
|
514
|
if(index < this->Segments.count())
|
|
515
|
if(index < this->Segments.count())
|
|
515
|
{
|
|
516
|
{
|
|
516
|
switch(this->Segments.at(index)->p_type)
|
|
517
|
switch(this->Segments.at(index)->p_type)
|
|
517
|
{
|
|
518
|
{
|
|
518
|
case PT_NULL:
|
|
519
|
case PT_NULL:
|
|
519
|
type = "Program header table entry unused";
|
|
520
|
type = "Program header table entry unused";
|
|
520
|
break;
|
|
521
|
break;
|
|
521
|
case PT_LOAD:
|
|
522
|
case PT_LOAD:
|
|
522
|
type = "Loadable program segment";
|
|
523
|
type = "Loadable program segment";
|
|
523
|
break;
|
|
524
|
break;
|
|
524
|
case PT_DYNAMIC :
|
|
525
|
case PT_DYNAMIC :
|
|
525
|
type = "Dynamic linking information";
|
|
526
|
type = "Dynamic linking information";
|
|
526
|
break;
|
|
527
|
break;
|
|
527
|
case PT_INTERP:
|
|
528
|
case PT_INTERP:
|
|
528
|
type ="Program interpreter";
|
|
529
|
type ="Program interpreter";
|
|
529
|
break;
|
|
530
|
break;
|
|
530
|
case PT_NOTE:
|
|
531
|
case PT_NOTE:
|
|
531
|
type = "Auxiliary information";
|
|
532
|
type = "Auxiliary information";
|
|
532
|
break;
|
|
533
|
break;
|
|
533
|
case PT_SHLIB:
|
|
534
|
case PT_SHLIB:
|
|
534
|
type = "Reserved";
|
|
535
|
type = "Reserved";
|
|
535
|
break;
|
|
536
|
break;
|
|
536
|
case PT_PHDR:
|
|
537
|
case PT_PHDR:
|
|
537
|
type = "Entry for header table itself";
|
|
538
|
type = "Entry for header table itself";
|
|
538
|
break;
|
|
539
|
break;
|
|
539
|
case PT_TLS:
|
|
540
|
case PT_TLS:
|
|
540
|
type = "Thread-local storage segment";
|
|
541
|
type = "Thread-local storage segment";
|
|
541
|
break;
|
|
542
|
break;
|
|
542
|
case PT_NUM:
|
|
543
|
case PT_NUM:
|
|
543
|
type = "Number of defined types";
|
|
544
|
type = "Number of defined types";
|
|
544
|
break;
|
|
545
|
break;
|
|
545
|
case PT_LOOS:
|
|
546
|
case PT_LOOS:
|
|
546
|
type = "Start of OS-specific";
|
|
547
|
type = "Start of OS-specific";
|
|
547
|
break;
|
|
548
|
break;
|
|
548
|
case PT_SUNWSTACK:
|
|
549
|
case PT_SUNWSTACK:
|
|
549
|
type = "Stack segment";
|
|
550
|
type = "Stack segment";
|
|
550
|
break;
|
|
551
|
break;
|
|
551
|
case PT_LOPROC:
|
|
552
|
case PT_LOPROC:
|
|
552
|
type = "Start of processor-specific";
|
|
553
|
type = "Start of processor-specific";
|
|
553
|
break;
|
|
554
|
break;
|
|
554
|
case PT_HIPROC:
|
|
555
|
case PT_HIPROC:
|
|
555
|
type = "End of processor-specific";
|
|
556
|
type = "End of processor-specific";
|
|
556
|
break;
|
|
557
|
break;
|
|
557
|
default:
|
|
558
|
default:
|
|
558
|
type = "Unknow Section Type";
|
|
559
|
type = "Unknow Section Type";
|
|
559
|
break;
|
|
560
|
break;
|
|
560
|
}
|
|
561
|
}
|
|
561
|
}
|
|
562
|
}
|
|
562
|
}
|
|
563
|
}
|
|
563
|
|
|
564
|
|
|
564
|
return type;
|
|
565
|
return type;
|
|
565
|
}
|
|
566
|
}
|
|
566
|
|
|
567
|
|
|
567
|
|
|
568
|
|
|
568
|
qint64 ElfFile::getSegmentOffset(int index)
|
|
569
|
qint64 ElfFile::getSegmentOffset(int index)
|
|
569
|
{
|
|
570
|
{
|
|
570
|
int64_t Offset;
|
|
571
|
int64_t Offset;
|
|
571
|
if(this->e!=NULL)
|
|
572
|
if(this->e!=NULL)
|
|
572
|
{
|
|
573
|
{
|
|
573
|
if(index < this->Segments.count())
|
|
574
|
if(index < this->Segments.count())
|
|
574
|
{
|
|
575
|
{
|
|
575
|
Offset = (int64_t)this->Segments.at(index)->p_offset;
|
|
576
|
Offset = (int64_t)this->Segments.at(index)->p_offset;
|
|
576
|
}
|
|
577
|
}
|
|
577
|
}
|
|
578
|
}
|
|
578
|
return Offset;
|
|
579
|
return Offset;
|
|
579
|
}
|
|
580
|
}
|
|
580
|
|
|
581
|
|
|
581
|
|
|
582
|
|
|
582
|
qint64 ElfFile::getSegmentVaddr(int index)
|
|
583
|
qint64 ElfFile::getSegmentVaddr(int index)
|
|
583
|
{
|
|
584
|
{
|
|
584
|
int64_t Vaddr = 0;
|
|
585
|
int64_t Vaddr = 0;
|
|
585
|
if(this->e!=NULL)
|
|
586
|
if(this->e!=NULL)
|
|
586
|
{
|
|
587
|
{
|
|
587
|
if(index < this->Segments.count())
|
|
588
|
if(index < this->Segments.count())
|
|
588
|
{
|
|
589
|
{
|
|
589
|
Vaddr = (int64_t)this->Segments.at(index)->p_vaddr;
|
|
590
|
Vaddr = (int64_t)this->Segments.at(index)->p_vaddr;
|
|
590
|
}
|
|
591
|
}
|
|
591
|
}
|
|
592
|
}
|
|
592
|
return Vaddr;
|
|
593
|
return Vaddr;
|
|
593
|
}
|
|
594
|
}
|
|
594
|
|
|
595
|
|
|
595
|
|
|
596
|
|
|
596
|
qint64 ElfFile::getSegmentPaddr(int index)
|
|
597
|
qint64 ElfFile::getSegmentPaddr(int index)
|
|
597
|
{
|
|
598
|
{
|
|
598
|
int64_t Paddr=0;
|
|
599
|
int64_t Paddr=0;
|
|
599
|
if(this->e!=NULL)
|
|
600
|
if(this->e!=NULL)
|
|
600
|
{
|
|
601
|
{
|
|
601
|
if(index < this->Segments.count())
|
|
602
|
if(index < this->Segments.count())
|
|
602
|
{
|
|
603
|
{
|
|
603
|
Paddr = (int64_t)this->Segments.at(index)->p_paddr;
|
|
604
|
Paddr = (int64_t)this->Segments.at(index)->p_paddr;
|
|
604
|
}
|
|
605
|
}
|
|
605
|
}
|
|
606
|
}
|
|
606
|
return Paddr;
|
|
607
|
return Paddr;
|
|
607
|
}
|
|
608
|
}
|
|
608
|
|
|
609
|
|
|
609
|
qint64 ElfFile::getSectionPaddr(int index)
|
|
610
|
qint64 ElfFile::getSectionPaddr(int index)
|
|
610
|
{
|
|
611
|
{
|
|
611
|
int64_t Paddr=0;
|
|
612
|
int64_t Paddr=0;
|
|
612
|
if(this->e!=NULL)
|
|
613
|
if(this->e!=NULL)
|
|
613
|
{
|
|
614
|
{
|
|
614
|
if(index < this->sections.count())
|
|
615
|
if(index < this->sections.count())
|
|
615
|
{
|
|
616
|
{
|
|
616
|
Paddr = (int64_t)this->sections.at(index)->section_header->sh_addr;
|
|
617
|
Paddr = (int64_t)this->sections.at(index)->section_header->sh_addr;
|
|
617
|
}
|
|
618
|
}
|
|
618
|
}
|
|
619
|
}
|
|
619
|
return Paddr;
|
|
620
|
return Paddr;
|
|
620
|
}
|
|
621
|
}
|
|
621
|
|
|
622
|
|
|
622
|
|
|
623
|
|
|
623
|
qint64 ElfFile::getSegmentFilesz(int index)
|
|
624
|
qint64 ElfFile::getSegmentFilesz(int index)
|
|
624
|
{
|
|
625
|
{
|
|
625
|
int64_t FileSz=0;
|
|
626
|
int64_t FileSz=0;
|
|
626
|
if(this->e!=NULL)
|
|
627
|
if(this->e!=NULL)
|
|
627
|
{
|
|
628
|
{
|
|
628
|
if(index < this->Segments.count())
|
|
629
|
if(index < this->Segments.count())
|
|
629
|
{
|
|
630
|
{
|
|
630
|
FileSz = (int64_t)this->Segments.at(index)->p_filesz;
|
|
631
|
FileSz = (int64_t)this->Segments.at(index)->p_filesz;
|
|
631
|
}
|
|
632
|
}
|
|
632
|
}
|
|
633
|
}
|
|
633
|
return FileSz;
|
|
634
|
return FileSz;
|
|
634
|
}
|
|
635
|
}
|
|
635
|
|
|
636
|
|
|
636
|
qint64 ElfFile::getSectionDatasz(int index)
|
|
637
|
qint64 ElfFile::getSectionDatasz(int index)
|
|
637
|
{
|
|
638
|
{
|
|
638
|
int64_t DataSz=0;
|
|
639
|
int64_t DataSz=0;
|
|
639
|
if(this->e!=NULL)
|
|
640
|
if(this->e!=NULL)
|
|
640
|
{
|
|
641
|
{
|
|
641
|
if(index < this->sections.count())
|
|
642
|
if(index < this->sections.count())
|
|
642
|
{
|
|
643
|
{
|
|
643
|
DataSz = (int64_t)this->sections.at(index)->data->d_size;
|
|
644
|
DataSz = (int64_t)this->sections.at(index)->data->d_size;
|
|
644
|
}
|
|
645
|
}
|
|
645
|
}
|
|
646
|
}
|
|
646
|
return DataSz;
|
|
647
|
return DataSz;
|
|
647
|
}
|
|
648
|
}
|
|
648
|
|
|
649
|
|
|
649
|
bool ElfFile::getSectionData(int index, char **buffer)
|
|
650
|
bool ElfFile::getSectionData(int index, char **buffer)
|
|
650
|
{
|
|
651
|
{
|
|
651
|
if(this->e!=NULL)
|
|
652
|
if(this->e!=NULL)
|
|
652
|
{
|
|
653
|
{
|
|
653
|
if(index < this->sections.count())
|
|
654
|
if(index < this->sections.count())
|
|
654
|
{
|
|
655
|
{
|
|
655
|
*buffer = (char *)this->sections.at(index)->data->d_buf;
|
|
656
|
*buffer = (char *)this->sections.at(index)->data->d_buf;
|
|
656
|
return true;
|
|
657
|
return true;
|
|
657
|
}
|
|
658
|
}
|
|
658
|
}
|
|
659
|
}
|
|
659
|
return false;
|
|
660
|
return false;
|
|
660
|
}
|
|
661
|
}
|
|
661
|
|
|
662
|
|
|
662
|
|
|
663
|
|
|
663
|
qint64 ElfFile::getSegmentMemsz(int index)
|
|
664
|
qint64 ElfFile::getSegmentMemsz(int index)
|
|
664
|
{
|
|
665
|
{
|
|
665
|
int64_t MemSz=0;
|
|
666
|
int64_t MemSz=0;
|
|
666
|
if(this->e!=NULL)
|
|
667
|
if(this->e!=NULL)
|
|
667
|
{
|
|
668
|
{
|
|
668
|
if(index < this->Segments.count())
|
|
669
|
if(index < this->Segments.count())
|
|
669
|
{
|
|
670
|
{
|
|
670
|
MemSz = (int64_t)this->Segments.at(index)->p_memsz;
|
|
671
|
MemSz = (int64_t)this->Segments.at(index)->p_memsz;
|
|
671
|
}
|
|
672
|
}
|
|
672
|
}
|
|
673
|
}
|
|
673
|
return MemSz;
|
|
674
|
return MemSz;
|
|
674
|
}
|
|
675
|
}
|
|
675
|
|
|
676
|
|
|
676
|
qint64 ElfFile::getSectionMemsz(int index)
|
|
677
|
qint64 ElfFile::getSectionMemsz(int index)
|
|
677
|
{
|
|
678
|
{
|
|
678
|
int64_t MemSz=0;
|
|
679
|
int64_t MemSz=0;
|
|
679
|
if(this->e!=NULL)
|
|
680
|
if(this->e!=NULL)
|
|
680
|
{
|
|
681
|
{
|
|
681
|
if(index < this->sections.count())
|
|
682
|
if(index < this->sections.count())
|
|
682
|
{
|
|
683
|
{
|
|
683
|
MemSz = (int64_t)this->sections.at(index)->section_header->sh_size;
|
|
684
|
MemSz = (int64_t)this->sections.at(index)->section_header->sh_size;
|
|
684
|
}
|
|
685
|
}
|
|
685
|
}
|
|
686
|
}
|
|
686
|
return MemSz;
|
|
687
|
return MemSz;
|
|
687
|
}
|
|
688
|
}
|
|
688
|
|
|
689
|
|
|
689
|
|
|
690
|
|
|
690
|
QString ElfFile::getSegmentFlags(int index)
|
|
691
|
QString ElfFile::getSegmentFlags(int index)
|
|
691
|
{
|
|
692
|
{
|
|
692
|
QString flags("");
|
|
693
|
QString flags("");
|
|
693
|
if(this->e!=NULL)
|
|
694
|
if(this->e!=NULL)
|
|
694
|
{
|
|
695
|
{
|
|
695
|
if(index < this->Segments.count())
|
|
696
|
if(index < this->Segments.count())
|
|
696
|
{
|
|
697
|
{
|
|
697
|
if((this->Segments.at(index)->p_flags&PF_X) == PF_X)flags+="x";
|
|
698
|
if((this->Segments.at(index)->p_flags&PF_X) == PF_X)flags+="x";
|
|
698
|
if((this->Segments.at(index)->p_flags&PF_W) == PF_W)flags+="w";
|
|
699
|
if((this->Segments.at(index)->p_flags&PF_W) == PF_W)flags+="w";
|
|
699
|
if((this->Segments.at(index)->p_flags&PF_R) == PF_R)flags+="r";
|
|
700
|
if((this->Segments.at(index)->p_flags&PF_R) == PF_R)flags+="r";
|
|
700
|
if((this->Segments.at(index)->p_flags&PF_MASKOS) == PF_MASKOS)flags+=" OS-specific";
|
|
701
|
if((this->Segments.at(index)->p_flags&PF_MASKOS) == PF_MASKOS)flags+=" OS-specific";
|
|
701
|
if((this->Segments.at(index)->p_flags&PF_MASKPROC) == PF_MASKPROC)flags+=" Processor-specific";
|
|
702
|
if((this->Segments.at(index)->p_flags&PF_MASKPROC) == PF_MASKPROC)flags+=" Processor-specific";
|
|
702
|
}
|
|
703
|
}
|
|
703
|
}
|
|
704
|
}
|
|
704
|
return flags;
|
|
705
|
return flags;
|
|
705
|
}
|
|
706
|
}
|
|
706
|
|
|
707
|
|
|
707
|
|
|
708
|
|
|
708
|
QString ElfFile::getSectionName(int index)
|
|
709
|
QString ElfFile::getSectionName(int index)
|
|
709
|
{
|
|
710
|
{
|
|
710
|
char* nameChr = elf_strptr(this->e , this->shstrndx , this->sections.at(index)->section_header->sh_name);
|
|
711
|
char* nameChr = elf_strptr(this->e , this->shstrndx , this->sections.at(index)->section_header->sh_name);
|
|
711
|
return QString(nameChr);
|
|
712
|
return QString(nameChr);
|
|
712
|
}
|
|
713
|
}
|
|
713
|
|
|
714
|
|
|
714
|
|
|
715
|
|
|
715
|
void ElfFile::updateSections()
|
|
716
|
void ElfFile::updateSections()
|
|
716
|
{
|
|
717
|
{
|
|
717
|
for(int i=0;i<this->sections.count();i++)
|
|
718
|
for(int i=0;i<this->sections.count();i++)
|
|
718
|
{
|
|
719
|
{
|
|
719
|
delete this->sections.at(i);
|
|
720
|
delete this->sections.at(i);
|
|
720
|
}
|
|
721
|
}
|
|
721
|
this->sections.clear();
|
|
722
|
this->sections.clear();
|
|
722
|
this->scn = elf_nextscn (this->e , NULL );
|
|
723
|
this->scn = elf_nextscn (this->e , NULL );
|
|
723
|
this->SectionCount = 0;
|
|
724
|
this->SectionCount = 0;
|
|
724
|
while( this->scn != NULL )
|
|
725
|
while( this->scn != NULL )
|
|
725
|
{
|
|
726
|
{
|
|
726
|
GElf_Shdr* shdr = (GElf_Shdr*)malloc(sizeof(GElf_Shdr));
|
|
727
|
GElf_Shdr* shdr = (GElf_Shdr*)malloc(sizeof(GElf_Shdr));
|
|
727
|
gelf_getshdr ( this->scn , shdr );
|
|
728
|
gelf_getshdr ( this->scn , shdr );
|
|
728
|
Elf_Data* data = elf_getdata(this->scn, NULL);
|
|
729
|
Elf_Data* data = elf_getdata(this->scn, NULL);
|
|
729
|
this->sections.append(new Elf_Section(data,shdr));
|
|
730
|
this->sections.append(new Elf_Section(data,shdr));
|
|
730
|
this->SectionCount+=1;
|
|
731
|
this->SectionCount+=1;
|
|
731
|
this->scn = elf_nextscn(e , scn);
|
|
732
|
this->scn = elf_nextscn(e , scn);
|
|
732
|
}
|
|
733
|
}
|
|
733
|
}
|
|
734
|
}
|
|
734
|
|
|
735
|
|
|
735
|
|
|
736
|
|
|
736
|
void ElfFile::updateSegments()
|
|
737
|
void ElfFile::updateSegments()
|
|
737
|
{
|
|
738
|
{
|
|
738
|
elf_getphdrnum (this->e , &this->SegmentCount);
|
|
739
|
elf_getphdrnum (this->e , &this->SegmentCount);
|
|
739
|
for(int i=0;i<this->Segments.count();i++)
|
|
740
|
for(int i=0;i<this->Segments.count();i++)
|
|
740
|
{
|
|
741
|
{
|
|
741
|
free(this->Segments.at(i));
|
|
742
|
free(this->Segments.at(i));
|
|
742
|
}
|
|
743
|
}
|
|
743
|
this->Segments.clear();
|
|
744
|
this->Segments.clear();
|
|
744
|
for(int i=0;i<this->SegmentCount;i++)
|
|
745
|
for(int i=0;i<this->SegmentCount;i++)
|
|
745
|
{
|
|
746
|
{
|
|
746
|
GElf_Phdr* header=(GElf_Phdr*)malloc(sizeof(GElf_Phdr));
|
|
747
|
GElf_Phdr* header=(GElf_Phdr*)malloc(sizeof(GElf_Phdr));
|
|
747
|
gelf_getphdr (this->e , i , header );
|
|
748
|
gelf_getphdr (this->e , i , header );
|
|
748
|
this->Segments.append(header);
|
|
749
|
this->Segments.append(header);
|
|
749
|
}
|
|
750
|
}
|
|
750
|
}
|
|
751
|
}
|
|
751
|
|
|
752
|
|
|
752
|
void ElfFile::updateSymbols()
|
|
753
|
void ElfFile::updateSymbols()
|
|
753
|
{
|
|
754
|
{
|
|
|
|
|
755
|
for(int i=0;i<symbols.count();i++)
|
|
|
|
|
756
|
{
|
|
|
|
|
757
|
delete this->symbols.at(i);
|
|
|
|
|
758
|
}
|
|
|
|
|
759
|
this->symbols.clear();
|
|
|
|
|
760
|
updateSections(); //Useless in most case but safer to do it
|
|
|
|
|
761
|
for(int i=0;i<SectionCount;i++)
|
|
|
|
|
762
|
{
|
|
|
|
|
763
|
//First find Symbol table
|
|
|
|
|
764
|
if(this->getSectionName(i)==".symtab")
|
|
|
|
|
765
|
{
|
|
|
|
|
766
|
Elf_Section* sec = sections.at(i);
|
|
|
|
|
767
|
this->SymbolCount = sec->section_header->sh_size / sec->section_header->sh_entsize;
|
|
|
|
|
768
|
//Then list all symbols
|
|
|
|
|
769
|
for(int j=0;j<this->SymbolCount;j++)
|
|
|
|
|
770
|
{
|
|
|
|
|
771
|
GElf_Sym* esym = (GElf_Sym*)malloc(sizeof(GElf_Sym));
|
|
|
|
|
772
|
gelf_getsym(sec->data, j, esym);
|
|
|
|
|
773
|
QString name = elf_strptr(this->e,sec->section_header->sh_link,esym->st_name);
|
|
|
|
|
774
|
Elf_Symbol* sym = new Elf_Symbol(name,esym);
|
|
|
|
|
775
|
symbols.append(sym);
|
|
|
|
|
776
|
}
|
|
|
|
|
777
|
}
|
|
|
|
|
778
|
}
|
|
754
|
|
|
779
|
|
|
755
|
}
|
|
780
|
}
|
|
756
|
|
|
781
|
|
|
757
|
|
|
782
|
|
|
758
|
|
|
783
|
|
|
759
|
|
|
|
|
|
760
|
|
|
|
|
|
761
|
QString ElfFile::getSectionType(int index)
|
|
784
|
QString ElfFile::getSectionType(int index)
|
|
762
|
{
|
|
785
|
{
|
|
763
|
QString type("");
|
|
786
|
QString type("");
|
|
764
|
if(this->e!=NULL)
|
|
787
|
if(this->e!=NULL)
|
|
765
|
{
|
|
788
|
{
|
|
766
|
if(index < this->Segments.count())
|
|
789
|
if(index < this->Segments.count())
|
|
767
|
{
|
|
790
|
{
|
|
768
|
switch(this->Segments.at(index)->p_type)
|
|
791
|
switch(this->Segments.at(index)->p_type)
|
|
769
|
{
|
|
792
|
{
|
|
770
|
case SHT_NULL : type = "Section header table entry unused"; break;
|
|
793
|
case SHT_NULL : type = "Section header table entry unused"; break;
|
|
771
|
case SHT_PROGBITS : type = "Program data"; break;
|
|
794
|
case SHT_PROGBITS : type = "Program data"; break;
|
|
772
|
case SHT_SYMTAB : type = "Symbol table"; break;
|
|
795
|
case SHT_SYMTAB : type = "Symbol table"; break;
|
|
773
|
case SHT_STRTAB : type = "String table"; break;
|
|
796
|
case SHT_STRTAB : type = "String table"; break;
|
|
774
|
case SHT_RELA : type = "Relocation entries with addends"; break;
|
|
797
|
case SHT_RELA : type = "Relocation entries with addends"; break;
|
|
775
|
case SHT_HASH : type = "Symbol hash table"; break;
|
|
798
|
case SHT_HASH : type = "Symbol hash table"; break;
|
|
776
|
case SHT_DYNAMIC : type = "Dynamic linking information"; break;
|
|
799
|
case SHT_DYNAMIC : type = "Dynamic linking information"; break;
|
|
777
|
case SHT_NOTE : type = "Notes"; break;
|
|
800
|
case SHT_NOTE : type = "Notes"; break;
|
|
778
|
case SHT_NOBITS :type = "Program space with no data (bss)"; break;
|
|
801
|
case SHT_NOBITS :type = "Program space with no data (bss)"; break;
|
|
779
|
case SHT_REL :type = "Relocation entries, no addends"; break;
|
|
802
|
case SHT_REL :type = "Relocation entries, no addends"; break;
|
|
780
|
case SHT_SHLIB : type = "Reserved"; break;
|
|
803
|
case SHT_SHLIB : type = "Reserved"; break;
|
|
781
|
case SHT_DYNSYM : type = "Dynamic linker symbol table"; break;
|
|
804
|
case SHT_DYNSYM : type = "Dynamic linker symbol table"; break;
|
|
782
|
case SHT_INIT_ARRAY : type = "Array of constructors"; break;
|
|
805
|
case SHT_INIT_ARRAY : type = "Array of constructors"; break;
|
|
783
|
case SHT_FINI_ARRAY : type = "Array of destructors"; break;
|
|
806
|
case SHT_FINI_ARRAY : type = "Array of destructors"; break;
|
|
784
|
case SHT_PREINIT_ARRAY : type = "Array of pre-constructors"; break;
|
|
807
|
case SHT_PREINIT_ARRAY : type = "Array of pre-constructors"; break;
|
|
785
|
case SHT_GROUP : type = "Section group"; break;
|
|
808
|
case SHT_GROUP : type = "Section group"; break;
|
|
786
|
case SHT_SYMTAB_SHNDX : type = "Extended section indeces"; break;
|
|
809
|
case SHT_SYMTAB_SHNDX : type = "Extended section indeces"; break;
|
|
787
|
case SHT_NUM : type = "Number of defined types. "; break;
|
|
810
|
case SHT_NUM : type = "Number of defined types. "; break;
|
|
788
|
case SHT_LOOS : type = "Start OS-specific. "; break;
|
|
811
|
case SHT_LOOS : type = "Start OS-specific. "; break;
|
|
789
|
case SHT_LOSUNW : type = "Sun-specific low bound. "; break;
|
|
812
|
case SHT_LOSUNW : type = "Sun-specific low bound. "; break;
|
|
790
|
case SHT_SUNW_COMDAT : type = " "; break;
|
|
813
|
case SHT_SUNW_COMDAT : type = " "; break;
|
|
791
|
case SHT_SUNW_syminfo : type = " "; break;
|
|
814
|
case SHT_SUNW_syminfo : type = " "; break;
|
|
792
|
case SHT_GNU_verdef : type = "Version definition section. "; break;
|
|
815
|
case SHT_GNU_verdef : type = "Version definition section. "; break;
|
|
793
|
case SHT_GNU_verneed : type = "Version needs section. "; break;
|
|
816
|
case SHT_GNU_verneed : type = "Version needs section. "; break;
|
|
794
|
case SHT_GNU_versym : type = "Version symbol table. "; break;
|
|
817
|
case SHT_GNU_versym : type = "Version symbol table. "; break;
|
|
795
|
case SHT_LOPROC : type = "Start of processor-specific"; break;
|
|
818
|
case SHT_LOPROC : type = "Start of processor-specific"; break;
|
|
796
|
case SHT_HIPROC : type = "End of processor-specific"; break;
|
|
819
|
case SHT_HIPROC : type = "End of processor-specific"; break;
|
|
797
|
case SHT_HIUSER : type = "End of application-specific"; break;
|
|
820
|
case SHT_HIUSER : type = "End of application-specific"; break;
|
|
798
|
}
|
|
821
|
}
|
|
799
|
}
|
|
822
|
}
|
|
800
|
}
|
|
823
|
}
|
|
801
|
return type;
|
|
824
|
return type;
|
|
802
|
}
|
|
825
|
}
|
|
803
|
|
|
826
|
|
|
804
|
bool ElfFile::isElf(const QString &File)
|
|
827
|
bool ElfFile::isElf(const QString &File)
|
|
805
|
{
|
|
828
|
{
|
|
806
|
int file =0;
|
|
829
|
int file =0;
|
|
807
|
#ifdef _ELF_WINDOWS_
|
|
830
|
#ifdef _ELF_WINDOWS_
|
|
808
|
file = open(File.toStdString().c_str(),O_RDONLY|O_BINARY ,0);
|
|
831
|
file = open(File.toStdString().c_str(),O_RDONLY|O_BINARY ,0);
|
|
809
|
#else
|
|
832
|
#else
|
|
810
|
file = open(File.toStdString().c_str(),O_RDONLY ,0);
|
|
833
|
file = open(File.toStdString().c_str(),O_RDONLY ,0);
|
|
811
|
#endif
|
|
834
|
#endif
|
|
812
|
char Magic[4];
|
|
835
|
char Magic[4];
|
|
813
|
if(file!=-1)
|
|
836
|
if(file!=-1)
|
|
814
|
{
|
|
837
|
{
|
|
815
|
read(file,Magic,4);
|
|
838
|
read(file,Magic,4);
|
|
816
|
close(file);
|
|
839
|
close(file);
|
|
817
|
if(Magic[0]==0x7f && Magic[1]==0x45 && Magic[2]==0x4c && Magic[3]==0x46)
|
|
840
|
if(Magic[0]==0x7f && Magic[1]==0x45 && Magic[2]==0x4c && Magic[3]==0x46)
|
|
818
|
{
|
|
841
|
{
|
|
819
|
return true;
|
|
842
|
return true;
|
|
820
|
}
|
|
843
|
}
|
|
821
|
}
|
|
844
|
}
|
|
822
|
return false;
|
|
845
|
return false;
|
|
823
|
}
|
|
846
|
}
|