##// END OF EJS Templates
Fixed Win32 build but lppmonplot python wrapper still broken!
Jeandet Alexis -
r49:d9c54528bd30 Win32 build Ok default
parent child
Show More
@@ -1,1068 +1,1068
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 #include "srec/srecfile.h"
25 #include "srec/srecfile.h"
26 #include <stdint.h>
26
27
27 ElfFile::ElfFile()
28 ElfFile::ElfFile()
28 :abstractBinFile()
29 :abstractBinFile()
29 {
30 {
30 this->opened = false;
31 this->opened = false;
31 this->type_elf = false;
32 this->type_elf = false;
32 this->elfFile = (int)NULL;
33 this->elfFile = (int)NULL;
33 this->e = NULL;
34 this->e = NULL;
34 }
35 }
35
36
36 ElfFile::ElfFile(const QString &File)
37 ElfFile::ElfFile(const QString &File)
37 :abstractBinFile()
38 :abstractBinFile()
38 {
39 {
39 this->opened = false;
40 this->opened = false;
40 this->type_elf = false;
41 this->type_elf = false;
41 this->elfFile = (int)NULL;
42 this->elfFile = (int)NULL;
42 this->e = NULL;
43 this->e = NULL;
43 this->p_fileName = File;
44 this->p_fileName = File;
44 openFile(File);
45 openFile(File);
45 }
46 }
46
47
47 ElfFile::~ElfFile()
48 ElfFile::~ElfFile()
48 {
49 {
49 closeFile();
50 closeFile();
50 if(scn)free(scn);
51 if(scn)free(scn);
51 if(data)free(data);
52 if(data)free(data);
52 for(int i=0;i<this->sections.count();i++)
53 for(int i=0;i<this->sections.count();i++)
53 {
54 {
54 delete this->sections.at(i);
55 delete this->sections.at(i);
55 }
56 }
56 this->sections.clear();
57 this->sections.clear();
57 for(int i=0;i<this->Segments.count();i++)
58 for(int i=0;i<this->Segments.count();i++)
58 {
59 {
59 free(this->Segments.at(i));
60 free(this->Segments.at(i));
60 }
61 }
61 this->Segments.clear();
62 this->Segments.clear();
62 for(int i=0;i<symbols.count();i++)
63 for(int i=0;i<symbols.count();i++)
63 {
64 {
64 delete this->symbols.at(i);
65 delete this->symbols.at(i);
65 }
66 }
66 this->symbols.clear();
67 this->symbols.clear();
67 }
68 }
68
69
69 bool ElfFile::openFile(const QString &File)
70 bool ElfFile::openFile(const QString &File)
70 {
71 {
71 this->p_fileName = File;
72 this->p_fileName = File;
72 this->closeFile();
73 this->closeFile();
73 if(elf_version(EV_CURRENT)==EV_NONE)return 0;
74 if(elf_version(EV_CURRENT)==EV_NONE)return 0;
74 #ifdef _ELF_WINDOWS_
75 #ifdef _ELF_WINDOWS_
75 this->elfFile = open(File.toStdString().c_str(),O_RDONLY|O_BINARY ,0);
76 this->elfFile = open(File.toStdString().c_str(),O_RDONLY|O_BINARY ,0);
76 #else
77 #else
77 this->elfFile = open(File.toStdString().c_str(),O_RDONLY ,0);
78 this->elfFile = open(File.toStdString().c_str(),O_RDONLY ,0);
78 #endif
79 #endif
79 if(this->elfFile==(int)NULL)return 0;
80 if(this->elfFile==(int)NULL)return 0;
80 this->e = elf_begin(this->elfFile,ELF_C_READ,NULL);
81 this->e = elf_begin(this->elfFile,ELF_C_READ,NULL);
81 if(this->e==NULL)return 0;
82 if(this->e==NULL)return 0;
82 this->ek = elf_kind(this->e);
83 this->ek = elf_kind(this->e);
83 gelf_getehdr (this->e, &this->ehdr );
84 gelf_getehdr (this->e, &this->ehdr );
84 elf_getshdrstrndx (this->e, &this->shstrndx);
85 elf_getshdrstrndx (this->e, &this->shstrndx);
85 this->updateSegments();
86 this->updateSegments();
86 this->updateSections();
87 this->updateSections();
87 this->updateSymbols();
88 this->updateSymbols();
88 this->opened = true;
89 this->opened = true;
89 return 1;
90 return 1;
90 }
91 }
91
92
92 bool ElfFile::isopened()
93 bool ElfFile::isopened()
93 {
94 {
94 return this->opened;
95 return this->opened;
95 }
96 }
96
97
97 int ElfFile::closeFile()
98 int ElfFile::closeFile()
98 {
99 {
99 if(this->elfFile!=(int)NULL)
100 if(this->elfFile!=(int)NULL)
100 {
101 {
101 if(this->e!=NULL)
102 if(this->e!=NULL)
102 {
103 {
103 elf_end(this->e);
104 elf_end(this->e);
104 this->e = NULL;
105 this->e = NULL;
105 }
106 }
106 close(this->elfFile);
107 close(this->elfFile);
107 this->elfFile = (int)NULL;
108 this->elfFile = (int)NULL;
108 }
109 }
109 this->opened = false;
110 this->opened = false;
110 return 0;
111 return 0;
111 }
112 }
112
113
113
114
114 QList<codeFragment*> ElfFile::getFragments(QStringList fragmentList)
115 QList<codeFragment*> ElfFile::getFragments(QStringList fragmentList)
115 {
116 {
116 QList<codeFragment*> fragments;
117 QList<codeFragment*> fragments;
117 if (isopened())
118 if (isopened())
118 {
119 {
119 for(int i =0;i<fragmentList.count();i++)
120 for(int i =0;i<fragmentList.count();i++)
120 {
121 {
121 fragments.append(getFragment(fragmentList.at(i)));
122 fragments.append(getFragment(fragmentList.at(i)));
122 }
123 }
123 }
124 }
124 return fragments;
125 return fragments;
125 }
126 }
126
127
127 QList<codeFragment*> ElfFile::getFragments()
128 QList<codeFragment*> ElfFile::getFragments()
128 {
129 {
129 return getFragments(QStringList()<<".data"<<".text");
130 return getFragments(QStringList()<<".data"<<".text");
130 }
131 }
131
132
132 codeFragment *ElfFile::getFragment(const QString &name)
133 codeFragment *ElfFile::getFragment(const QString &name)
133 {
134 {
134 codeFragment* fragment= new codeFragment();
135 codeFragment* fragment= new codeFragment();
135 for(int i=0;i<getSectionCount();i++)
136 for(int i=0;i<getSectionCount();i++)
136 {
137 {
137 if(getSectionName(i) == name)
138 if(getSectionName(i) == name)
138 {
139 {
139 fragment->data =NULL;
140 fragment->data =NULL;
140 fragment->size = getSectionDatasz(i);
141 fragment->size = getSectionDatasz(i);
141 fragment->address = getSectionPaddr(i);
142 fragment->address = getSectionPaddr(i);
142 getSectionData(i,&fragment->data);
143 getSectionData(i,&fragment->data);
143 }
144 }
144 }
145 }
145 return fragment;
146 return fragment;
146 }
147 }
147
148
148
149
149
150
150
151
151
152
152
153
153
154
154 QString elfresolveMachine(Elf64_Half e_machine)
155 QString elfresolveMachine(Elf64_Half e_machine)
155 {
156 {
156 QString machineName;
157 QString machineName;
157 //Update from with bash script don't write it by yourself!
158 //Update from with bash script don't write it by yourself!
158 switch(e_machine)
159 switch(e_machine)
159 {
160 {
160 case EM_NONE:
161 case EM_NONE:
161 machineName = " No machine ";
162 machineName = " No machine ";
162 break;
163 break;
163 case EM_M32:
164 case EM_M32:
164 machineName = " AT&T WE 32100 ";
165 machineName = " AT&T WE 32100 ";
165 break;
166 break;
166 case EM_SPARC:
167 case EM_SPARC:
167 machineName = " SUN SPARC ";
168 machineName = " SUN SPARC ";
168 break;
169 break;
169 case EM_386:
170 case EM_386:
170 machineName = " Intel 80386 ";
171 machineName = " Intel 80386 ";
171 break;
172 break;
172 case EM_68K:
173 case EM_68K:
173 machineName = " Motorola m68k family ";
174 machineName = " Motorola m68k family ";
174 break;
175 break;
175 case EM_88K:
176 case EM_88K:
176 machineName = " Motorola m88k family ";
177 machineName = " Motorola m88k family ";
177 break;
178 break;
178 case EM_860:
179 case EM_860:
179 machineName = " Intel 80860 ";
180 machineName = " Intel 80860 ";
180 break;
181 break;
181 case EM_MIPS:
182 case EM_MIPS:
182 machineName = " MIPS R3000 big-endian ";
183 machineName = " MIPS R3000 big-endian ";
183 break;
184 break;
184 case EM_S370:
185 case EM_S370:
185 machineName = " IBM System/370 ";
186 machineName = " IBM System/370 ";
186 break;
187 break;
187 case EM_MIPS_RS3_LE:
188 case EM_MIPS_RS3_LE:
188 machineName = " MIPS R3000 little-endian ";
189 machineName = " MIPS R3000 little-endian ";
189 break;
190 break;
190 case EM_PARISC:
191 case EM_PARISC:
191 machineName = " HPPA ";
192 machineName = " HPPA ";
192 break;
193 break;
193 case EM_VPP500:
194 case EM_VPP500:
194 machineName = " Fujitsu VPP500 ";
195 machineName = " Fujitsu VPP500 ";
195 break;
196 break;
196 case EM_SPARC32PLUS:
197 case EM_SPARC32PLUS:
197 machineName = " Sun's \"v8plus\" ";
198 machineName = " Sun's \"v8plus\" ";
198 break;
199 break;
199 case EM_960:
200 case EM_960:
200 machineName = " Intel 80960 ";
201 machineName = " Intel 80960 ";
201 break;
202 break;
202 case EM_PPC:
203 case EM_PPC:
203 machineName = " PowerPC ";
204 machineName = " PowerPC ";
204 break;
205 break;
205 case EM_PPC64:
206 case EM_PPC64:
206 machineName = " PowerPC 64-bit ";
207 machineName = " PowerPC 64-bit ";
207 break;
208 break;
208 case EM_S390:
209 case EM_S390:
209 machineName = " IBM S390 ";
210 machineName = " IBM S390 ";
210 break;
211 break;
211 case EM_V800:
212 case EM_V800:
212 machineName = " NEC V800 series ";
213 machineName = " NEC V800 series ";
213 break;
214 break;
214 case EM_FR20:
215 case EM_FR20:
215 machineName = " Fujitsu FR20 ";
216 machineName = " Fujitsu FR20 ";
216 break;
217 break;
217 case EM_RH32:
218 case EM_RH32:
218 machineName = " TRW RH-32 ";
219 machineName = " TRW RH-32 ";
219 break;
220 break;
220 case EM_RCE:
221 case EM_RCE:
221 machineName = " Motorola RCE ";
222 machineName = " Motorola RCE ";
222 break;
223 break;
223 case EM_ARM:
224 case EM_ARM:
224 machineName = " ARM ";
225 machineName = " ARM ";
225 break;
226 break;
226 case EM_FAKE_ALPHA:
227 case EM_FAKE_ALPHA:
227 machineName = " Digital Alpha ";
228 machineName = " Digital Alpha ";
228 break;
229 break;
229 case EM_SH:
230 case EM_SH:
230 machineName = " Hitachi SH ";
231 machineName = " Hitachi SH ";
231 break;
232 break;
232 case EM_SPARCV9:
233 case EM_SPARCV9:
233 machineName = " SPARC v9 64-bit ";
234 machineName = " SPARC v9 64-bit ";
234 break;
235 break;
235 case EM_TRICORE:
236 case EM_TRICORE:
236 machineName = " Siemens Tricore ";
237 machineName = " Siemens Tricore ";
237 break;
238 break;
238 case EM_ARC:
239 case EM_ARC:
239 machineName = " Argonaut RISC Core ";
240 machineName = " Argonaut RISC Core ";
240 break;
241 break;
241 case EM_H8_300:
242 case EM_H8_300:
242 machineName = " Hitachi H8/300 ";
243 machineName = " Hitachi H8/300 ";
243 break;
244 break;
244 case EM_H8_300H:
245 case EM_H8_300H:
245 machineName = " Hitachi H8/300H ";
246 machineName = " Hitachi H8/300H ";
246 break;
247 break;
247 case EM_H8S:
248 case EM_H8S:
248 machineName = " Hitachi H8S ";
249 machineName = " Hitachi H8S ";
249 break;
250 break;
250 case EM_H8_500:
251 case EM_H8_500:
251 machineName = " Hitachi H8/500 ";
252 machineName = " Hitachi H8/500 ";
252 break;
253 break;
253 case EM_IA_64:
254 case EM_IA_64:
254 machineName = " Intel Merced ";
255 machineName = " Intel Merced ";
255 break;
256 break;
256 case EM_MIPS_X:
257 case EM_MIPS_X:
257 machineName = " Stanford MIPS-X ";
258 machineName = " Stanford MIPS-X ";
258 break;
259 break;
259 case EM_COLDFIRE:
260 case EM_COLDFIRE:
260 machineName = " Motorola Coldfire ";
261 machineName = " Motorola Coldfire ";
261 break;
262 break;
262 case EM_68HC12:
263 case EM_68HC12:
263 machineName = " Motorola M68HC12 ";
264 machineName = " Motorola M68HC12 ";
264 break;
265 break;
265 case EM_MMA:
266 case EM_MMA:
266 machineName = " Fujitsu MMA Multimedia Accelerator";
267 machineName = " Fujitsu MMA Multimedia Accelerator";
267 break;
268 break;
268 case EM_PCP:
269 case EM_PCP:
269 machineName = " Siemens PCP ";
270 machineName = " Siemens PCP ";
270 break;
271 break;
271 case EM_NCPU:
272 case EM_NCPU:
272 machineName = " Sony nCPU embeeded RISC ";
273 machineName = " Sony nCPU embeeded RISC ";
273 break;
274 break;
274 case EM_NDR1:
275 case EM_NDR1:
275 machineName = " Denso NDR1 microprocessor ";
276 machineName = " Denso NDR1 microprocessor ";
276 break;
277 break;
277 case EM_STARCORE:
278 case EM_STARCORE:
278 machineName = " Motorola Start*Core processor ";
279 machineName = " Motorola Start*Core processor ";
279 break;
280 break;
280 case EM_ME16:
281 case EM_ME16:
281 machineName = " Toyota ME16 processor ";
282 machineName = " Toyota ME16 processor ";
282 break;
283 break;
283 case EM_ST100:
284 case EM_ST100:
284 machineName = " STMicroelectronic ST100 processor ";
285 machineName = " STMicroelectronic ST100 processor ";
285 break;
286 break;
286 case EM_TINYJ:
287 case EM_TINYJ:
287 machineName = " Advanced Logic Corp. Tinyj emb.fam";
288 machineName = " Advanced Logic Corp. Tinyj emb.fam";
288 break;
289 break;
289 case EM_X86_64:
290 case EM_X86_64:
290 machineName = " AMD x86-64 architecture ";
291 machineName = " AMD x86-64 architecture ";
291 break;
292 break;
292 case EM_PDSP:
293 case EM_PDSP:
293 machineName = " Sony DSP Processor ";
294 machineName = " Sony DSP Processor ";
294 break;
295 break;
295 case EM_FX66:
296 case EM_FX66:
296 machineName = " Siemens FX66 microcontroller ";
297 machineName = " Siemens FX66 microcontroller ";
297 break;
298 break;
298 case EM_ST9PLUS:
299 case EM_ST9PLUS:
299 machineName = " STMicroelectronics ST9+ 8/16 mc ";
300 machineName = " STMicroelectronics ST9+ 8/16 mc ";
300 break;
301 break;
301 case EM_ST7:
302 case EM_ST7:
302 machineName = " STmicroelectronics ST7 8 bit mc ";
303 machineName = " STmicroelectronics ST7 8 bit mc ";
303 break;
304 break;
304 case EM_68HC16:
305 case EM_68HC16:
305 machineName = " Motorola MC68HC16 microcontroller ";
306 machineName = " Motorola MC68HC16 microcontroller ";
306 break;
307 break;
307 case EM_68HC11:
308 case EM_68HC11:
308 machineName = " Motorola MC68HC11 microcontroller ";
309 machineName = " Motorola MC68HC11 microcontroller ";
309 break;
310 break;
310 case EM_68HC08:
311 case EM_68HC08:
311 machineName = " Motorola MC68HC08 microcontroller ";
312 machineName = " Motorola MC68HC08 microcontroller ";
312 break;
313 break;
313 case EM_68HC05:
314 case EM_68HC05:
314 machineName = " Motorola MC68HC05 microcontroller ";
315 machineName = " Motorola MC68HC05 microcontroller ";
315 break;
316 break;
316 case EM_SVX:
317 case EM_SVX:
317 machineName = " Silicon Graphics SVx ";
318 machineName = " Silicon Graphics SVx ";
318 break;
319 break;
319 case EM_ST19:
320 case EM_ST19:
320 machineName = " STMicroelectronics ST19 8 bit mc ";
321 machineName = " STMicroelectronics ST19 8 bit mc ";
321 break;
322 break;
322 case EM_VAX:
323 case EM_VAX:
323 machineName = " Digital VAX ";
324 machineName = " Digital VAX ";
324 break;
325 break;
325 case EM_CRIS:
326 case EM_CRIS:
326 machineName = " Axis Communications 32-bit embedded processor ";
327 machineName = " Axis Communications 32-bit embedded processor ";
327 break;
328 break;
328 case EM_JAVELIN:
329 case EM_JAVELIN:
329 machineName = " Infineon Technologies 32-bit embedded processor ";
330 machineName = " Infineon Technologies 32-bit embedded processor ";
330 break;
331 break;
331 case EM_FIREPATH:
332 case EM_FIREPATH:
332 machineName = " Element 14 64-bit DSP Processor ";
333 machineName = " Element 14 64-bit DSP Processor ";
333 break;
334 break;
334 case EM_ZSP:
335 case EM_ZSP:
335 machineName = " LSI Logic 16-bit DSP Processor ";
336 machineName = " LSI Logic 16-bit DSP Processor ";
336 break;
337 break;
337 case EM_MMIX:
338 case EM_MMIX:
338 machineName = " Donald Knuth's educational 64-bit processor ";
339 machineName = " Donald Knuth's educational 64-bit processor ";
339 break;
340 break;
340 case EM_HUANY:
341 case EM_HUANY:
341 machineName = " Harvard University machine-independent object files ";
342 machineName = " Harvard University machine-independent object files ";
342 break;
343 break;
343 case EM_PRISM:
344 case EM_PRISM:
344 machineName = " SiTera Prism ";
345 machineName = " SiTera Prism ";
345 break;
346 break;
346 case EM_AVR:
347 case EM_AVR:
347 machineName = " Atmel AVR 8-bit microcontroller ";
348 machineName = " Atmel AVR 8-bit microcontroller ";
348 break;
349 break;
349 case EM_FR30:
350 case EM_FR30:
350 machineName = " Fujitsu FR30 ";
351 machineName = " Fujitsu FR30 ";
351 break;
352 break;
352 case EM_D10V:
353 case EM_D10V:
353 machineName = " Mitsubishi D10V ";
354 machineName = " Mitsubishi D10V ";
354 break;
355 break;
355 case EM_D30V:
356 case EM_D30V:
356 machineName = " Mitsubishi D30V ";
357 machineName = " Mitsubishi D30V ";
357 break;
358 break;
358 case EM_V850:
359 case EM_V850:
359 machineName = " NEC v850 ";
360 machineName = " NEC v850 ";
360 break;
361 break;
361 case EM_M32R:
362 case EM_M32R:
362 machineName = " Mitsubishi M32R ";
363 machineName = " Mitsubishi M32R ";
363 break;
364 break;
364 case EM_MN10300:
365 case EM_MN10300:
365 machineName = " Matsushita MN10300 ";
366 machineName = " Matsushita MN10300 ";
366 break;
367 break;
367 case EM_MN10200:
368 case EM_MN10200:
368 machineName = " Matsushita MN10200 ";
369 machineName = " Matsushita MN10200 ";
369 break;
370 break;
370 case EM_PJ:
371 case EM_PJ:
371 machineName = " picoJava ";
372 machineName = " picoJava ";
372 break;
373 break;
373 case EM_OPENRISC:
374 case EM_OPENRISC:
374 machineName = " OpenRISC 32-bit embedded processor ";
375 machineName = " OpenRISC 32-bit embedded processor ";
375 break;
376 break;
376 case EM_ARC_A5:
377 case EM_ARC_A5:
377 machineName = " ARC Cores Tangent-A5 ";
378 machineName = " ARC Cores Tangent-A5 ";
378 break;
379 break;
379 case EM_XTENSA:
380 case EM_XTENSA:
380 machineName = " Tensilica Xtensa Architecture ";
381 machineName = " Tensilica Xtensa Architecture ";
381 break;
382 break;
382 case EM_AARCH64:
383 case EM_AARCH64:
383 machineName = " ARM AARCH64 ";
384 machineName = " ARM AARCH64 ";
384 break;
385 break;
385 case EM_TILEPRO:
386 case EM_TILEPRO:
386 machineName = " Tilera TILEPro ";
387 machineName = " Tilera TILEPro ";
387 break;
388 break;
388 case EM_MICROBLAZE:
389 case EM_MICROBLAZE:
389 machineName = " Xilinx MicroBlaze ";
390 machineName = " Xilinx MicroBlaze ";
390 break;
391 break;
391 case EM_TILEGX:
392 case EM_TILEGX:
392 machineName = " Tilera TILE-Gx ";
393 machineName = " Tilera TILE-Gx ";
393 break;
394 break;
394 case EM_NUM:
395 case EM_NUM:
395 machineName = "";
396 machineName = "";
396 break;
397 break;
397 default:
398 default:
398 machineName ="Unknow Machine";
399 machineName ="Unknow Machine";
399 break;
400 break;
400 }
401 }
401 return machineName;
402 return machineName;
402 }
403 }
403
404
404
405
405
406
406
407
407 QString ElfFile::getClass()
408 QString ElfFile::getClass()
408 {
409 {
409 if(this->e!=NULL)
410 if(this->e!=NULL)
410 {
411 {
411 int eclass = gelf_getclass(this->e);
412 int eclass = gelf_getclass(this->e);
412 if(eclass==ELFCLASS32)return "ELF32";
413 if(eclass==ELFCLASS32)return "ELF32";
413 if(eclass==ELFCLASS64)return "ELF64";
414 if(eclass==ELFCLASS64)return "ELF64";
414 }
415 }
415 return "none";
416 return "none";
416 }
417 }
417
418
418
419
419 bool ElfFile::iself()
420 bool ElfFile::iself()
420 {
421 {
421 return (this->getType()!="Unknow");
422 return (this->getType()!="Unknow");
422 }
423 }
423
424
424 QString ElfFile::getArchitecture()
425 QString ElfFile::getArchitecture()
425 {
426 {
426 if(this->e!=NULL)
427 if(this->e!=NULL)
427 {
428 {
428 return elfresolveMachine(this->ehdr.e_machine);
429 return elfresolveMachine(this->ehdr.e_machine);
429 }
430 }
430 return "";
431 return "";
431 }
432 }
432
433
433
434
434 QString ElfFile::getType()
435 QString ElfFile::getType()
435 {
436 {
436 QString kind("");
437 QString kind("");
437 if(this->e!=NULL)
438 if(this->e!=NULL)
438 {
439 {
439 switch(this->ek)
440 switch(this->ek)
440 {
441 {
441 case ELF_K_AR:
442 case ELF_K_AR:
442 kind = "Archive";
443 kind = "Archive";
443 break;
444 break;
444 case ELF_K_ELF:
445 case ELF_K_ELF:
445 kind = "Elf";
446 kind = "Elf";
446 break;
447 break;
447 case ELF_K_COFF:
448 case ELF_K_COFF:
448 kind = "COFF";
449 kind = "COFF";
449 break;
450 break;
450 case ELF_K_NUM:
451 case ELF_K_NUM:
451 kind = "NUM";
452 kind = "NUM";
452 break;
453 break;
453 case ELF_K_NONE:
454 case ELF_K_NONE:
454 kind = "Data";
455 kind = "Data";
455 break;
456 break;
456 default:
457 default:
457 kind = "Unknow";
458 kind = "Unknow";
458 break;
459 break;
459 }
460 }
460 }
461 }
461 return kind;
462 return kind;
462 }
463 }
463
464
464 QString ElfFile::getEndianness()
465 QString ElfFile::getEndianness()
465 {
466 {
466 if(this->e!=NULL)
467 if(this->e!=NULL)
467 {
468 {
468 if(this->ehdr.e_ident[EI_DATA]==ELFDATA2LSB)return "2's complement, little endian";
469 if(this->ehdr.e_ident[EI_DATA]==ELFDATA2LSB)return "2's complement, little endian";
469 if(this->ehdr.e_ident[EI_DATA]==ELFDATA2MSB)return "2's complement, big endian";
470 if(this->ehdr.e_ident[EI_DATA]==ELFDATA2MSB)return "2's complement, big endian";
470 }
471 }
471 return "none";
472 return "none";
472 }
473 }
473
474
474 QString ElfFile::getABI()
475 QString ElfFile::getABI()
475 {
476 {
476 if(this->e!=NULL)
477 if(this->e!=NULL)
477 {
478 {
478 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_NONE)return "UNIX System V ABI";
479 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_NONE)return "UNIX System V ABI";
479 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_SYSV)return "Alias";
480 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_SYSV)return "Alias";
480 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_HPUX)return "HP-UX";
481 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_HPUX)return "HP-UX";
481 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_NETBSD)return "NetBSD";
482 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_NETBSD)return "NetBSD";
482 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_GNU)return "Object uses GNU ELF extensions";
483 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_LINUX)return "Object uses GNU ELF extensions";
483 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_LINUX)return "Compatibility alias";
484 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_SOLARIS)return "Sun Solaris";
484 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_SOLARIS)return "Sun Solaris";
485 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_AIX)return "IBM AIX";
485 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_AIX)return "IBM AIX";
486 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_IRIX)return "SGI Irix";
486 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_IRIX)return "SGI Irix";
487 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_FREEBSD)return "FreeBSD";
487 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_FREEBSD)return "FreeBSD";
488 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_TRU64)return "Compaq TRU64 UNIX";
488 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_TRU64)return "Compaq TRU64 UNIX";
489 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_MODESTO)return " Novell Modesto";
489 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_MODESTO)return " Novell Modesto";
490 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_OPENBSD)return "OpenBSD";
490 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_OPENBSD)return "OpenBSD";
491 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_ARM_AEABI)return "ARM EABI";
491 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_ARM_AEABI)return "ARM EABI";
492 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_ARM)return "ARM";
492 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_ARM)return "ARM";
493 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_STANDALONE)return "Standalone (embedded) application";
493 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_STANDALONE)return "Standalone (embedded) application";
494 }
494 }
495 return "none";
495 return "none";
496 }
496 }
497
497
498
498
499 qint64 ElfFile::getVersion()
499 qint64 ElfFile::getVersion()
500 {
500 {
501 if(this->e!=NULL)
501 if(this->e!=NULL)
502 {
502 {
503 return this->ehdr.e_version;
503 return this->ehdr.e_version;
504 }
504 }
505 return -1;
505 return -1;
506 }
506 }
507
507
508 qint64 ElfFile::getEntryPointAddress()
508 qint64 ElfFile::getEntryPointAddress()
509 {
509 {
510 if(this->e!=NULL)
510 if(this->e!=NULL)
511 {
511 {
512 return this->ehdr.e_entry;
512 return this->ehdr.e_entry;
513 }
513 }
514 return -1;
514 return -1;
515 }
515 }
516
516
517
517
518 int ElfFile::getSectionCount()
518 int ElfFile::getSectionCount()
519 {
519 {
520 return (int)this->SectionCount;
520 return (int)this->SectionCount;
521 }
521 }
522
522
523 int ElfFile::getSymbolCount()
523 int ElfFile::getSymbolCount()
524 {
524 {
525 return (int)this->SymbolCount;
525 return (int)this->SymbolCount;
526 }
526 }
527
527
528
528
529 int ElfFile::getSegmentCount()
529 int ElfFile::getSegmentCount()
530 {
530 {
531 return (int)this->SegmentCount;
531 return (int)this->SegmentCount;
532 }
532 }
533
533
534
534
535 QString ElfFile::getSegmentType(int index)
535 QString ElfFile::getSegmentType(int index)
536 {
536 {
537 QString type("");
537 QString type("");
538 if(this->e!=NULL)
538 if(this->e!=NULL)
539 {
539 {
540 if(index < this->Segments.count())
540 if(index < this->Segments.count())
541 {
541 {
542 switch(this->Segments.at(index)->p_type)
542 switch(this->Segments.at(index)->p_type)
543 {
543 {
544 case PT_NULL:
544 case PT_NULL:
545 type = "Program header table entry unused";
545 type = "Program header table entry unused";
546 break;
546 break;
547 case PT_LOAD:
547 case PT_LOAD:
548 type = "Loadable program segment";
548 type = "Loadable program segment";
549 break;
549 break;
550 case PT_DYNAMIC :
550 case PT_DYNAMIC :
551 type = "Dynamic linking information";
551 type = "Dynamic linking information";
552 break;
552 break;
553 case PT_INTERP:
553 case PT_INTERP:
554 type ="Program interpreter";
554 type ="Program interpreter";
555 break;
555 break;
556 case PT_NOTE:
556 case PT_NOTE:
557 type = "Auxiliary information";
557 type = "Auxiliary information";
558 break;
558 break;
559 case PT_SHLIB:
559 case PT_SHLIB:
560 type = "Reserved";
560 type = "Reserved";
561 break;
561 break;
562 case PT_PHDR:
562 case PT_PHDR:
563 type = "Entry for header table itself";
563 type = "Entry for header table itself";
564 break;
564 break;
565 case PT_TLS:
565 case PT_TLS:
566 type = "Thread-local storage segment";
566 type = "Thread-local storage segment";
567 break;
567 break;
568 case PT_NUM:
568 case PT_NUM:
569 type = "Number of defined types";
569 type = "Number of defined types";
570 break;
570 break;
571 case PT_LOOS:
571 case PT_LOOS:
572 type = "Start of OS-specific";
572 type = "Start of OS-specific";
573 break;
573 break;
574 case PT_SUNWSTACK:
574 case PT_SUNWSTACK:
575 type = "Stack segment";
575 type = "Stack segment";
576 break;
576 break;
577 case PT_LOPROC:
577 case PT_LOPROC:
578 type = "Start of processor-specific";
578 type = "Start of processor-specific";
579 break;
579 break;
580 case PT_HIPROC:
580 case PT_HIPROC:
581 type = "End of processor-specific";
581 type = "End of processor-specific";
582 break;
582 break;
583 default:
583 default:
584 type = "Unknow Section Type";
584 type = "Unknow Section Type";
585 break;
585 break;
586 }
586 }
587 }
587 }
588 }
588 }
589
589
590 return type;
590 return type;
591 }
591 }
592
592
593
593
594 qint64 ElfFile::getSegmentOffset(int index)
594 qint64 ElfFile::getSegmentOffset(int index)
595 {
595 {
596 qint64 Offset = -1;
596 qint64 Offset = -1;
597 if(this->e!=NULL)
597 if(this->e!=NULL)
598 {
598 {
599 if(index < this->Segments.count())
599 if(index < this->Segments.count())
600 {
600 {
601 Offset = (qint64)this->Segments.at(index)->p_offset;
601 Offset = (qint64)this->Segments.at(index)->p_offset;
602 }
602 }
603 }
603 }
604 return Offset;
604 return Offset;
605 }
605 }
606
606
607
607
608 qint64 ElfFile::getSegmentVaddr(int index)
608 qint64 ElfFile::getSegmentVaddr(int index)
609 {
609 {
610 int64_t Vaddr = 0;
610 int64_t Vaddr = 0;
611 if(this->e!=NULL)
611 if(this->e!=NULL)
612 {
612 {
613 if(index < this->Segments.count())
613 if(index < this->Segments.count())
614 {
614 {
615 Vaddr = (int64_t)this->Segments.at(index)->p_vaddr;
615 Vaddr = (int64_t)this->Segments.at(index)->p_vaddr;
616 }
616 }
617 }
617 }
618 return Vaddr;
618 return Vaddr;
619 }
619 }
620
620
621
621
622 qint64 ElfFile::getSegmentPaddr(int index)
622 qint64 ElfFile::getSegmentPaddr(int index)
623 {
623 {
624 int64_t Paddr=0;
624 int64_t Paddr=0;
625 if(this->e!=NULL)
625 if(this->e!=NULL)
626 {
626 {
627 if(index < this->Segments.count())
627 if(index < this->Segments.count())
628 {
628 {
629 Paddr = (int64_t)this->Segments.at(index)->p_paddr;
629 Paddr = (int64_t)this->Segments.at(index)->p_paddr;
630 }
630 }
631 }
631 }
632 return Paddr;
632 return Paddr;
633 }
633 }
634
634
635 qint64 ElfFile::getSectionPaddr(int index)
635 qint64 ElfFile::getSectionPaddr(int index)
636 {
636 {
637 int64_t Paddr=0;
637 int64_t Paddr=0;
638 if(this->e!=NULL)
638 if(this->e!=NULL)
639 {
639 {
640 if(index < this->sections.count())
640 if(index < this->sections.count())
641 {
641 {
642 Paddr = (int64_t)this->sections.at(index)->section_header->sh_addr;
642 Paddr = (int64_t)this->sections.at(index)->section_header->sh_addr;
643 }
643 }
644 }
644 }
645 return Paddr;
645 return Paddr;
646 }
646 }
647
647
648
648
649 qint64 ElfFile::getSegmentFilesz(int index)
649 qint64 ElfFile::getSegmentFilesz(int index)
650 {
650 {
651 int64_t FileSz=0;
651 int64_t FileSz=0;
652 if(this->e!=NULL)
652 if(this->e!=NULL)
653 {
653 {
654 if(index < this->Segments.count())
654 if(index < this->Segments.count())
655 {
655 {
656 FileSz = (int64_t)this->Segments.at(index)->p_filesz;
656 FileSz = (int64_t)this->Segments.at(index)->p_filesz;
657 }
657 }
658 }
658 }
659 return FileSz;
659 return FileSz;
660 }
660 }
661
661
662 qint64 ElfFile::getSectionDatasz(int index)
662 qint64 ElfFile::getSectionDatasz(int index)
663 {
663 {
664 int64_t DataSz=0;
664 int64_t DataSz=0;
665 if(this->e!=NULL)
665 if(this->e!=NULL)
666 {
666 {
667 if(index < this->sections.count())
667 if(index < this->sections.count())
668 {
668 {
669 if(this->sections.at(index)->section_header->sh_type==SHT_NOBITS)
669 if(this->sections.at(index)->section_header->sh_type==SHT_NOBITS)
670 {
670 {
671 DataSz=0;
671 DataSz=0;
672 }
672 }
673 else
673 else
674 {
674 {
675 DataSz = (int64_t)this->sections.at(index)->data->d_size;
675 DataSz = (int64_t)this->sections.at(index)->data->d_size;
676 }
676 }
677 }
677 }
678 }
678 }
679 return DataSz;
679 return DataSz;
680 }
680 }
681
681
682 bool ElfFile::getSectionData(int index, char **buffer)
682 bool ElfFile::getSectionData(int index, char **buffer)
683 {
683 {
684 if(this->e!=NULL)
684 if(this->e!=NULL)
685 {
685 {
686 if(index < this->sections.count())
686 if(index < this->sections.count())
687 {
687 {
688 *buffer = (char *)this->sections.at(index)->data->d_buf;
688 *buffer = (char *)this->sections.at(index)->data->d_buf;
689 return true;
689 return true;
690 }
690 }
691 }
691 }
692 return false;
692 return false;
693 }
693 }
694
694
695
695
696 qint64 ElfFile::getSegmentMemsz(int index)
696 qint64 ElfFile::getSegmentMemsz(int index)
697 {
697 {
698 int64_t MemSz=0;
698 int64_t MemSz=0;
699 if(this->e!=NULL)
699 if(this->e!=NULL)
700 {
700 {
701 if(index < this->Segments.count())
701 if(index < this->Segments.count())
702 {
702 {
703 MemSz = (int64_t)this->Segments.at(index)->p_memsz;
703 MemSz = (int64_t)this->Segments.at(index)->p_memsz;
704 }
704 }
705 }
705 }
706 return MemSz;
706 return MemSz;
707 }
707 }
708
708
709 qint64 ElfFile::getSectionMemsz(int index)
709 qint64 ElfFile::getSectionMemsz(int index)
710 {
710 {
711 int64_t MemSz=0;
711 int64_t MemSz=0;
712 if(this->e!=NULL)
712 if(this->e!=NULL)
713 {
713 {
714 if(index < this->sections.count())
714 if(index < this->sections.count())
715 {
715 {
716 MemSz = (int64_t)this->sections.at(index)->section_header->sh_size;
716 MemSz = (int64_t)this->sections.at(index)->section_header->sh_size;
717 }
717 }
718 }
718 }
719 return MemSz;
719 return MemSz;
720 }
720 }
721
721
722
722
723 QString ElfFile::getSegmentFlags(int index)
723 QString ElfFile::getSegmentFlags(int index)
724 {
724 {
725 QString flags("");
725 QString flags("");
726 if(this->e!=NULL)
726 if(this->e!=NULL)
727 {
727 {
728 if(index < this->Segments.count())
728 if(index < this->Segments.count())
729 {
729 {
730 if((this->Segments.at(index)->p_flags&PF_X) == PF_X)flags+="x";
730 if((this->Segments.at(index)->p_flags&PF_X) == PF_X)flags+="x";
731 if((this->Segments.at(index)->p_flags&PF_W) == PF_W)flags+="w";
731 if((this->Segments.at(index)->p_flags&PF_W) == PF_W)flags+="w";
732 if((this->Segments.at(index)->p_flags&PF_R) == PF_R)flags+="r";
732 if((this->Segments.at(index)->p_flags&PF_R) == PF_R)flags+="r";
733 if((this->Segments.at(index)->p_flags&PF_MASKOS) == PF_MASKOS)flags+=" OS-specific";
733 if((this->Segments.at(index)->p_flags&PF_MASKOS) == PF_MASKOS)flags+=" OS-specific";
734 if((this->Segments.at(index)->p_flags&PF_MASKPROC) == PF_MASKPROC)flags+=" Processor-specific";
734 if((this->Segments.at(index)->p_flags&PF_MASKPROC) == PF_MASKPROC)flags+=" Processor-specific";
735 }
735 }
736 }
736 }
737 return flags;
737 return flags;
738 }
738 }
739
739
740
740
741 QString ElfFile::getSectionName(int index)
741 QString ElfFile::getSectionName(int index)
742 {
742 {
743 if((index<sections.count()) && (index>=0))
743 if((index<sections.count()) && (index>=0))
744 {
744 {
745 char* nameChr = elf_strptr(this->e , this->shstrndx , this->sections.at(index)->section_header->sh_name);
745 char* nameChr = elf_strptr(this->e , this->shstrndx , this->sections.at(index)->section_header->sh_name);
746 return QString(nameChr);
746 return QString(nameChr);
747 }
747 }
748 return "";
748 return "";
749 }
749 }
750
750
751
751
752 void ElfFile::updateSections()
752 void ElfFile::updateSections()
753 {
753 {
754 for(int i=0;i<this->sections.count();i++)
754 for(int i=0;i<this->sections.count();i++)
755 {
755 {
756 delete this->sections.at(i);
756 delete this->sections.at(i);
757 }
757 }
758 this->sections.clear();
758 this->sections.clear();
759 this->scn = elf_nextscn (this->e , NULL );
759 this->scn = elf_nextscn (this->e , NULL );
760 this->SectionCount = 0;
760 this->SectionCount = 0;
761 while( this->scn != NULL )
761 while( this->scn != NULL )
762 {
762 {
763 GElf_Shdr* shdr = (GElf_Shdr*)malloc(sizeof(GElf_Shdr));
763 GElf_Shdr* shdr = (GElf_Shdr*)malloc(sizeof(GElf_Shdr));
764 gelf_getshdr ( this->scn , shdr );
764 gelf_getshdr ( this->scn , shdr );
765 Elf_Data* data = elf_getdata(this->scn, NULL);
765 Elf_Data* data = elf_getdata(this->scn, NULL);
766 this->sections.append(new Elf_Section(data,shdr));
766 this->sections.append(new Elf_Section(data,shdr));
767 this->SectionCount+=1;
767 this->SectionCount+=1;
768 this->scn = elf_nextscn(e , scn);
768 this->scn = elf_nextscn(e , scn);
769 }
769 }
770 }
770 }
771
771
772
772
773 void ElfFile::updateSegments()
773 void ElfFile::updateSegments()
774 {
774 {
775 elf_getphdrnum (this->e , &this->SegmentCount);
775 elf_getphdrnum (this->e , &this->SegmentCount);
776 for(int i=0;i<this->Segments.count();i++)
776 for(int i=0;i<this->Segments.count();i++)
777 {
777 {
778 free(this->Segments.at(i));
778 free(this->Segments.at(i));
779 }
779 }
780 this->Segments.clear();
780 this->Segments.clear();
781 for(int i=0;i<(int)this->SegmentCount;i++)
781 for(int i=0;i<(int)this->SegmentCount;i++)
782 {
782 {
783 GElf_Phdr* header=(GElf_Phdr*)malloc(sizeof(GElf_Phdr));
783 GElf_Phdr* header=(GElf_Phdr*)malloc(sizeof(GElf_Phdr));
784 gelf_getphdr (this->e , i , header );
784 gelf_getphdr (this->e , i , header );
785 this->Segments.append(header);
785 this->Segments.append(header);
786 }
786 }
787 }
787 }
788
788
789 void ElfFile::updateSymbols()
789 void ElfFile::updateSymbols()
790 {
790 {
791 for(int i=0;i<symbols.count();i++)
791 for(int i=0;i<symbols.count();i++)
792 {
792 {
793 delete this->symbols.at(i);
793 delete this->symbols.at(i);
794 }
794 }
795 this->symbols.clear();
795 this->symbols.clear();
796 updateSections(); //Useless in most case but safer to do it
796 updateSections(); //Useless in most case but safer to do it
797 for(int i=0;i<(int)SectionCount;i++)
797 for(int i=0;i<(int)SectionCount;i++)
798 {
798 {
799 //First find Symbol table
799 //First find Symbol table
800 if(this->getSectionName(i)==".symtab")
800 if(this->getSectionName(i)==".symtab")
801 {
801 {
802 Elf_Section* sec = sections.at(i);
802 Elf_Section* sec = sections.at(i);
803 this->SymbolCount = sec->section_header->sh_size / sec->section_header->sh_entsize;
803 this->SymbolCount = sec->section_header->sh_size / sec->section_header->sh_entsize;
804 //Then list all symbols
804 //Then list all symbols
805 for(int j=0;j<(int)this->SymbolCount;j++)
805 for(int j=0;j<(int)this->SymbolCount;j++)
806 {
806 {
807 GElf_Sym* esym = (GElf_Sym*)malloc(sizeof(GElf_Sym));
807 GElf_Sym* esym = (GElf_Sym*)malloc(sizeof(GElf_Sym));
808 gelf_getsym(sec->data, j, esym);
808 gelf_getsym(sec->data, j, esym);
809 QString name = elf_strptr(this->e,sec->section_header->sh_link,esym->st_name);
809 QString name = elf_strptr(this->e,sec->section_header->sh_link,esym->st_name);
810 Elf_Symbol* sym = new Elf_Symbol(name,esym);
810 Elf_Symbol* sym = new Elf_Symbol(name,esym);
811 symbols.append(sym);
811 symbols.append(sym);
812 }
812 }
813 }
813 }
814 }
814 }
815
815
816 }
816 }
817
817
818
818
819
819
820 QString ElfFile::getSectionType(int index)
820 QString ElfFile::getSectionType(int index)
821 {
821 {
822 QString type("");
822 QString type("");
823 if(this->e!=NULL)
823 if(this->e!=NULL)
824 {
824 {
825 if(index < this->sections.count())
825 if(index < this->sections.count())
826 {
826 {
827 switch(this->sections.at(index)->section_header->sh_type)
827 switch(this->sections.at(index)->section_header->sh_type)
828 {
828 {
829 case SHT_NULL : type = "Section header table entry unused"; break;
829 case SHT_NULL : type = "Section header table entry unused"; break;
830 case SHT_PROGBITS : type = "Program data"; break;
830 case SHT_PROGBITS : type = "Program data"; break;
831 case SHT_SYMTAB : type = "Symbol table"; break;
831 case SHT_SYMTAB : type = "Symbol table"; break;
832 case SHT_STRTAB : type = "String table"; break;
832 case SHT_STRTAB : type = "String table"; break;
833 case SHT_RELA : type = "Relocation entries with addends"; break;
833 case SHT_RELA : type = "Relocation entries with addends"; break;
834 case SHT_HASH : type = "Symbol hash table"; break;
834 case SHT_HASH : type = "Symbol hash table"; break;
835 case SHT_DYNAMIC : type = "Dynamic linking information"; break;
835 case SHT_DYNAMIC : type = "Dynamic linking information"; break;
836 case SHT_NOTE : type = "Notes"; break;
836 case SHT_NOTE : type = "Notes"; break;
837 case SHT_NOBITS :type = "Program space with no data (bss)"; break;
837 case SHT_NOBITS :type = "Program space with no data (bss)"; break;
838 case SHT_REL :type = "Relocation entries, no addends"; break;
838 case SHT_REL :type = "Relocation entries, no addends"; break;
839 case SHT_SHLIB : type = "Reserved"; break;
839 case SHT_SHLIB : type = "Reserved"; break;
840 case SHT_DYNSYM : type = "Dynamic linker symbol table"; break;
840 case SHT_DYNSYM : type = "Dynamic linker symbol table"; break;
841 case SHT_INIT_ARRAY : type = "Array of constructors"; break;
841 case SHT_INIT_ARRAY : type = "Array of constructors"; break;
842 case SHT_FINI_ARRAY : type = "Array of destructors"; break;
842 case SHT_FINI_ARRAY : type = "Array of destructors"; break;
843 case SHT_PREINIT_ARRAY : type = "Array of pre-constructors"; break;
843 case SHT_PREINIT_ARRAY : type = "Array of pre-constructors"; break;
844 case SHT_GROUP : type = "Section group"; break;
844 case SHT_GROUP : type = "Section group"; break;
845 case SHT_SYMTAB_SHNDX : type = "Extended section indeces"; break;
845 case SHT_SYMTAB_SHNDX : type = "Extended section indeces"; break;
846 case SHT_NUM : type = "Number of defined types. "; break;
846 case SHT_NUM : type = "Number of defined types. "; break;
847 case SHT_LOOS : type = "Start OS-specific. "; break;
847 case SHT_LOOS : type = "Start OS-specific. "; break;
848 case SHT_LOSUNW : type = "Sun-specific low bound. "; break;
848 case SHT_LOSUNW : type = "Sun-specific low bound. "; break;
849 case SHT_SUNW_COMDAT : type = " "; break;
849 case SHT_SUNW_COMDAT : type = " "; break;
850 case SHT_SUNW_syminfo : type = " "; break;
850 case SHT_SUNW_syminfo : type = " "; break;
851 case SHT_GNU_verdef : type = "Version definition section. "; break;
851 case SHT_GNU_verdef : type = "Version definition section. "; break;
852 case SHT_GNU_verneed : type = "Version needs section. "; break;
852 case SHT_GNU_verneed : type = "Version needs section. "; break;
853 case SHT_GNU_versym : type = "Version symbol table. "; break;
853 case SHT_GNU_versym : type = "Version symbol table. "; break;
854 case SHT_LOPROC : type = "Start of processor-specific"; break;
854 case SHT_LOPROC : type = "Start of processor-specific"; break;
855 case SHT_HIPROC : type = "End of processor-specific"; break;
855 case SHT_HIPROC : type = "End of processor-specific"; break;
856 case SHT_HIUSER : type = "End of application-specific"; break;
856 case SHT_HIUSER : type = "End of application-specific"; break;
857 }
857 }
858 }
858 }
859 }
859 }
860 return type;
860 return type;
861 }
861 }
862
862
863 int ElfFile::getSectionIndex(QString name)
863 int ElfFile::getSectionIndex(QString name)
864 {
864 {
865 if(this->e!=NULL)
865 if(this->e!=NULL)
866 {
866 {
867 for(int i=0;i<sections.count();i++)
867 for(int i=0;i<sections.count();i++)
868 {
868 {
869 if(getSectionName(i)==name)
869 if(getSectionName(i)==name)
870 return i;
870 return i;
871 }
871 }
872 }
872 }
873 return -1;
873 return -1;
874 }
874 }
875
875
876 bool ElfFile::sectionIsNobits(int index)
876 bool ElfFile::sectionIsNobits(int index)
877 {
877 {
878 if(this->e!=NULL)
878 if(this->e!=NULL)
879 {
879 {
880 if(index < this->sections.count())
880 if(index < this->sections.count())
881 {
881 {
882 return this->sections.at(index)->section_header->sh_type== SHT_NOBITS;
882 return this->sections.at(index)->section_header->sh_type== SHT_NOBITS;
883 }
883 }
884 }
884 }
885 return false;
885 return false;
886 }
886 }
887
887
888 QString ElfFile::getSymbolName(int index)
888 QString ElfFile::getSymbolName(int index)
889 {
889 {
890 if(this->e!=NULL)
890 if(this->e!=NULL)
891 {
891 {
892 if(index < this->symbols.count())
892 if(index < this->symbols.count())
893 {
893 {
894 return symbols.at(index)->name;
894 return symbols.at(index)->name;
895 }
895 }
896 }
896 }
897 return "";
897 return "";
898 }
898 }
899
899
900 QString ElfFile::getSymbolType(int index)
900 QString ElfFile::getSymbolType(int index)
901 {
901 {
902 if(this->e!=NULL)
902 if(this->e!=NULL)
903 {
903 {
904 if(index < this->symbols.count())
904 if(index < this->symbols.count())
905 {
905 {
906 int type = GELF_ST_TYPE(symbols.at(index)->sym->st_info);
906 int type = GELF_ST_TYPE(symbols.at(index)->sym->st_info);
907 switch(type)
907 switch(type)
908 {
908 {
909 case STT_NOTYPE:
909 case STT_NOTYPE:
910 return "No Type";
910 return "No Type";
911 break;
911 break;
912 case STT_OBJECT:
912 case STT_OBJECT:
913 return "Object";
913 return "Object";
914 break;
914 break;
915 case STT_FUNC:
915 case STT_FUNC:
916 return "Function";
916 return "Function";
917 break;
917 break;
918 case STT_SECTION:
918 case STT_SECTION:
919 return "Section";
919 return "Section";
920 break;
920 break;
921 case STT_FILE:
921 case STT_FILE:
922 return "File";
922 return "File";
923 break;
923 break;
924 case STT_COMMON:
924 case STT_COMMON:
925 return "Common data object";
925 return "Common data object";
926 break;
926 break;
927 case STT_TLS:
927 case STT_TLS:
928 return "Thread-local data object";
928 return "Thread-local data object";
929 break;
929 break;
930 case STT_NUM:
930 case STT_NUM:
931 return "Number of defined types";
931 return "Number of defined types";
932 break;
932 break;
933 case STT_LOOS:
933 case STT_LOOS:
934 return "Start of OS-specific";
934 return "Start of OS-specific";
935 break;
935 break;
936 case STT_HIOS:
936 case STT_HIOS:
937 return "End of OS-specific";
937 return "End of OS-specific";
938 break;
938 break;
939 case STT_LOPROC:
939 case STT_LOPROC:
940 return "Start of processor-specific";
940 return "Start of processor-specific";
941 break;
941 break;
942 case STT_HIPROC:
942 case STT_HIPROC:
943 return "End of processor-specific";
943 return "End of processor-specific";
944 break;
944 break;
945 default:
945 default:
946 return "none";
946 return "none";
947 break;
947 break;
948 }
948 }
949 }
949 }
950 }
950 }
951 return "none";
951 return "none";
952 }
952 }
953
953
954 quint64 ElfFile::getSymbolSize(int index)
954 quint64 ElfFile::getSymbolSize(int index)
955 {
955 {
956 if(this->e!=NULL)
956 if(this->e!=NULL)
957 {
957 {
958 if((index < this->symbols.count()) && (index>=0))
958 if((index < this->symbols.count()) && (index>=0))
959 {
959 {
960 return symbols.at(index)->sym->st_size;
960 return symbols.at(index)->sym->st_size;
961 }
961 }
962 }
962 }
963 return 0;
963 return 0;
964 }
964 }
965
965
966 QString ElfFile::getSymbolSectionName(int index)
966 QString ElfFile::getSymbolSectionName(int index)
967 {
967 {
968 if(this->e!=NULL)
968 if(this->e!=NULL)
969 {
969 {
970 if((index < this->symbols.count()) && (index>=0))
970 if((index < this->symbols.count()) && (index>=0))
971 {
971 {
972 return getSectionName(symbols.at(index)->sym->st_shndx-1);
972 return getSectionName(symbols.at(index)->sym->st_shndx-1);
973 }
973 }
974 }
974 }
975 return "none";
975 return "none";
976 }
976 }
977
977
978 int ElfFile::getSymbolSectionIndex(int index)
978 int ElfFile::getSymbolSectionIndex(int index)
979 {
979 {
980 if(this->e!=NULL)
980 if(this->e!=NULL)
981 {
981 {
982 if((index < this->symbols.count()) && (index>=0))
982 if((index < this->symbols.count()) && (index>=0))
983 {
983 {
984 return symbols.at(index)->sym->st_shndx;
984 return symbols.at(index)->sym->st_shndx;
985 }
985 }
986 }
986 }
987 return 0;
987 return 0;
988 }
988 }
989
989
990 quint64 ElfFile::getSymbolAddress(int index)
990 quint64 ElfFile::getSymbolAddress(int index)
991 {
991 {
992 if(this->e!=NULL)
992 if(this->e!=NULL)
993 {
993 {
994 if((index < this->symbols.count()) && (index>=0))
994 if((index < this->symbols.count()) && (index>=0))
995 {
995 {
996 return symbols.at(index)->sym->st_value;
996 return symbols.at(index)->sym->st_value;
997 }
997 }
998 }
998 }
999 return 0;
999 return 0;
1000 }
1000 }
1001
1001
1002 QString ElfFile::getSymbolLinkType(int index)
1002 QString ElfFile::getSymbolLinkType(int index)
1003 {
1003 {
1004 if(this->e!=NULL)
1004 if(this->e!=NULL)
1005 {
1005 {
1006 if(index < this->symbols.count())
1006 if(index < this->symbols.count())
1007 {
1007 {
1008 int btype = GELF_ST_BIND(symbols.at(index)->sym->st_info);
1008 int btype = GELF_ST_BIND(symbols.at(index)->sym->st_info);
1009 switch(btype)
1009 switch(btype)
1010 {
1010 {
1011 case STB_LOCAL:
1011 case STB_LOCAL:
1012 return "Local";
1012 return "Local";
1013 break;
1013 break;
1014 case STB_GLOBAL:
1014 case STB_GLOBAL:
1015 return "Global";
1015 return "Global";
1016 break;
1016 break;
1017 case STB_WEAK:
1017 case STB_WEAK:
1018 return "Weak";
1018 return "Weak";
1019 break;
1019 break;
1020 case STB_NUM:
1020 case STB_NUM:
1021 return "Number of defined types";
1021 return "Number of defined types";
1022 break;
1022 break;
1023 case STB_LOOS:
1023 case STB_LOOS:
1024 return "Start of OS-specific";
1024 return "Start of OS-specific";
1025 break;
1025 break;
1026 case STB_HIOS:
1026 case STB_HIOS:
1027 return "End of OS-specific";
1027 return "End of OS-specific";
1028 break;
1028 break;
1029 case STB_LOPROC:
1029 case STB_LOPROC:
1030 return "Start of processor-specific";
1030 return "Start of processor-specific";
1031 break;
1031 break;
1032 case STB_HIPROC:
1032 case STB_HIPROC:
1033 return "End of processor-specific";
1033 return "End of processor-specific";
1034 break;
1034 break;
1035 default:
1035 default:
1036 return "none";
1036 return "none";
1037 break;
1037 break;
1038 }
1038 }
1039 }
1039 }
1040 }
1040 }
1041 return "none";
1041 return "none";
1042 }
1042 }
1043
1043
1044 bool ElfFile::isElf(const QString &File)
1044 bool ElfFile::isElf(const QString &File)
1045 {
1045 {
1046 int file =0;
1046 int file =0;
1047 #ifdef _ELF_WINDOWS_
1047 #ifdef _ELF_WINDOWS_
1048 file = open(File.toStdString().c_str(),O_RDONLY|O_BINARY ,0);
1048 file = open(File.toStdString().c_str(),O_RDONLY|O_BINARY ,0);
1049 #else
1049 #else
1050 file = open(File.toStdString().c_str(),O_RDONLY ,0);
1050 file = open(File.toStdString().c_str(),O_RDONLY ,0);
1051 #endif
1051 #endif
1052 char Magic[4];
1052 char Magic[4];
1053 if(file!=-1)
1053 if(file!=-1)
1054 {
1054 {
1055 size_t res = read(file,Magic,4);
1055 size_t res = read(file,Magic,4);
1056 close(file);
1056 close(file);
1057 if((res==4) && (Magic[0]==0x7f) && (Magic[1]==0x45) && (Magic[2]==0x4c) && (Magic[3]==0x46))
1057 if((res==4) && (Magic[0]==0x7f) && (Magic[1]==0x45) && (Magic[2]==0x4c) && (Magic[3]==0x46))
1058 {
1058 {
1059 return true;
1059 return true;
1060 }
1060 }
1061 }
1061 }
1062 return false;
1062 return false;
1063 }
1063 }
1064
1064
1065 bool ElfFile::toSrec(const QString &File)
1065 bool ElfFile::toSrec(const QString &File)
1066 {
1066 {
1067 return srecFile::toSrec(this->getFragments(),File);
1067 return srecFile::toSrec(this->getFragments(),File);
1068 }
1068 }
@@ -1,523 +1,522
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) 2013, Plasma Physics Laboratory - CNRS
3 -- Copyright (C) 2013, 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 3 of the License, or
7 -- the Free Software Foundation; either version 3 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 : Alexis Jeandet
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 ----------------------------------------------------------------------------*/
21 ----------------------------------------------------------------------------*/
22 #include "elfparser.h"
22 #include "elfparser.h"
23 #include <sys/types.h>
23 #include <sys/types.h>
24 #include <sys/stat.h>
24 #include <sys/stat.h>
25 #include <fcntl.h>
25 #include <fcntl.h>
26 #include <unistd.h>
26 #include <unistd.h>
27
27
28 extern QString elfresolveMachine(Elf64_Half e_machine);
28 extern QString elfresolveMachine(Elf64_Half e_machine);
29
29
30
30
31 elfparser::elfparser()
31 elfparser::elfparser()
32 {
32 {
33 this->opened = false;
33 this->opened = false;
34 this->type_elf = false;
34 this->type_elf = false;
35 this->elfFile = (int)NULL;
35 this->elfFile = (int)NULL;
36 this->e = NULL;
36 this->e = NULL;
37 }
37 }
38
38
39
39
40 int elfparser::setFilename(const QString &name)
40 int elfparser::setFilename(const QString &name)
41 {
41 {
42 this->closeFile();
42 this->closeFile();
43 if(elf_version(EV_CURRENT)==EV_NONE)return 0;
43 if(elf_version(EV_CURRENT)==EV_NONE)return 0;
44 #ifdef _ELF_WINDOWS_
44 #ifdef _ELF_WINDOWS_
45 this->elfFile = open(name.toStdString().c_str(),O_RDONLY|O_BINARY ,0);
45 this->elfFile = open(name.toStdString().c_str(),O_RDONLY|O_BINARY ,0);
46 #else
46 #else
47 this->elfFile = open(name.toStdString().c_str(),O_RDONLY ,0);
47 this->elfFile = open(name.toStdString().c_str(),O_RDONLY ,0);
48 #endif
48 #endif
49 if(this->elfFile==(int)NULL)return 0;
49 if(this->elfFile==(int)NULL)return 0;
50 this->e = elf_begin(this->elfFile,ELF_C_READ,NULL);
50 this->e = elf_begin(this->elfFile,ELF_C_READ,NULL);
51 if(this->e==NULL)return 0;
51 if(this->e==NULL)return 0;
52 this->ek = elf_kind(this->e);
52 this->ek = elf_kind(this->e);
53 gelf_getehdr (this->e, &this->ehdr );
53 gelf_getehdr (this->e, &this->ehdr );
54 elf_getshdrstrndx (this->e, &this->shstrndx);
54 elf_getshdrstrndx (this->e, &this->shstrndx);
55 this->updateSegments();
55 this->updateSegments();
56 this->updateSections();
56 this->updateSections();
57 return 1;
57 return 1;
58 }
58 }
59
59
60
60
61 int elfparser::closeFile()
61 int elfparser::closeFile()
62 {
62 {
63 if(this->elfFile!=(int)NULL)
63 if(this->elfFile!=(int)NULL)
64 {
64 {
65 if(this->e!=NULL)
65 if(this->e!=NULL)
66 {
66 {
67 elf_end(this->e);
67 elf_end(this->e);
68 this->e = NULL;
68 this->e = NULL;
69 }
69 }
70 close(this->elfFile);
70 close(this->elfFile);
71 this->elfFile = (int)NULL;
71 this->elfFile = (int)NULL;
72 }
72 }
73 return 0;
73 return 0;
74 }
74 }
75
75
76 QString elfparser::getClass()
76 QString elfparser::getClass()
77 {
77 {
78 if(this->e!=NULL)
78 if(this->e!=NULL)
79 {
79 {
80 int eclass = gelf_getclass(this->e);
80 int eclass = gelf_getclass(this->e);
81 if(eclass==ELFCLASS32)return "ELF32";
81 if(eclass==ELFCLASS32)return "ELF32";
82 if(eclass==ELFCLASS64)return "ELF64";
82 if(eclass==ELFCLASS64)return "ELF64";
83 }
83 }
84 return "none";
84 return "none";
85 }
85 }
86
86
87
87
88 bool elfparser::isopened()
88 bool elfparser::isopened()
89 {
89 {
90 return this->opened;
90 return this->opened;
91 }
91 }
92
92
93
93
94 bool elfparser::iself()
94 bool elfparser::iself()
95 {
95 {
96 return this->type_elf;
96 return this->type_elf;
97 }
97 }
98
98
99
99
100 QString elfparser::getArchitecture()
100 QString elfparser::getArchitecture()
101 {
101 {
102 if(this->e!=NULL)
102 if(this->e!=NULL)
103 {
103 {
104 return elfresolveMachine(this->ehdr.e_machine);
104 return elfresolveMachine(this->ehdr.e_machine);
105 }
105 }
106 return "";
106 return "";
107 }
107 }
108
108
109
109
110 QString elfparser::getType()
110 QString elfparser::getType()
111 {
111 {
112 QString kind("");
112 QString kind("");
113 if(this->e!=NULL)
113 if(this->e!=NULL)
114 {
114 {
115 switch(this->ek)
115 switch(this->ek)
116 {
116 {
117 case ELF_K_AR:
117 case ELF_K_AR:
118 kind = "Archive";
118 kind = "Archive";
119 break;
119 break;
120 case ELF_K_ELF:
120 case ELF_K_ELF:
121 kind = "Elf";
121 kind = "Elf";
122 break;
122 break;
123 case ELF_K_COFF:
123 case ELF_K_COFF:
124 kind = "COFF";
124 kind = "COFF";
125 break;
125 break;
126 case ELF_K_NUM:
126 case ELF_K_NUM:
127 kind = "NUM";
127 kind = "NUM";
128 break;
128 break;
129 case ELF_K_NONE:
129 case ELF_K_NONE:
130 kind = "Data";
130 kind = "Data";
131 break;
131 break;
132 default:
132 default:
133 kind = "Unknow";
133 kind = "Unknow";
134 break;
134 break;
135 }
135 }
136 }
136 }
137 return kind;
137 return kind;
138 }
138 }
139
139
140 QString elfparser::getEndianness()
140 QString elfparser::getEndianness()
141 {
141 {
142 if(this->e!=NULL)
142 if(this->e!=NULL)
143 {
143 {
144 if(this->ehdr.e_ident[EI_DATA]==ELFDATA2LSB)return "2's complement, little endian";
144 if(this->ehdr.e_ident[EI_DATA]==ELFDATA2LSB)return "2's complement, little endian";
145 if(this->ehdr.e_ident[EI_DATA]==ELFDATA2MSB)return "2's complement, big endian";
145 if(this->ehdr.e_ident[EI_DATA]==ELFDATA2MSB)return "2's complement, big endian";
146 }
146 }
147 return "none";
147 return "none";
148 }
148 }
149
149
150 QString elfparser::getABI()
150 QString elfparser::getABI()
151 {
151 {
152 if(this->e!=NULL)
152 if(this->e!=NULL)
153 {
153 {
154 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_NONE)return "UNIX System V ABI";
154 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_NONE)return "UNIX System V ABI";
155 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_SYSV)return "Alias";
155 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_SYSV)return "Alias";
156 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_HPUX)return "HP-UX";
156 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_HPUX)return "HP-UX";
157 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_NETBSD)return "NetBSD";
157 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_NETBSD)return "NetBSD";
158 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_GNU)return "Object uses GNU ELF extensions";
158 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_LINUX)return "Object uses GNU ELF extensions";
159 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_LINUX)return "Compatibility alias";
160 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_SOLARIS)return "Sun Solaris";
159 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_SOLARIS)return "Sun Solaris";
161 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_AIX)return "IBM AIX";
160 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_AIX)return "IBM AIX";
162 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_IRIX)return "SGI Irix";
161 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_IRIX)return "SGI Irix";
163 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_FREEBSD)return "FreeBSD";
162 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_FREEBSD)return "FreeBSD";
164 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_TRU64)return "Compaq TRU64 UNIX";
163 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_TRU64)return "Compaq TRU64 UNIX";
165 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_MODESTO)return " Novell Modesto";
164 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_MODESTO)return " Novell Modesto";
166 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_OPENBSD)return "OpenBSD";
165 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_OPENBSD)return "OpenBSD";
167 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_ARM_AEABI)return "ARM EABI";
166 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_ARM_AEABI)return "ARM EABI";
168 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_ARM)return "ARM";
167 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_ARM)return "ARM";
169 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_STANDALONE)return "Standalone (embedded) application";
168 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_STANDALONE)return "Standalone (embedded) application";
170 }
169 }
171 return "none";
170 return "none";
172 }
171 }
173
172
174
173
175 qint64 elfparser::getVersion()
174 qint64 elfparser::getVersion()
176 {
175 {
177 if(this->e!=NULL)
176 if(this->e!=NULL)
178 {
177 {
179 return this->ehdr.e_version;
178 return this->ehdr.e_version;
180 }
179 }
181 return -1;
180 return -1;
182 }
181 }
183
182
184 qint64 elfparser::getEntryPointAddress()
183 qint64 elfparser::getEntryPointAddress()
185 {
184 {
186 if(this->e!=NULL)
185 if(this->e!=NULL)
187 {
186 {
188 return this->ehdr.e_entry;
187 return this->ehdr.e_entry;
189 }
188 }
190 return -1;
189 return -1;
191 }
190 }
192
191
193
192
194 int elfparser::getSectioncount()
193 int elfparser::getSectioncount()
195 {
194 {
196 return (int)this->SectionCount;
195 return (int)this->SectionCount;
197 }
196 }
198
197
199
198
200 int elfparser::getSegmentcount()
199 int elfparser::getSegmentcount()
201 {
200 {
202 return (int)this->SegmentCount;
201 return (int)this->SegmentCount;
203 }
202 }
204
203
205
204
206 QString elfparser::getSegmentType(int index)
205 QString elfparser::getSegmentType(int index)
207 {
206 {
208 QString type("");
207 QString type("");
209 if(this->e!=NULL)
208 if(this->e!=NULL)
210 {
209 {
211 if(index < this->Segments.count())
210 if(index < this->Segments.count())
212 {
211 {
213 switch(this->Segments.at(index)->p_type)
212 switch(this->Segments.at(index)->p_type)
214 {
213 {
215 case PT_NULL:
214 case PT_NULL:
216 type = "Program header table entry unused";
215 type = "Program header table entry unused";
217 break;
216 break;
218 case PT_LOAD:
217 case PT_LOAD:
219 type = "Loadable program segment";
218 type = "Loadable program segment";
220 break;
219 break;
221 case PT_DYNAMIC :
220 case PT_DYNAMIC :
222 type = "Dynamic linking information";
221 type = "Dynamic linking information";
223 break;
222 break;
224 case PT_INTERP:
223 case PT_INTERP:
225 type ="Program interpreter";
224 type ="Program interpreter";
226 break;
225 break;
227 case PT_NOTE:
226 case PT_NOTE:
228 type = "Auxiliary information";
227 type = "Auxiliary information";
229 break;
228 break;
230 case PT_SHLIB:
229 case PT_SHLIB:
231 type = "Reserved";
230 type = "Reserved";
232 break;
231 break;
233 case PT_PHDR:
232 case PT_PHDR:
234 type = "Entry for header table itself";
233 type = "Entry for header table itself";
235 break;
234 break;
236 case PT_TLS:
235 case PT_TLS:
237 type = "Thread-local storage segment";
236 type = "Thread-local storage segment";
238 break;
237 break;
239 case PT_NUM:
238 case PT_NUM:
240 type = "Number of defined types";
239 type = "Number of defined types";
241 break;
240 break;
242 case PT_LOOS:
241 case PT_LOOS:
243 type = "Start of OS-specific";
242 type = "Start of OS-specific";
244 break;
243 break;
245 case PT_SUNWSTACK:
244 case PT_SUNWSTACK:
246 type = "Stack segment";
245 type = "Stack segment";
247 break;
246 break;
248 case PT_LOPROC:
247 case PT_LOPROC:
249 type = "Start of processor-specific";
248 type = "Start of processor-specific";
250 break;
249 break;
251 case PT_HIPROC:
250 case PT_HIPROC:
252 type = "End of processor-specific";
251 type = "End of processor-specific";
253 break;
252 break;
254 default:
253 default:
255 type = "Unknow Section Type";
254 type = "Unknow Section Type";
256 break;
255 break;
257 }
256 }
258 }
257 }
259 }
258 }
260
259
261 return type;
260 return type;
262 }
261 }
263
262
264
263
265 qint64 elfparser::getSegmentOffset(int index)
264 qint64 elfparser::getSegmentOffset(int index)
266 {
265 {
267 qint64 Offset=-1;
266 qint64 Offset=-1;
268 if(this->e!=NULL)
267 if(this->e!=NULL)
269 {
268 {
270 if(index < this->Segments.count())
269 if(index < this->Segments.count())
271 {
270 {
272 Offset = (qint64)this->Segments.at(index)->p_offset;
271 Offset = (qint64)this->Segments.at(index)->p_offset;
273 }
272 }
274 }
273 }
275 return Offset;
274 return Offset;
276 }
275 }
277
276
278
277
279 qint64 elfparser::getSegmentVaddr(int index)
278 qint64 elfparser::getSegmentVaddr(int index)
280 {
279 {
281 int64_t Vaddr = 0;
280 int64_t Vaddr = 0;
282 if(this->e!=NULL)
281 if(this->e!=NULL)
283 {
282 {
284 if(index < this->Segments.count())
283 if(index < this->Segments.count())
285 {
284 {
286 Vaddr = (int64_t)this->Segments.at(index)->p_vaddr;
285 Vaddr = (int64_t)this->Segments.at(index)->p_vaddr;
287 }
286 }
288 }
287 }
289 return Vaddr;
288 return Vaddr;
290 }
289 }
291
290
292
291
293 qint64 elfparser::getSegmentPaddr(int index)
292 qint64 elfparser::getSegmentPaddr(int index)
294 {
293 {
295 int64_t Paddr=0;
294 int64_t Paddr=0;
296 if(this->e!=NULL)
295 if(this->e!=NULL)
297 {
296 {
298 if(index < this->Segments.count())
297 if(index < this->Segments.count())
299 {
298 {
300 Paddr = (int64_t)this->Segments.at(index)->p_paddr;
299 Paddr = (int64_t)this->Segments.at(index)->p_paddr;
301 }
300 }
302 }
301 }
303 return Paddr;
302 return Paddr;
304 }
303 }
305
304
306 qint64 elfparser::getSectionPaddr(int index)
305 qint64 elfparser::getSectionPaddr(int index)
307 {
306 {
308 int64_t Paddr=0;
307 int64_t Paddr=0;
309 if(this->e!=NULL)
308 if(this->e!=NULL)
310 {
309 {
311 if(index < this->sections.count())
310 if(index < this->sections.count())
312 {
311 {
313 Paddr = (int64_t)this->sections.at(index)->section_header->sh_addr;
312 Paddr = (int64_t)this->sections.at(index)->section_header->sh_addr;
314 }
313 }
315 }
314 }
316 return Paddr;
315 return Paddr;
317 }
316 }
318
317
319
318
320 qint64 elfparser::getSegmentFilesz(int index)
319 qint64 elfparser::getSegmentFilesz(int index)
321 {
320 {
322 int64_t FileSz=0;
321 int64_t FileSz=0;
323 if(this->e!=NULL)
322 if(this->e!=NULL)
324 {
323 {
325 if(index < this->Segments.count())
324 if(index < this->Segments.count())
326 {
325 {
327 FileSz = (int64_t)this->Segments.at(index)->p_filesz;
326 FileSz = (int64_t)this->Segments.at(index)->p_filesz;
328 }
327 }
329 }
328 }
330 return FileSz;
329 return FileSz;
331 }
330 }
332
331
333 qint64 elfparser::getSectionDatasz(int index)
332 qint64 elfparser::getSectionDatasz(int index)
334 {
333 {
335 int64_t DataSz=0;
334 int64_t DataSz=0;
336 if(this->e!=NULL)
335 if(this->e!=NULL)
337 {
336 {
338 if(index < this->sections.count())
337 if(index < this->sections.count())
339 {
338 {
340 DataSz = (int64_t)this->sections.at(index)->data->d_size;
339 DataSz = (int64_t)this->sections.at(index)->data->d_size;
341 }
340 }
342 }
341 }
343 return DataSz;
342 return DataSz;
344 }
343 }
345
344
346 bool elfparser::getSectionData(int index, char **buffer)
345 bool elfparser::getSectionData(int index, char **buffer)
347 {
346 {
348 if(this->e!=NULL)
347 if(this->e!=NULL)
349 {
348 {
350 if(index < this->sections.count())
349 if(index < this->sections.count())
351 {
350 {
352 *buffer = (char *)this->sections.at(index)->data->d_buf;
351 *buffer = (char *)this->sections.at(index)->data->d_buf;
353 return true;
352 return true;
354 }
353 }
355 }
354 }
356 return false;
355 return false;
357 }
356 }
358
357
359
358
360 qint64 elfparser::getSegmentMemsz(int index)
359 qint64 elfparser::getSegmentMemsz(int index)
361 {
360 {
362 int64_t MemSz=0;
361 int64_t MemSz=0;
363 if(this->e!=NULL)
362 if(this->e!=NULL)
364 {
363 {
365 if(index < this->Segments.count())
364 if(index < this->Segments.count())
366 {
365 {
367 MemSz = (int64_t)this->Segments.at(index)->p_memsz;
366 MemSz = (int64_t)this->Segments.at(index)->p_memsz;
368 }
367 }
369 }
368 }
370 return MemSz;
369 return MemSz;
371 }
370 }
372
371
373 qint64 elfparser::getSectionMemsz(int index)
372 qint64 elfparser::getSectionMemsz(int index)
374 {
373 {
375 int64_t MemSz=0;
374 int64_t MemSz=0;
376 if(this->e!=NULL)
375 if(this->e!=NULL)
377 {
376 {
378 if(index < this->sections.count())
377 if(index < this->sections.count())
379 {
378 {
380 MemSz = (int64_t)this->sections.at(index)->section_header->sh_size;
379 MemSz = (int64_t)this->sections.at(index)->section_header->sh_size;
381 }
380 }
382 }
381 }
383 return MemSz;
382 return MemSz;
384 }
383 }
385
384
386
385
387 QString elfparser::getSegmentFlags(int index)
386 QString elfparser::getSegmentFlags(int index)
388 {
387 {
389 QString flags("");
388 QString flags("");
390 if(this->e!=NULL)
389 if(this->e!=NULL)
391 {
390 {
392 if(index < this->Segments.count())
391 if(index < this->Segments.count())
393 {
392 {
394 if((this->Segments.at(index)->p_flags&PF_X) == PF_X)flags+="x";
393 if((this->Segments.at(index)->p_flags&PF_X) == PF_X)flags+="x";
395 if((this->Segments.at(index)->p_flags&PF_W) == PF_W)flags+="w";
394 if((this->Segments.at(index)->p_flags&PF_W) == PF_W)flags+="w";
396 if((this->Segments.at(index)->p_flags&PF_R) == PF_R)flags+="r";
395 if((this->Segments.at(index)->p_flags&PF_R) == PF_R)flags+="r";
397 if((this->Segments.at(index)->p_flags&PF_MASKOS) == PF_MASKOS)flags+=" OS-specific";
396 if((this->Segments.at(index)->p_flags&PF_MASKOS) == PF_MASKOS)flags+=" OS-specific";
398 if((this->Segments.at(index)->p_flags&PF_MASKPROC) == PF_MASKPROC)flags+=" Processor-specific";
397 if((this->Segments.at(index)->p_flags&PF_MASKPROC) == PF_MASKPROC)flags+=" Processor-specific";
399 }
398 }
400 }
399 }
401 return flags;
400 return flags;
402 }
401 }
403
402
404
403
405 QString elfparser::getSectionName(int index)
404 QString elfparser::getSectionName(int index)
406 {
405 {
407 char* nameChr = elf_strptr(this->e , this->shstrndx , this->sections.at(index)->section_header->sh_name);
406 char* nameChr = elf_strptr(this->e , this->shstrndx , this->sections.at(index)->section_header->sh_name);
408 return QString(nameChr);
407 return QString(nameChr);
409 }
408 }
410
409
411
410
412 void elfparser::updateSections()
411 void elfparser::updateSections()
413 {
412 {
414 for(int i=0;i<this->sections.count();i++)
413 for(int i=0;i<this->sections.count();i++)
415 {
414 {
416 delete this->sections.at(i);
415 delete this->sections.at(i);
417 }
416 }
418 this->sections.clear();
417 this->sections.clear();
419 this->scn = elf_nextscn (this->e , NULL );
418 this->scn = elf_nextscn (this->e , NULL );
420 this->SectionCount = 0;
419 this->SectionCount = 0;
421 while( this->scn != NULL )
420 while( this->scn != NULL )
422 {
421 {
423 GElf_Shdr* shdr = (GElf_Shdr*)malloc(sizeof(GElf_Shdr));
422 GElf_Shdr* shdr = (GElf_Shdr*)malloc(sizeof(GElf_Shdr));
424 gelf_getshdr ( this->scn , shdr );
423 gelf_getshdr ( this->scn , shdr );
425 Elf_Data* data = elf_getdata(this->scn, NULL);
424 Elf_Data* data = elf_getdata(this->scn, NULL);
426 this->sections.append(new Elf_Section(data,shdr));
425 this->sections.append(new Elf_Section(data,shdr));
427 this->SectionCount+=1;
426 this->SectionCount+=1;
428 this->scn = elf_nextscn(e , scn);
427 this->scn = elf_nextscn(e , scn);
429 }
428 }
430 }
429 }
431
430
432
431
433 void elfparser::updateSegments()
432 void elfparser::updateSegments()
434 {
433 {
435 elf_getphdrnum (this->e , &this->SegmentCount);
434 elf_getphdrnum (this->e , &this->SegmentCount);
436 for(int i=0;i<this->Segments.count();i++)
435 for(int i=0;i<this->Segments.count();i++)
437 {
436 {
438 free(this->Segments.at(i));
437 free(this->Segments.at(i));
439 }
438 }
440 this->Segments.clear();
439 this->Segments.clear();
441 for(int i=0;i<(int)this->SegmentCount;i++)
440 for(int i=0;i<(int)this->SegmentCount;i++)
442 {
441 {
443 GElf_Phdr* header=(GElf_Phdr*)malloc(sizeof(GElf_Phdr));
442 GElf_Phdr* header=(GElf_Phdr*)malloc(sizeof(GElf_Phdr));
444 gelf_getphdr (this->e , i , header );
443 gelf_getphdr (this->e , i , header );
445 this->Segments.append(header);
444 this->Segments.append(header);
446 }
445 }
447 }
446 }
448
447
449
448
450
449
451
450
452
451
453 QString elfparser::getSectionType(int index)
452 QString elfparser::getSectionType(int index)
454 {
453 {
455 QString type("");
454 QString type("");
456 if(this->e!=NULL)
455 if(this->e!=NULL)
457 {
456 {
458 if(index < this->Segments.count())
457 if(index < this->Segments.count())
459 {
458 {
460 switch(this->Segments.at(index)->p_type)
459 switch(this->Segments.at(index)->p_type)
461 {
460 {
462 case SHT_NULL : type = "Section header table entry unused"; break;
461 case SHT_NULL : type = "Section header table entry unused"; break;
463 case SHT_PROGBITS : type = "Program data"; break;
462 case SHT_PROGBITS : type = "Program data"; break;
464 case SHT_SYMTAB : type = "Symbol table"; break;
463 case SHT_SYMTAB : type = "Symbol table"; break;
465 case SHT_STRTAB : type = "String table"; break;
464 case SHT_STRTAB : type = "String table"; break;
466 case SHT_RELA : type = "Relocation entries with addends"; break;
465 case SHT_RELA : type = "Relocation entries with addends"; break;
467 case SHT_HASH : type = "Symbol hash table"; break;
466 case SHT_HASH : type = "Symbol hash table"; break;
468 case SHT_DYNAMIC : type = "Dynamic linking information"; break;
467 case SHT_DYNAMIC : type = "Dynamic linking information"; break;
469 case SHT_NOTE : type = "Notes"; break;
468 case SHT_NOTE : type = "Notes"; break;
470 case SHT_NOBITS :type = "Program space with no data (bss)"; break;
469 case SHT_NOBITS :type = "Program space with no data (bss)"; break;
471 case SHT_REL :type = "Relocation entries, no addends"; break;
470 case SHT_REL :type = "Relocation entries, no addends"; break;
472 case SHT_SHLIB : type = "Reserved"; break;
471 case SHT_SHLIB : type = "Reserved"; break;
473 case SHT_DYNSYM : type = "Dynamic linker symbol table"; break;
472 case SHT_DYNSYM : type = "Dynamic linker symbol table"; break;
474 case SHT_INIT_ARRAY : type = "Array of constructors"; break;
473 case SHT_INIT_ARRAY : type = "Array of constructors"; break;
475 case SHT_FINI_ARRAY : type = "Array of destructors"; break;
474 case SHT_FINI_ARRAY : type = "Array of destructors"; break;
476 case SHT_PREINIT_ARRAY : type = "Array of pre-constructors"; break;
475 case SHT_PREINIT_ARRAY : type = "Array of pre-constructors"; break;
477 case SHT_GROUP : type = "Section group"; break;
476 case SHT_GROUP : type = "Section group"; break;
478 case SHT_SYMTAB_SHNDX : type = "Extended section indeces"; break;
477 case SHT_SYMTAB_SHNDX : type = "Extended section indeces"; break;
479 case SHT_NUM : type = "Number of defined types. "; break;
478 case SHT_NUM : type = "Number of defined types. "; break;
480 case SHT_LOOS : type = "Start OS-specific. "; break;
479 case SHT_LOOS : type = "Start OS-specific. "; break;
481 case SHT_LOSUNW : type = "Sun-specific low bound. "; break;
480 case SHT_LOSUNW : type = "Sun-specific low bound. "; break;
482 case SHT_SUNW_COMDAT : type = " "; break;
481 case SHT_SUNW_COMDAT : type = " "; break;
483 case SHT_SUNW_syminfo : type = " "; break;
482 case SHT_SUNW_syminfo : type = " "; break;
484 case SHT_GNU_verdef : type = "Version definition section. "; break;
483 case SHT_GNU_verdef : type = "Version definition section. "; break;
485 case SHT_GNU_verneed : type = "Version needs section. "; break;
484 case SHT_GNU_verneed : type = "Version needs section. "; break;
486 case SHT_GNU_versym : type = "Version symbol table. "; break;
485 case SHT_GNU_versym : type = "Version symbol table. "; break;
487 case SHT_LOPROC : type = "Start of processor-specific"; break;
486 case SHT_LOPROC : type = "Start of processor-specific"; break;
488 case SHT_HIPROC : type = "End of processor-specific"; break;
487 case SHT_HIPROC : type = "End of processor-specific"; break;
489 case SHT_HIUSER : type = "End of application-specific"; break;
488 case SHT_HIUSER : type = "End of application-specific"; break;
490 }
489 }
491 }
490 }
492 }
491 }
493 return type;
492 return type;
494 }
493 }
495
494
496 bool elfparser::isElf(const QString &File)
495 bool elfparser::isElf(const QString &File)
497 {
496 {
498 int file =0;
497 int file =0;
499 #ifdef _ELF_WINDOWS_
498 #ifdef _ELF_WINDOWS_
500 file = open(File.toStdString().c_str(),O_RDONLY|O_BINARY ,0);
499 file = open(File.toStdString().c_str(),O_RDONLY|O_BINARY ,0);
501 #else
500 #else
502 file = open(File.toStdString().c_str(),O_RDONLY ,0);
501 file = open(File.toStdString().c_str(),O_RDONLY ,0);
503 #endif
502 #endif
504 char Magic[4];
503 char Magic[4];
505 if(file!=-1)
504 if(file!=-1)
506 {
505 {
507 size_t res = read(file,Magic,4);
506 size_t res = read(file,Magic,4);
508 close(file);
507 close(file);
509 if((res == 4) && (Magic[0]==0x7f) && (Magic[1]==0x45) && (Magic[2]==0x4c) && (Magic[3]==0x46))
508 if((res == 4) && (Magic[0]==0x7f) && (Magic[1]==0x45) && (Magic[2]==0x4c) && (Magic[3]==0x46))
510 {
509 {
511 return true;
510 return true;
512 }
511 }
513 }
512 }
514 return false;
513 return false;
515 }
514 }
516
515
517
516
518
517
519
518
520
519
521
520
522
521
523
522
@@ -1,996 +1,1002
1 /*
1 /*
2 * elf_repl.h - public header file for systems that lack it.
2 * elf_repl.h - public header file for systems that lack it.
3 * Copyright (C) 1995 - 2006 Michael Riepe
3 * Copyright (C) 1995 - 2006 Michael Riepe
4 *
4 *
5 * This library is free software; you can redistribute it and/or
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
8 * version 2 of the License, or (at your option) any later version.
9 *
9 *
10 * This library is distributed in the hope that it will be useful,
10 * This library 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 GNU
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
13 * Library General Public License for more details.
14 *
14 *
15 * You should have received a copy of the GNU Library General Public
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the Free Software
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
18 */
18 */
19
19
20 /* @(#) $Id: elf_repl.h,v 1.22 2009/11/01 13:04:19 michael Exp $ */
20 /* @(#) $Id: elf_repl.h,v 1.22 2009/11/01 13:04:19 michael Exp $ */
21
21
22 /*
22 /*
23 * NEVER INCLUDE THIS FILE DIRECTLY - USE <libelf.h> INSTEAD!
23 * NEVER INCLUDE THIS FILE DIRECTLY - USE <libelf.h> INSTEAD!
24 */
24 */
25
25
26 #ifndef _ELF_REPL_H
26 #ifndef _ELF_REPL_H
27 #define _ELF_REPL_H
27 #define _ELF_REPL_H
28
28
29 #ifdef __cplusplus
29 #ifdef __cplusplus
30 extern "C" {
30 extern "C" {
31 #endif /* __cplusplus */
31 #endif /* __cplusplus */
32
32
33 /*
33 /*
34 * Scalar data types
34 * Scalar data types
35 */
35 */
36 typedef __libelf_u32_t Elf32_Addr;
36 typedef __libelf_u32_t Elf32_Addr;
37 typedef __libelf_u16_t Elf32_Half;
37 typedef __libelf_u16_t Elf32_Half;
38 typedef __libelf_u32_t Elf32_Off;
38 typedef __libelf_u32_t Elf32_Off;
39 typedef __libelf_i32_t Elf32_Sword;
39 typedef __libelf_i32_t Elf32_Sword;
40 typedef __libelf_u32_t Elf32_Word;
40 typedef __libelf_u32_t Elf32_Word;
41
41
42 #define ELF32_FSZ_ADDR 4
42 #define ELF32_FSZ_ADDR 4
43 #define ELF32_FSZ_HALF 2
43 #define ELF32_FSZ_HALF 2
44 #define ELF32_FSZ_OFF 4
44 #define ELF32_FSZ_OFF 4
45 #define ELF32_FSZ_SWORD 4
45 #define ELF32_FSZ_SWORD 4
46 #define ELF32_FSZ_WORD 4
46 #define ELF32_FSZ_WORD 4
47
47
48 #if __LIBELF64
48 #if __LIBELF64
49
49
50 typedef __libelf_u64_t Elf64_Addr;
50 typedef __libelf_u64_t Elf64_Addr;
51 typedef __libelf_u16_t Elf64_Half;
51 typedef __libelf_u16_t Elf64_Half;
52 typedef __libelf_u64_t Elf64_Off;
52 typedef __libelf_u64_t Elf64_Off;
53 typedef __libelf_i32_t Elf64_Sword;
53 typedef __libelf_i32_t Elf64_Sword;
54 typedef __libelf_u32_t Elf64_Word;
54 typedef __libelf_u32_t Elf64_Word;
55 typedef __libelf_i64_t Elf64_Sxword;
55 typedef __libelf_i64_t Elf64_Sxword;
56 typedef __libelf_u64_t Elf64_Xword;
56 typedef __libelf_u64_t Elf64_Xword;
57
57
58 #define ELF64_FSZ_ADDR 8
58 #define ELF64_FSZ_ADDR 8
59 #define ELF64_FSZ_HALF 2
59 #define ELF64_FSZ_HALF 2
60 #define ELF64_FSZ_OFF 8
60 #define ELF64_FSZ_OFF 8
61 #define ELF64_FSZ_SWORD 4
61 #define ELF64_FSZ_SWORD 4
62 #define ELF64_FSZ_WORD 4
62 #define ELF64_FSZ_WORD 4
63 #define ELF64_FSZ_SXWORD 8
63 #define ELF64_FSZ_SXWORD 8
64 #define ELF64_FSZ_XWORD 8
64 #define ELF64_FSZ_XWORD 8
65
65
66 /*
66 /*
67 * Blame Sun for this...
67 * Blame Sun for this...
68 */
68 */
69 typedef __libelf_u64_t Elf64_Lword;
69 typedef __libelf_u64_t Elf64_Lword;
70 typedef __libelf_u64_t Elf32_Lword;
70 typedef __libelf_u64_t Elf32_Lword;
71
71
72 #endif /* __LIBELF64 */
72 #endif /* __LIBELF64 */
73
73
74 /*
74 /*
75 * ELF header
75 * ELF header
76 */
76 */
77 #define EI_NIDENT 16
77 #define EI_NIDENT 16
78
78
79 typedef struct {
79 typedef struct {
80 unsigned char e_ident[EI_NIDENT];
80 unsigned char e_ident[EI_NIDENT];
81 Elf32_Half e_type;
81 Elf32_Half e_type;
82 Elf32_Half e_machine;
82 Elf32_Half e_machine;
83 Elf32_Word e_version;
83 Elf32_Word e_version;
84 Elf32_Addr e_entry;
84 Elf32_Addr e_entry;
85 Elf32_Off e_phoff;
85 Elf32_Off e_phoff;
86 Elf32_Off e_shoff;
86 Elf32_Off e_shoff;
87 Elf32_Word e_flags;
87 Elf32_Word e_flags;
88 Elf32_Half e_ehsize;
88 Elf32_Half e_ehsize;
89 Elf32_Half e_phentsize;
89 Elf32_Half e_phentsize;
90 Elf32_Half e_phnum;
90 Elf32_Half e_phnum;
91 Elf32_Half e_shentsize;
91 Elf32_Half e_shentsize;
92 Elf32_Half e_shnum;
92 Elf32_Half e_shnum;
93 Elf32_Half e_shstrndx;
93 Elf32_Half e_shstrndx;
94 } Elf32_Ehdr;
94 } Elf32_Ehdr;
95
95
96 #if __LIBELF64
96 #if __LIBELF64
97 typedef struct {
97 typedef struct {
98 unsigned char e_ident[EI_NIDENT];
98 unsigned char e_ident[EI_NIDENT];
99 Elf64_Half e_type;
99 Elf64_Half e_type;
100 Elf64_Half e_machine;
100 Elf64_Half e_machine;
101 Elf64_Word e_version;
101 Elf64_Word e_version;
102 Elf64_Addr e_entry;
102 Elf64_Addr e_entry;
103 Elf64_Off e_phoff;
103 Elf64_Off e_phoff;
104 Elf64_Off e_shoff;
104 Elf64_Off e_shoff;
105 Elf64_Word e_flags;
105 Elf64_Word e_flags;
106 Elf64_Half e_ehsize;
106 Elf64_Half e_ehsize;
107 Elf64_Half e_phentsize;
107 Elf64_Half e_phentsize;
108 Elf64_Half e_phnum;
108 Elf64_Half e_phnum;
109 Elf64_Half e_shentsize;
109 Elf64_Half e_shentsize;
110 Elf64_Half e_shnum;
110 Elf64_Half e_shnum;
111 Elf64_Half e_shstrndx;
111 Elf64_Half e_shstrndx;
112 } Elf64_Ehdr;
112 } Elf64_Ehdr;
113 #endif /* __LIBELF64 */
113 #endif /* __LIBELF64 */
114
114
115 /*
115 /*
116 * e_ident
116 * e_ident
117 */
117 */
118 #define EI_MAG0 0
118 #define EI_MAG0 0
119 #define EI_MAG1 1
119 #define EI_MAG1 1
120 #define EI_MAG2 2
120 #define EI_MAG2 2
121 #define EI_MAG3 3
121 #define EI_MAG3 3
122 #define EI_CLASS 4
122 #define EI_CLASS 4
123 #define EI_DATA 5
123 #define EI_DATA 5
124 #define EI_VERSION 6
124 #define EI_VERSION 6
125 #define EI_OSABI 7
125 #define EI_OSABI 7
126 #define EI_ABIVERSION 8
126 #define EI_ABIVERSION 8
127 #define EI_PAD 9
127 #define EI_PAD 9
128
128
129 #define ELFMAG0 0x7f
129 #define ELFMAG0 0x7f
130 #define ELFMAG1 'E'
130 #define ELFMAG1 'E'
131 #define ELFMAG2 'L'
131 #define ELFMAG2 'L'
132 #define ELFMAG3 'F'
132 #define ELFMAG3 'F'
133 #define ELFMAG "\177ELF"
133 #define ELFMAG "\177ELF"
134 #define SELFMAG 4
134 #define SELFMAG 4
135
135
136 /*
136 /*
137 * e_ident[EI_CLASS]
137 * e_ident[EI_CLASS]
138 */
138 */
139 #define ELFCLASSNONE 0
139 #define ELFCLASSNONE 0
140 #define ELFCLASS32 1
140 #define ELFCLASS32 1
141 #define ELFCLASS64 2
141 #define ELFCLASS64 2
142 #define ELFCLASSNUM 3
142 #define ELFCLASSNUM 3
143
143
144 /*
144 /*
145 * e_ident[EI_DATA]
145 * e_ident[EI_DATA]
146 */
146 */
147 #define ELFDATANONE 0
147 #define ELFDATANONE 0
148 #define ELFDATA2LSB 1
148 #define ELFDATA2LSB 1
149 #define ELFDATA2MSB 2
149 #define ELFDATA2MSB 2
150 #define ELFDATANUM 3
150 #define ELFDATANUM 3
151
151
152 /*
152 /*
153 * e_ident[EI_OSABI]
153 * e_ident[EI_OSABI]
154 */
154 */
155 #define ELFOSABI_NONE 0 /* No extensions or unspecified */
155 #define ELFOSABI_NONE 0 /* No extensions or unspecified */
156 #define ELFOSABI_SYSV ELFOSABI_NONE
156 #define ELFOSABI_SYSV ELFOSABI_NONE
157 #define ELFOSABI_HPUX 1 /* Hewlett-Packard HP-UX */
157 #define ELFOSABI_HPUX 1 /* Hewlett-Packard HP-UX */
158 #define ELFOSABI_NETBSD 2 /* NetBSD */
158 #define ELFOSABI_NETBSD 2 /* NetBSD */
159 #define ELFOSABI_LINUX 3 /* Linux */
159 #define ELFOSABI_LINUX 3 /* Linux */
160 #define ELFOSABI_SOLARIS 6 /* Sun Solaris */
160 #define ELFOSABI_SOLARIS 6 /* Sun Solaris */
161 #define ELFOSABI_AIX 7 /* AIX */
161 #define ELFOSABI_AIX 7 /* AIX */
162 #define ELFOSABI_IRIX 8 /* IRIX */
162 #define ELFOSABI_IRIX 8 /* IRIX */
163 #define ELFOSABI_FREEBSD 9 /* FreeBSD */
163 #define ELFOSABI_FREEBSD 9 /* FreeBSD */
164 #define ELFOSABI_TRU64 10 /* Compaq TRU64 UNIX */
164 #define ELFOSABI_TRU64 10 /* Compaq TRU64 UNIX */
165 #define ELFOSABI_MODESTO 11 /* Novell Modesto */
165 #define ELFOSABI_MODESTO 11 /* Novell Modesto */
166 #define ELFOSABI_OPENBSD 12 /* Open BSD */
166 #define ELFOSABI_OPENBSD 12 /* Open BSD */
167 #define ELFOSABI_OPENVMS 13 /* Open VMS */
167 #define ELFOSABI_OPENVMS 13 /* Open VMS */
168 #define ELFOSABI_NSK 14 /* Hewlett-Packard Non-Stop Kernel */
168 #define ELFOSABI_NSK 14 /* Hewlett-Packard Non-Stop Kernel */
169 #define ELFOSABI_AROS 15 /* Amiga Research OS */
169 #define ELFOSABI_AROS 15 /* Amiga Research OS */
170 /* these are probably obsolete: */
170 /* these are probably obsolete: */
171 #define ELFOSABI_ARM_AEABI 64 /* ARM EABI */
171 #define ELFOSABI_ARM 97 /* ARM */
172 #define ELFOSABI_ARM 97 /* ARM */
172 #define ELFOSABI_STANDALONE 255 /* standalone (embedded) application */
173 #define ELFOSABI_STANDALONE 255 /* standalone (embedded) application */
173
174
174
175
175 /*
176 /*
176 * e_type
177 * e_type
177 */
178 */
178 #define ET_NONE 0
179 #define ET_NONE 0
179 #define ET_REL 1
180 #define ET_REL 1
180 #define ET_EXEC 2
181 #define ET_EXEC 2
181 #define ET_DYN 3
182 #define ET_DYN 3
182 #define ET_CORE 4
183 #define ET_CORE 4
183 #define ET_NUM 5
184 #define ET_NUM 5
184 #define ET_LOOS 0xfe00
185 #define ET_LOOS 0xfe00
185 #define ET_HIOS 0xfeff
186 #define ET_HIOS 0xfeff
186 #define ET_LOPROC 0xff00
187 #define ET_LOPROC 0xff00
187 #define ET_HIPROC 0xffff
188 #define ET_HIPROC 0xffff
188
189
189 /*
190 /*
190 * e_machine
191 * e_machine
191 */
192 */
192 #define EM_NONE 0 /* No machine */
193 #define EM_NONE 0 /* No machine */
193 #define EM_M32 1 /* AT&T WE 32100 */
194 #define EM_M32 1 /* AT&T WE 32100 */
194 #define EM_SPARC 2 /* SPARC */
195 #define EM_SPARC 2 /* SPARC */
195 #define EM_386 3 /* Intel 80386 */
196 #define EM_386 3 /* Intel 80386 */
196 #define EM_68K 4 /* Motorola 68000 */
197 #define EM_68K 4 /* Motorola 68000 */
197 #define EM_88K 5 /* Motorola 88000 */
198 #define EM_88K 5 /* Motorola 88000 */
198 #define EM_486 6 /* Intel i486 (DO NOT USE THIS ONE) */
199 #define EM_486 6 /* Intel i486 (DO NOT USE THIS ONE) */
199 #define EM_860 7 /* Intel 80860 */
200 #define EM_860 7 /* Intel 80860 */
200 #define EM_MIPS 8 /* MIPS I Architecture */
201 #define EM_MIPS 8 /* MIPS I Architecture */
201 #define EM_S370 9 /* IBM System/370 Processor */
202 #define EM_S370 9 /* IBM System/370 Processor */
202 #define EM_MIPS_RS3_LE 10 /* MIPS RS3000 Little-endian */
203 #define EM_MIPS_RS3_LE 10 /* MIPS RS3000 Little-endian */
203 #define EM_SPARC64 11 /* SPARC 64-bit */
204 #define EM_SPARC64 11 /* SPARC 64-bit */
204 #define EM_PARISC 15 /* Hewlett-Packard PA-RISC */
205 #define EM_PARISC 15 /* Hewlett-Packard PA-RISC */
205 #define EM_VPP500 17 /* Fujitsu VPP500 */
206 #define EM_VPP500 17 /* Fujitsu VPP500 */
206 #define EM_SPARC32PLUS 18 /* Enhanced instruction set SPARC */
207 #define EM_SPARC32PLUS 18 /* Enhanced instruction set SPARC */
207 #define EM_960 19 /* Intel 80960 */
208 #define EM_960 19 /* Intel 80960 */
208 #define EM_PPC 20 /* PowerPC */
209 #define EM_PPC 20 /* PowerPC */
209 #define EM_PPC64 21 /* 64-bit PowerPC */
210 #define EM_PPC64 21 /* 64-bit PowerPC */
210 #define EM_S390 22 /* IBM System/390 Processor */
211 #define EM_S390 22 /* IBM System/390 Processor */
211 #define EM_V800 36 /* NEC V800 */
212 #define EM_V800 36 /* NEC V800 */
212 #define EM_FR20 37 /* Fujitsu FR20 */
213 #define EM_FR20 37 /* Fujitsu FR20 */
213 #define EM_RH32 38 /* TRW RH-32 */
214 #define EM_RH32 38 /* TRW RH-32 */
214 #define EM_RCE 39 /* Motorola RCE */
215 #define EM_RCE 39 /* Motorola RCE */
215 #define EM_ARM 40 /* Advanced RISC Machines ARM */
216 #define EM_ARM 40 /* Advanced RISC Machines ARM */
216 #define EM_ALPHA 41 /* Digital Alpha */
217 #define EM_FAKE_ALPHA 41 /* Digital Alpha */
217 #define EM_SH 42 /* Hitachi SH */
218 #define EM_SH 42 /* Hitachi SH */
218 #define EM_SPARCV9 43 /* SPARC Version 9 */
219 #define EM_SPARCV9 43 /* SPARC Version 9 */
219 #define EM_TRICORE 44 /* Siemens TriCore embedded processor */
220 #define EM_TRICORE 44 /* Siemens TriCore embedded processor */
220 #define EM_ARC 45 /* Argonaut RISC Core, Argonaut Technologies Inc. */
221 #define EM_ARC 45 /* Argonaut RISC Core, Argonaut Technologies Inc. */
221 #define EM_H8_300 46 /* Hitachi H8/300 */
222 #define EM_H8_300 46 /* Hitachi H8/300 */
222 #define EM_H8_300H 47 /* Hitachi H8/300H */
223 #define EM_H8_300H 47 /* Hitachi H8/300H */
223 #define EM_H8S 48 /* Hitachi H8S */
224 #define EM_H8S 48 /* Hitachi H8S */
224 #define EM_H8_500 49 /* Hitachi H8/500 */
225 #define EM_H8_500 49 /* Hitachi H8/500 */
225 #define EM_IA_64 50 /* Intel IA-64 processor architecture */
226 #define EM_IA_64 50 /* Intel IA-64 processor architecture */
226 #define EM_MIPS_X 51 /* Stanford MIPS-X */
227 #define EM_MIPS_X 51 /* Stanford MIPS-X */
227 #define EM_COLDFIRE 52 /* Motorola ColdFire */
228 #define EM_COLDFIRE 52 /* Motorola ColdFire */
228 #define EM_68HC12 53 /* Motorola M68HC12 */
229 #define EM_68HC12 53 /* Motorola M68HC12 */
229 #define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator */
230 #define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator */
230 #define EM_PCP 55 /* Siemens PCP */
231 #define EM_PCP 55 /* Siemens PCP */
231 #define EM_NCPU 56 /* Sony nCPU embedded RISC processor */
232 #define EM_NCPU 56 /* Sony nCPU embedded RISC processor */
232 #define EM_NDR1 57 /* Denso NDR1 microprocessor */
233 #define EM_NDR1 57 /* Denso NDR1 microprocessor */
233 #define EM_STARCORE 58 /* Motorola Star*Core processor */
234 #define EM_STARCORE 58 /* Motorola Star*Core processor */
234 #define EM_ME16 59 /* Toyota ME16 processor */
235 #define EM_ME16 59 /* Toyota ME16 processor */
235 #define EM_ST100 60 /* STMicroelectronics ST100 processor */
236 #define EM_ST100 60 /* STMicroelectronics ST100 processor */
236 #define EM_TINYJ 61 /* Advanced Logic Corp. TinyJ embedded processor family */
237 #define EM_TINYJ 61 /* Advanced Logic Corp. TinyJ embedded processor family */
237 #define EM_X86_64 62 /* AMD x86-64 architecture */
238 #define EM_X86_64 62 /* AMD x86-64 architecture */
238 #define EM_AMD64 EM_X86_64
239 #define EM_AMD64 EM_X86_64
239 #define EM_PDSP 63 /* Sony DSP Processor */
240 #define EM_PDSP 63 /* Sony DSP Processor */
240 #define EM_FX66 66 /* Siemens FX66 microcontroller */
241 #define EM_FX66 66 /* Siemens FX66 microcontroller */
241 #define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 bit microcontroller */
242 #define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 bit microcontroller */
242 #define EM_ST7 68 /* STMicroelectronics ST7 8-bit microcontroller */
243 #define EM_ST7 68 /* STMicroelectronics ST7 8-bit microcontroller */
243 #define EM_68HC16 69 /* Motorola MC68HC16 Microcontroller */
244 #define EM_68HC16 69 /* Motorola MC68HC16 Microcontroller */
244 #define EM_68HC11 70 /* Motorola MC68HC11 Microcontroller */
245 #define EM_68HC11 70 /* Motorola MC68HC11 Microcontroller */
245 #define EM_68HC08 71 /* Motorola MC68HC08 Microcontroller */
246 #define EM_68HC08 71 /* Motorola MC68HC08 Microcontroller */
246 #define EM_68HC05 72 /* Motorola MC68HC05 Microcontroller */
247 #define EM_68HC05 72 /* Motorola MC68HC05 Microcontroller */
247 #define EM_SVX 73 /* Silicon Graphics SVx */
248 #define EM_SVX 73 /* Silicon Graphics SVx */
248 #define EM_ST19 74 /* STMicroelectronics ST19 8-bit microcontroller */
249 #define EM_ST19 74 /* STMicroelectronics ST19 8-bit microcontroller */
249 #define EM_VAX 75 /* Digital VAX */
250 #define EM_VAX 75 /* Digital VAX */
250 #define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */
251 #define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */
251 #define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded processor */
252 #define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded processor */
252 #define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor */
253 #define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor */
253 #define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor */
254 #define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor */
254 #define EM_MMIX 80 /* Donald Knuth's educational 64-bit processor */
255 #define EM_MMIX 80 /* Donald Knuth's educational 64-bit processor */
255 #define EM_HUANY 81 /* Harvard University machine-independent object files */
256 #define EM_HUANY 81 /* Harvard University machine-independent object files */
256 #define EM_PRISM 82 /* SiTera Prism */
257 #define EM_PRISM 82 /* SiTera Prism */
257 #define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */
258 #define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */
258 #define EM_FR30 84 /* Fujitsu FR30 */
259 #define EM_FR30 84 /* Fujitsu FR30 */
259 #define EM_D10V 85 /* Mitsubishi D10V */
260 #define EM_D10V 85 /* Mitsubishi D10V */
260 #define EM_D30V 86 /* Mitsubishi D30V */
261 #define EM_D30V 86 /* Mitsubishi D30V */
261 #define EM_V850 87 /* NEC v850 */
262 #define EM_V850 87 /* NEC v850 */
262 #define EM_M32R 88 /* Mitsubishi M32R */
263 #define EM_M32R 88 /* Mitsubishi M32R */
263 #define EM_MN10300 89 /* Matsushita MN10300 */
264 #define EM_MN10300 89 /* Matsushita MN10300 */
264 #define EM_MN10200 90 /* Matsushita MN10200 */
265 #define EM_MN10200 90 /* Matsushita MN10200 */
265 #define EM_PJ 91 /* picoJava */
266 #define EM_PJ 91 /* picoJava */
266 #define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */
267 #define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */
267 #define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */
268 #define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */
268 #define EM_XTENSA 94 /* Tensilica Xtensa Architecture */
269 #define EM_XTENSA 94 /* Tensilica Xtensa Architecture */
269 #define EM_VIDEOCORE 95 /* Alphamosaic VideoCore processor */
270 #define EM_VIDEOCORE 95 /* Alphamosaic VideoCore processor */
270 #define EM_TMM_GPP 96 /* Thompson Multimedia General Purpose Processor */
271 #define EM_TMM_GPP 96 /* Thompson Multimedia General Purpose Processor */
271 #define EM_NS32K 97 /* National Semiconductor 32000 series */
272 #define EM_NS32K 97 /* National Semiconductor 32000 series */
272 #define EM_TPC 98 /* Tenor Network TPC processor */
273 #define EM_TPC 98 /* Tenor Network TPC processor */
273 #define EM_SNP1K 99 /* Trebia SNP 1000 processor */
274 #define EM_SNP1K 99 /* Trebia SNP 1000 processor */
274 #define EM_ST200 100 /* STMicroelectronics (www.st.com) ST200 microcontroller */
275 #define EM_ST200 100 /* STMicroelectronics (www.st.com) ST200 microcontroller */
275 #define EM_IP2K 101 /* Ubicom IP2xxx microcontroller family */
276 #define EM_IP2K 101 /* Ubicom IP2xxx microcontroller family */
276 #define EM_MAX 102 /* MAX Processor */
277 #define EM_MAX 102 /* MAX Processor */
277 #define EM_CR 103 /* National Semiconductor CompactRISC microprocessor */
278 #define EM_CR 103 /* National Semiconductor CompactRISC microprocessor */
278 #define EM_F2MC16 104 /* Fujitsu F2MC16 */
279 #define EM_F2MC16 104 /* Fujitsu F2MC16 */
279 #define EM_MSP430 105 /* Texas Instruments embedded microcontroller msp430 */
280 #define EM_MSP430 105 /* Texas Instruments embedded microcontroller msp430 */
280 #define EM_BLACKFIN 106 /* Analog Devices Blackfin (DSP) processor */
281 #define EM_BLACKFIN 106 /* Analog Devices Blackfin (DSP) processor */
281 #define EM_SE_C33 107 /* S1C33 Family of Seiko Epson processors */
282 #define EM_SE_C33 107 /* S1C33 Family of Seiko Epson processors */
282 #define EM_SEP 108 /* Sharp embedded microprocessor */
283 #define EM_SEP 108 /* Sharp embedded microprocessor */
283 #define EM_ARCA 109 /* Arca RISC Microprocessor */
284 #define EM_ARCA 109 /* Arca RISC Microprocessor */
284 #define EM_UNICORE 110 /* Microprocessor series from PKU-Unity Ltd. and MPRC of Peking University */
285 #define EM_UNICORE 110 /* Microprocessor series from PKU-Unity Ltd. and MPRC of Peking University */
285 #define EM_NUM 111
286 #define EM_AARCH64 183 /* ARM AARCH64 */
287 #define EM_TILEPRO 188 /* Tilera TILEPro */
288 #define EM_MICROBLAZE 189 /* Xilinx MicroBlaze */
289 #define EM_TILEGX 191 /* Tilera TILE-Gx */
290 #define EM_NUM 192
291
286
292
287 /*
293 /*
288 * e_ident[EI_VERSION], e_version
294 * e_ident[EI_VERSION], e_version
289 */
295 */
290 #define EV_NONE 0
296 #define EV_NONE 0
291 #define EV_CURRENT 1
297 #define EV_CURRENT 1
292 #define EV_NUM 2
298 #define EV_NUM 2
293
299
294 /*
300 /*
295 * Section header
301 * Section header
296 */
302 */
297 typedef struct {
303 typedef struct {
298 Elf32_Word sh_name;
304 Elf32_Word sh_name;
299 Elf32_Word sh_type;
305 Elf32_Word sh_type;
300 Elf32_Word sh_flags;
306 Elf32_Word sh_flags;
301 Elf32_Addr sh_addr;
307 Elf32_Addr sh_addr;
302 Elf32_Off sh_offset;
308 Elf32_Off sh_offset;
303 Elf32_Word sh_size;
309 Elf32_Word sh_size;
304 Elf32_Word sh_link;
310 Elf32_Word sh_link;
305 Elf32_Word sh_info;
311 Elf32_Word sh_info;
306 Elf32_Word sh_addralign;
312 Elf32_Word sh_addralign;
307 Elf32_Word sh_entsize;
313 Elf32_Word sh_entsize;
308 } Elf32_Shdr;
314 } Elf32_Shdr;
309
315
310 #if __LIBELF64
316 #if __LIBELF64
311 typedef struct {
317 typedef struct {
312 Elf64_Word sh_name;
318 Elf64_Word sh_name;
313 Elf64_Word sh_type;
319 Elf64_Word sh_type;
314 Elf64_Xword sh_flags;
320 Elf64_Xword sh_flags;
315 Elf64_Addr sh_addr;
321 Elf64_Addr sh_addr;
316 Elf64_Off sh_offset;
322 Elf64_Off sh_offset;
317 Elf64_Xword sh_size;
323 Elf64_Xword sh_size;
318 Elf64_Word sh_link;
324 Elf64_Word sh_link;
319 Elf64_Word sh_info;
325 Elf64_Word sh_info;
320 Elf64_Xword sh_addralign;
326 Elf64_Xword sh_addralign;
321 Elf64_Xword sh_entsize;
327 Elf64_Xword sh_entsize;
322 } Elf64_Shdr;
328 } Elf64_Shdr;
323 #endif /* __LIBELF64 */
329 #endif /* __LIBELF64 */
324
330
325 /*
331 /*
326 * Special section indices
332 * Special section indices
327 */
333 */
328 #define SHN_UNDEF 0
334 #define SHN_UNDEF 0
329 #define SHN_LORESERVE 0xff00
335 #define SHN_LORESERVE 0xff00
330 #define SHN_LOPROC 0xff00
336 #define SHN_LOPROC 0xff00
331 #define SHN_HIPROC 0xff1f
337 #define SHN_HIPROC 0xff1f
332 #define SHN_LOOS 0xff20
338 #define SHN_LOOS 0xff20
333 #define SHN_HIOS 0xff3f
339 #define SHN_HIOS 0xff3f
334 #define SHN_ABS 0xfff1
340 #define SHN_ABS 0xfff1
335 #define SHN_COMMON 0xfff2
341 #define SHN_COMMON 0xfff2
336 #define SHN_XINDEX 0xffff
342 #define SHN_XINDEX 0xffff
337 #define SHN_HIRESERVE 0xffff
343 #define SHN_HIRESERVE 0xffff
338
344
339 /*
345 /*
340 * sh_type
346 * sh_type
341 */
347 */
342 #define SHT_NULL 0
348 #define SHT_NULL 0
343 #define SHT_PROGBITS 1
349 #define SHT_PROGBITS 1
344 #define SHT_SYMTAB 2
350 #define SHT_SYMTAB 2
345 #define SHT_STRTAB 3
351 #define SHT_STRTAB 3
346 #define SHT_RELA 4
352 #define SHT_RELA 4
347 #define SHT_HASH 5
353 #define SHT_HASH 5
348 #define SHT_DYNAMIC 6
354 #define SHT_DYNAMIC 6
349 #define SHT_NOTE 7
355 #define SHT_NOTE 7
350 #define SHT_NOBITS 8
356 #define SHT_NOBITS 8
351 #define SHT_REL 9
357 #define SHT_REL 9
352 #define SHT_SHLIB 10
358 #define SHT_SHLIB 10
353 #define SHT_DYNSYM 11
359 #define SHT_DYNSYM 11
354 #define SHT_INIT_ARRAY 14
360 #define SHT_INIT_ARRAY 14
355 #define SHT_FINI_ARRAY 15
361 #define SHT_FINI_ARRAY 15
356 #define SHT_PREINIT_ARRAY 16
362 #define SHT_PREINIT_ARRAY 16
357 #define SHT_GROUP 17
363 #define SHT_GROUP 17
358 #define SHT_SYMTAB_SHNDX 18
364 #define SHT_SYMTAB_SHNDX 18
359 #define SHT_NUM 19
365 #define SHT_NUM 19
360 #define SHT_LOOS 0x60000000
366 #define SHT_LOOS 0x60000000
361 #define SHT_HIOS 0x6fffffff
367 #define SHT_HIOS 0x6fffffff
362 #define SHT_LOPROC 0x70000000
368 #define SHT_LOPROC 0x70000000
363 #define SHT_HIPROC 0x7fffffff
369 #define SHT_HIPROC 0x7fffffff
364 #define SHT_LOUSER 0x80000000
370 #define SHT_LOUSER 0x80000000
365 #define SHT_HIUSER 0xffffffff
371 #define SHT_HIUSER 0xffffffff
366
372
367 /*
373 /*
368 * Solaris extensions
374 * Solaris extensions
369 */
375 */
370 #define SHT_LOSUNW 0x6ffffff4
376 #define SHT_LOSUNW 0x6ffffff4
371 #define SHT_SUNW_dof 0x6ffffff4
377 #define SHT_SUNW_dof 0x6ffffff4
372 #define SHT_SUNW_cap 0x6ffffff5
378 #define SHT_SUNW_cap 0x6ffffff5
373 #define SHT_SUNW_SIGNATURE 0x6ffffff6
379 #define SHT_SUNW_SIGNATURE 0x6ffffff6
374 #define SHT_SUNW_ANNOTATE 0x6ffffff7
380 #define SHT_SUNW_ANNOTATE 0x6ffffff7
375 #define SHT_SUNW_DEBUGSTR 0x6ffffff8
381 #define SHT_SUNW_DEBUGSTR 0x6ffffff8
376 #define SHT_SUNW_DEBUG 0x6ffffff9
382 #define SHT_SUNW_DEBUG 0x6ffffff9
377 #define SHT_SUNW_move 0x6ffffffa
383 #define SHT_SUNW_move 0x6ffffffa
378 #define SHT_SUNW_COMDAT 0x6ffffffb
384 #define SHT_SUNW_COMDAT 0x6ffffffb
379 #define SHT_SUNW_syminfo 0x6ffffffc
385 #define SHT_SUNW_syminfo 0x6ffffffc
380 #define SHT_SUNW_verdef 0x6ffffffd
386 #define SHT_SUNW_verdef 0x6ffffffd
381 #define SHT_SUNW_verneed 0x6ffffffe
387 #define SHT_SUNW_verneed 0x6ffffffe
382 #define SHT_SUNW_versym 0x6fffffff
388 #define SHT_SUNW_versym 0x6fffffff
383 #define SHT_HISUNW 0x6fffffff
389 #define SHT_HISUNW 0x6fffffff
384
390
385 #define SHT_SPARC_GOTDATA 0x70000000
391 #define SHT_SPARC_GOTDATA 0x70000000
386 #define SHT_AMD64_UNWIND 0x70000001
392 #define SHT_AMD64_UNWIND 0x70000001
387
393
388 /*
394 /*
389 * GNU extensions
395 * GNU extensions
390 */
396 */
391 #define SHT_GNU_verdef 0x6ffffffd
397 #define SHT_GNU_verdef 0x6ffffffd
392 #define SHT_GNU_verneed 0x6ffffffe
398 #define SHT_GNU_verneed 0x6ffffffe
393 #define SHT_GNU_versym 0x6fffffff
399 #define SHT_GNU_versym 0x6fffffff
394
400
395 /*
401 /*
396 * sh_flags
402 * sh_flags
397 */
403 */
398 #define SHF_WRITE 0x1
404 #define SHF_WRITE 0x1
399 #define SHF_ALLOC 0x2
405 #define SHF_ALLOC 0x2
400 #define SHF_EXECINSTR 0x4
406 #define SHF_EXECINSTR 0x4
401 #define SHF_MERGE 0x10
407 #define SHF_MERGE 0x10
402 #define SHF_STRINGS 0x20
408 #define SHF_STRINGS 0x20
403 #define SHF_INFO_LINK 0x40
409 #define SHF_INFO_LINK 0x40
404 #define SHF_LINK_ORDER 0x80
410 #define SHF_LINK_ORDER 0x80
405 #define SHF_OS_NONCONFORMING 0x100
411 #define SHF_OS_NONCONFORMING 0x100
406 #define SHF_GROUP 0x200
412 #define SHF_GROUP 0x200
407 #define SHF_TLS 0x400
413 #define SHF_TLS 0x400
408 #define SHF_MASKOS 0x0ff00000
414 #define SHF_MASKOS 0x0ff00000
409 #define SHF_MASKPROC 0xf0000000
415 #define SHF_MASKPROC 0xf0000000
410
416
411 /*
417 /*
412 * Solaris extensions
418 * Solaris extensions
413 */
419 */
414 #define SHF_AMD64_LARGE 0x10000000
420 #define SHF_AMD64_LARGE 0x10000000
415 #define SHF_ORDERED 0x40000000
421 #define SHF_ORDERED 0x40000000
416 #define SHF_EXCLUDE 0x80000000
422 #define SHF_EXCLUDE 0x80000000
417
423
418 /*
424 /*
419 * Section group flags
425 * Section group flags
420 */
426 */
421 #define GRP_COMDAT 0x1
427 #define GRP_COMDAT 0x1
422 #define GRP_MASKOS 0x0ff00000
428 #define GRP_MASKOS 0x0ff00000
423 #define GRP_MASKPROC 0xf0000000
429 #define GRP_MASKPROC 0xf0000000
424
430
425 /*
431 /*
426 * Symbol table
432 * Symbol table
427 */
433 */
428 typedef struct {
434 typedef struct {
429 Elf32_Word st_name;
435 Elf32_Word st_name;
430 Elf32_Addr st_value;
436 Elf32_Addr st_value;
431 Elf32_Word st_size;
437 Elf32_Word st_size;
432 unsigned char st_info;
438 unsigned char st_info;
433 unsigned char st_other;
439 unsigned char st_other;
434 Elf32_Half st_shndx;
440 Elf32_Half st_shndx;
435 } Elf32_Sym;
441 } Elf32_Sym;
436
442
437 #if __LIBELF64
443 #if __LIBELF64
438 typedef struct {
444 typedef struct {
439 Elf64_Word st_name;
445 Elf64_Word st_name;
440 unsigned char st_info;
446 unsigned char st_info;
441 unsigned char st_other;
447 unsigned char st_other;
442 Elf64_Half st_shndx;
448 Elf64_Half st_shndx;
443 Elf64_Addr st_value;
449 Elf64_Addr st_value;
444 Elf64_Xword st_size;
450 Elf64_Xword st_size;
445 } Elf64_Sym;
451 } Elf64_Sym;
446 #endif /* __LIBELF64 */
452 #endif /* __LIBELF64 */
447
453
448 /*
454 /*
449 * Special symbol indices
455 * Special symbol indices
450 */
456 */
451 #define STN_UNDEF 0
457 #define STN_UNDEF 0
452
458
453 /*
459 /*
454 * Macros for manipulating st_info
460 * Macros for manipulating st_info
455 */
461 */
456 #define ELF32_ST_BIND(i) ((i)>>4)
462 #define ELF32_ST_BIND(i) ((i)>>4)
457 #define ELF32_ST_TYPE(i) ((i)&0xf)
463 #define ELF32_ST_TYPE(i) ((i)&0xf)
458 #define ELF32_ST_INFO(b,t) (((b)<<4)+((t)&0xf))
464 #define ELF32_ST_INFO(b,t) (((b)<<4)+((t)&0xf))
459
465
460 #if __LIBELF64
466 #if __LIBELF64
461 #define ELF64_ST_BIND(i) ((i)>>4)
467 #define ELF64_ST_BIND(i) ((i)>>4)
462 #define ELF64_ST_TYPE(i) ((i)&0xf)
468 #define ELF64_ST_TYPE(i) ((i)&0xf)
463 #define ELF64_ST_INFO(b,t) (((b)<<4)+((t)&0xf))
469 #define ELF64_ST_INFO(b,t) (((b)<<4)+((t)&0xf))
464 #endif /* __LIBELF64 */
470 #endif /* __LIBELF64 */
465
471
466 /*
472 /*
467 * Symbol binding
473 * Symbol binding
468 */
474 */
469 #define STB_LOCAL 0
475 #define STB_LOCAL 0
470 #define STB_GLOBAL 1
476 #define STB_GLOBAL 1
471 #define STB_WEAK 2
477 #define STB_WEAK 2
472 #define STB_NUM 3
478 #define STB_NUM 3
473 #define STB_LOOS 10
479 #define STB_LOOS 10
474 #define STB_HIOS 12
480 #define STB_HIOS 12
475 #define STB_LOPROC 13
481 #define STB_LOPROC 13
476 #define STB_HIPROC 15
482 #define STB_HIPROC 15
477
483
478 /*
484 /*
479 * Symbol types
485 * Symbol types
480 */
486 */
481 #define STT_NOTYPE 0
487 #define STT_NOTYPE 0
482 #define STT_OBJECT 1
488 #define STT_OBJECT 1
483 #define STT_FUNC 2
489 #define STT_FUNC 2
484 #define STT_SECTION 3
490 #define STT_SECTION 3
485 #define STT_FILE 4
491 #define STT_FILE 4
486 #define STT_COMMON 5
492 #define STT_COMMON 5
487 #define STT_TLS 6
493 #define STT_TLS 6
488 #define STT_NUM 7
494 #define STT_NUM 7
489 #define STT_LOOS 10
495 #define STT_LOOS 10
490 #define STT_HIOS 12
496 #define STT_HIOS 12
491 #define STT_LOPROC 13
497 #define STT_LOPROC 13
492 #define STT_HIPROC 15
498 #define STT_HIPROC 15
493
499
494 /*
500 /*
495 * Macros for manipulating st_other
501 * Macros for manipulating st_other
496 */
502 */
497 #define ELF32_ST_VISIBILITY(o) ((o)&0x3)
503 #define ELF32_ST_VISIBILITY(o) ((o)&0x3)
498 #if __LIBELF64
504 #if __LIBELF64
499 #define ELF64_ST_VISIBILITY(o) ((o)&0x3)
505 #define ELF64_ST_VISIBILITY(o) ((o)&0x3)
500 #endif /* __LIBELF64 */
506 #endif /* __LIBELF64 */
501
507
502 /*
508 /*
503 * Symbol visibility
509 * Symbol visibility
504 */
510 */
505 #define STV_DEFAULT 0
511 #define STV_DEFAULT 0
506 #define STV_INTERNAL 1
512 #define STV_INTERNAL 1
507 #define STV_HIDDEN 2
513 #define STV_HIDDEN 2
508 #define STV_PROTECTED 3
514 #define STV_PROTECTED 3
509
515
510 /*
516 /*
511 * Relocation
517 * Relocation
512 */
518 */
513 typedef struct {
519 typedef struct {
514 Elf32_Addr r_offset;
520 Elf32_Addr r_offset;
515 Elf32_Word r_info;
521 Elf32_Word r_info;
516 } Elf32_Rel;
522 } Elf32_Rel;
517
523
518 typedef struct {
524 typedef struct {
519 Elf32_Addr r_offset;
525 Elf32_Addr r_offset;
520 Elf32_Word r_info;
526 Elf32_Word r_info;
521 Elf32_Sword r_addend;
527 Elf32_Sword r_addend;
522 } Elf32_Rela;
528 } Elf32_Rela;
523
529
524 #if __LIBELF64
530 #if __LIBELF64
525 typedef struct {
531 typedef struct {
526 Elf64_Addr r_offset;
532 Elf64_Addr r_offset;
527 Elf64_Xword r_info;
533 Elf64_Xword r_info;
528 } Elf64_Rel;
534 } Elf64_Rel;
529
535
530 typedef struct {
536 typedef struct {
531 Elf64_Addr r_offset;
537 Elf64_Addr r_offset;
532 Elf64_Xword r_info;
538 Elf64_Xword r_info;
533 Elf64_Sxword r_addend;
539 Elf64_Sxword r_addend;
534 } Elf64_Rela;
540 } Elf64_Rela;
535 #endif /* __LIBELF64 */
541 #endif /* __LIBELF64 */
536
542
537 /*
543 /*
538 * Macros for manipulating r_info
544 * Macros for manipulating r_info
539 */
545 */
540 #define ELF32_R_SYM(i) ((i)>>8)
546 #define ELF32_R_SYM(i) ((i)>>8)
541 #define ELF32_R_TYPE(i) ((unsigned char)(i))
547 #define ELF32_R_TYPE(i) ((unsigned char)(i))
542 #define ELF32_R_INFO(s,t) (((s)<<8)+(unsigned char)(t))
548 #define ELF32_R_INFO(s,t) (((s)<<8)+(unsigned char)(t))
543
549
544 #if __LIBELF64
550 #if __LIBELF64
545 #define ELF64_R_SYM(i) ((Elf64_Xword)(i)>>32)
551 #define ELF64_R_SYM(i) ((Elf64_Xword)(i)>>32)
546 #define ELF64_R_TYPE(i) ((i)&0xffffffffL)
552 #define ELF64_R_TYPE(i) ((i)&0xffffffffL)
547 #define ELF64_R_INFO(s,t) (((Elf64_Xword)(s)<<32)+((t)&0xffffffffL))
553 #define ELF64_R_INFO(s,t) (((Elf64_Xword)(s)<<32)+((t)&0xffffffffL))
548 #endif /* __LIBELF64 */
554 #endif /* __LIBELF64 */
549
555
550 /*
556 /*
551 * Note entry header
557 * Note entry header
552 */
558 */
553 typedef struct {
559 typedef struct {
554 Elf32_Word n_namesz; /* name size */
560 Elf32_Word n_namesz; /* name size */
555 Elf32_Word n_descsz; /* descriptor size */
561 Elf32_Word n_descsz; /* descriptor size */
556 Elf32_Word n_type; /* descriptor type */
562 Elf32_Word n_type; /* descriptor type */
557 } Elf32_Nhdr;
563 } Elf32_Nhdr;
558
564
559 #if __LIBELF64
565 #if __LIBELF64
560 /* Solaris and GNU use this layout. Be compatible. */
566 /* Solaris and GNU use this layout. Be compatible. */
561 /* XXX: Latest ELF specs say it's 64-bit!!! */
567 /* XXX: Latest ELF specs say it's 64-bit!!! */
562 typedef struct {
568 typedef struct {
563 Elf64_Word n_namesz; /* name size */
569 Elf64_Word n_namesz; /* name size */
564 Elf64_Word n_descsz; /* descriptor size */
570 Elf64_Word n_descsz; /* descriptor size */
565 Elf64_Word n_type; /* descriptor type */
571 Elf64_Word n_type; /* descriptor type */
566 } Elf64_Nhdr;
572 } Elf64_Nhdr;
567 #endif /* __LIBELF64 */
573 #endif /* __LIBELF64 */
568
574
569 /*
575 /*
570 * Well-known descriptor types for ET_CORE files
576 * Well-known descriptor types for ET_CORE files
571 */
577 */
572 #define NT_PRSTATUS 1
578 #define NT_PRSTATUS 1
573 #define NT_PRFPREG 2
579 #define NT_PRFPREG 2
574 #define NT_PRPSINFO 3
580 #define NT_PRPSINFO 3
575
581
576 /*
582 /*
577 * Program header
583 * Program header
578 */
584 */
579 typedef struct {
585 typedef struct {
580 Elf32_Word p_type;
586 Elf32_Word p_type;
581 Elf32_Off p_offset;
587 Elf32_Off p_offset;
582 Elf32_Addr p_vaddr;
588 Elf32_Addr p_vaddr;
583 Elf32_Addr p_paddr;
589 Elf32_Addr p_paddr;
584 Elf32_Word p_filesz;
590 Elf32_Word p_filesz;
585 Elf32_Word p_memsz;
591 Elf32_Word p_memsz;
586 Elf32_Word p_flags;
592 Elf32_Word p_flags;
587 Elf32_Word p_align;
593 Elf32_Word p_align;
588 } Elf32_Phdr;
594 } Elf32_Phdr;
589
595
590 #if __LIBELF64
596 #if __LIBELF64
591 typedef struct {
597 typedef struct {
592 Elf64_Word p_type;
598 Elf64_Word p_type;
593 Elf64_Word p_flags;
599 Elf64_Word p_flags;
594 Elf64_Off p_offset;
600 Elf64_Off p_offset;
595 Elf64_Addr p_vaddr;
601 Elf64_Addr p_vaddr;
596 Elf64_Addr p_paddr;
602 Elf64_Addr p_paddr;
597 Elf64_Xword p_filesz;
603 Elf64_Xword p_filesz;
598 Elf64_Xword p_memsz;
604 Elf64_Xword p_memsz;
599 Elf64_Xword p_align;
605 Elf64_Xword p_align;
600 } Elf64_Phdr;
606 } Elf64_Phdr;
601 #endif /* __LIBELF64 */
607 #endif /* __LIBELF64 */
602
608
603 /*
609 /*
604 * Special numbers
610 * Special numbers
605 */
611 */
606 #define PN_XNUM 0xffff
612 #define PN_XNUM 0xffff
607
613
608 /*
614 /*
609 * p_type
615 * p_type
610 */
616 */
611 #define PT_NULL 0
617 #define PT_NULL 0
612 #define PT_LOAD 1
618 #define PT_LOAD 1
613 #define PT_DYNAMIC 2
619 #define PT_DYNAMIC 2
614 #define PT_INTERP 3
620 #define PT_INTERP 3
615 #define PT_NOTE 4
621 #define PT_NOTE 4
616 #define PT_SHLIB 5
622 #define PT_SHLIB 5
617 #define PT_PHDR 6
623 #define PT_PHDR 6
618 #define PT_TLS 7
624 #define PT_TLS 7
619 #define PT_NUM 8
625 #define PT_NUM 8
620 #define PT_LOOS 0x60000000
626 #define PT_LOOS 0x60000000
621 #define PT_HIOS 0x6fffffff
627 #define PT_HIOS 0x6fffffff
622 #define PT_LOPROC 0x70000000
628 #define PT_LOPROC 0x70000000
623 #define PT_HIPROC 0x7fffffff
629 #define PT_HIPROC 0x7fffffff
624
630
625 /*
631 /*
626 * Solaris extensions
632 * Solaris extensions
627 */
633 */
628
634
629 #define PT_SUNW_UNWIND 0x6464e550
635 #define PT_SUNW_UNWIND 0x6464e550
630 #define PT_LOSUNW 0x6ffffffa
636 #define PT_LOSUNW 0x6ffffffa
631 #define PT_SUNWBSS 0x6ffffffa
637 #define PT_SUNWBSS 0x6ffffffa
632 #define PT_SUNWSTACK 0x6ffffffb
638 #define PT_SUNWSTACK 0x6ffffffb
633 #define PT_SUNWDTRACE 0x6ffffffc
639 #define PT_SUNWDTRACE 0x6ffffffc
634 #define PT_SUNWCAP 0x6ffffffd
640 #define PT_SUNWCAP 0x6ffffffd
635 #define PT_HISUNW 0x6fffffff
641 #define PT_HISUNW 0x6fffffff
636
642
637 /*
643 /*
638 * p_flags
644 * p_flags
639 */
645 */
640 #define PF_X 0x1
646 #define PF_X 0x1
641 #define PF_W 0x2
647 #define PF_W 0x2
642 #define PF_R 0x4
648 #define PF_R 0x4
643 #define PF_MASKOS 0x0ff00000
649 #define PF_MASKOS 0x0ff00000
644 #define PF_MASKPROC 0xf0000000
650 #define PF_MASKPROC 0xf0000000
645
651
646 /*
652 /*
647 * Dynamic structure
653 * Dynamic structure
648 */
654 */
649 typedef struct {
655 typedef struct {
650 Elf32_Sword d_tag;
656 Elf32_Sword d_tag;
651 union {
657 union {
652 Elf32_Word d_val;
658 Elf32_Word d_val;
653 Elf32_Addr d_ptr;
659 Elf32_Addr d_ptr;
654 } d_un;
660 } d_un;
655 } Elf32_Dyn;
661 } Elf32_Dyn;
656
662
657 #if __LIBELF64
663 #if __LIBELF64
658 typedef struct {
664 typedef struct {
659 Elf64_Sxword d_tag;
665 Elf64_Sxword d_tag;
660 union {
666 union {
661 Elf64_Xword d_val;
667 Elf64_Xword d_val;
662 Elf64_Addr d_ptr;
668 Elf64_Addr d_ptr;
663 } d_un;
669 } d_un;
664 } Elf64_Dyn;
670 } Elf64_Dyn;
665 #endif /* __LIBELF64 */
671 #endif /* __LIBELF64 */
666
672
667 /*
673 /*
668 * Dynamic array tags
674 * Dynamic array tags
669 */
675 */
670 /* d_un exec shared */
676 /* d_un exec shared */
671 #define DT_NULL 0 /* ign. mand. mand. */
677 #define DT_NULL 0 /* ign. mand. mand. */
672 #define DT_NEEDED 1 /* d_val opt. opt. */
678 #define DT_NEEDED 1 /* d_val opt. opt. */
673 #define DT_PLTRELSZ 2 /* d_val opt. opt. */
679 #define DT_PLTRELSZ 2 /* d_val opt. opt. */
674 #define DT_PLTGOT 3 /* d_ptr opt. opt. */
680 #define DT_PLTGOT 3 /* d_ptr opt. opt. */
675 #define DT_HASH 4 /* d_ptr mand. mand. */
681 #define DT_HASH 4 /* d_ptr mand. mand. */
676 #define DT_STRTAB 5 /* d_ptr mand. mand. */
682 #define DT_STRTAB 5 /* d_ptr mand. mand. */
677 #define DT_SYMTAB 6 /* d_ptr mand. mand. */
683 #define DT_SYMTAB 6 /* d_ptr mand. mand. */
678 #define DT_RELA 7 /* d_ptr mand. opt. */
684 #define DT_RELA 7 /* d_ptr mand. opt. */
679 #define DT_RELASZ 8 /* d_val mand. opt. */
685 #define DT_RELASZ 8 /* d_val mand. opt. */
680 #define DT_RELAENT 9 /* d_val mand. opt. */
686 #define DT_RELAENT 9 /* d_val mand. opt. */
681 #define DT_STRSZ 10 /* d_val mand. mand. */
687 #define DT_STRSZ 10 /* d_val mand. mand. */
682 #define DT_SYMENT 11 /* d_val mand. mand. */
688 #define DT_SYMENT 11 /* d_val mand. mand. */
683 #define DT_INIT 12 /* d_ptr opt. opt. */
689 #define DT_INIT 12 /* d_ptr opt. opt. */
684 #define DT_FINI 13 /* d_ptr opt. opt. */
690 #define DT_FINI 13 /* d_ptr opt. opt. */
685 #define DT_SONAME 14 /* d_val ign. opt. */
691 #define DT_SONAME 14 /* d_val ign. opt. */
686 #define DT_RPATH 15 /* d_val opt. ign. */
692 #define DT_RPATH 15 /* d_val opt. ign. */
687 #define DT_SYMBOLIC 16 /* ign. ign. opt. */
693 #define DT_SYMBOLIC 16 /* ign. ign. opt. */
688 #define DT_REL 17 /* d_ptr mand. opt. */
694 #define DT_REL 17 /* d_ptr mand. opt. */
689 #define DT_RELSZ 18 /* d_val mand. opt. */
695 #define DT_RELSZ 18 /* d_val mand. opt. */
690 #define DT_RELENT 19 /* d_val mand. opt. */
696 #define DT_RELENT 19 /* d_val mand. opt. */
691 #define DT_PLTREL 20 /* d_val opt. opt. */
697 #define DT_PLTREL 20 /* d_val opt. opt. */
692 #define DT_DEBUG 21 /* d_ptr opt. ign. */
698 #define DT_DEBUG 21 /* d_ptr opt. ign. */
693 #define DT_TEXTREL 22 /* ign. opt. opt. */
699 #define DT_TEXTREL 22 /* ign. opt. opt. */
694 #define DT_JMPREL 23 /* d_ptr opt. opt. */
700 #define DT_JMPREL 23 /* d_ptr opt. opt. */
695 #define DT_BIND_NOW 24 /* ign. opt. opt. */
701 #define DT_BIND_NOW 24 /* ign. opt. opt. */
696 #define DT_INIT_ARRAY 25 /* d_ptr opt. opt. */
702 #define DT_INIT_ARRAY 25 /* d_ptr opt. opt. */
697 #define DT_FINI_ARRAY 26 /* d_ptr opt. opt. */
703 #define DT_FINI_ARRAY 26 /* d_ptr opt. opt. */
698 #define DT_INIT_ARRAYSZ 27 /* d_val opt. opt. */
704 #define DT_INIT_ARRAYSZ 27 /* d_val opt. opt. */
699 #define DT_FINI_ARRAYSZ 28 /* d_val opt. opt. */
705 #define DT_FINI_ARRAYSZ 28 /* d_val opt. opt. */
700 #define DT_RUNPATH 29 /* d_val opt. opt. */
706 #define DT_RUNPATH 29 /* d_val opt. opt. */
701 #define DT_FLAGS 30 /* d_val opt. opt. */
707 #define DT_FLAGS 30 /* d_val opt. opt. */
702 #define DT_ENCODING 32 /* odd/even encoding rule starts here */
708 #define DT_ENCODING 32 /* odd/even encoding rule starts here */
703 #define DT_PREINIT_ARRAY 32 /* d_ptr opt. ign. */
709 #define DT_PREINIT_ARRAY 32 /* d_ptr opt. ign. */
704 #define DT_PREINIT_ARRAYSZ 33 /* d_val opt. ign. */
710 #define DT_PREINIT_ARRAYSZ 33 /* d_val opt. ign. */
705 #define DT_NUM 34
711 #define DT_NUM 34
706 #define DT_LOOS 0x6000000D
712 #define DT_LOOS 0x6000000D
707 #define DT_HIOS 0x6ffff000
713 #define DT_HIOS 0x6ffff000
708 #define DT_LOPROC 0x70000000
714 #define DT_LOPROC 0x70000000
709 #define DT_HIPROC 0x7fffffff
715 #define DT_HIPROC 0x7fffffff
710
716
711 /*
717 /*
712 * DT_FLAGS values
718 * DT_FLAGS values
713 */
719 */
714 #define DF_ORIGIN 0x1
720 #define DF_ORIGIN 0x1
715 #define DF_SYMBOLIC 0x2
721 #define DF_SYMBOLIC 0x2
716 #define DF_TEXTREL 0x4
722 #define DF_TEXTREL 0x4
717 #define DF_BIND_NOW 0x8
723 #define DF_BIND_NOW 0x8
718 #define DF_STATIC_TLS 0x10
724 #define DF_STATIC_TLS 0x10
719
725
720 /*
726 /*
721 * Solaris extensions
727 * Solaris extensions
722 */
728 */
723 #define DT_VALRNGLO 0x6ffffd00
729 #define DT_VALRNGLO 0x6ffffd00
724 #define DT_CHECKSUM 0x6ffffdf8
730 #define DT_CHECKSUM 0x6ffffdf8
725 #define DT_PLTPADSZ 0x6ffffdf9
731 #define DT_PLTPADSZ 0x6ffffdf9
726 #define DT_MOVEENT 0x6ffffdfa
732 #define DT_MOVEENT 0x6ffffdfa
727 #define DT_MOVESZ 0x6ffffdfb
733 #define DT_MOVESZ 0x6ffffdfb
728 #define DT_FEATURE_1 0x6ffffdfc
734 #define DT_FEATURE_1 0x6ffffdfc
729 #define DT_POSFLAG_1 0x6ffffdfd
735 #define DT_POSFLAG_1 0x6ffffdfd
730 #define DT_SYMINSZ 0x6ffffdfe
736 #define DT_SYMINSZ 0x6ffffdfe
731 #define DT_SYMINENT 0x6ffffdff
737 #define DT_SYMINENT 0x6ffffdff
732 #define DT_VALRNGHI 0x6ffffdff
738 #define DT_VALRNGHI 0x6ffffdff
733
739
734 #define DT_ADDRRNGLO 0x6ffffe00
740 #define DT_ADDRRNGLO 0x6ffffe00
735 #define DT_CONFIG 0x6ffffefa
741 #define DT_CONFIG 0x6ffffefa
736 #define DT_DEPAUDIT 0x6ffffefb
742 #define DT_DEPAUDIT 0x6ffffefb
737 #define DT_AUDIT 0x6ffffefc
743 #define DT_AUDIT 0x6ffffefc
738 #define DT_PLTPAD 0x6ffffefd
744 #define DT_PLTPAD 0x6ffffefd
739 #define DT_MOVETAB 0x6ffffefe
745 #define DT_MOVETAB 0x6ffffefe
740 #define DT_SYMINFO 0x6ffffeff
746 #define DT_SYMINFO 0x6ffffeff
741 #define DT_ADDRRNGHI 0x6ffffeff
747 #define DT_ADDRRNGHI 0x6ffffeff
742
748
743 #define DT_RELACOUNT 0x6ffffff9
749 #define DT_RELACOUNT 0x6ffffff9
744 #define DT_RELCOUNT 0x6ffffffa
750 #define DT_RELCOUNT 0x6ffffffa
745 #define DT_FLAGS_1 0x6ffffffb
751 #define DT_FLAGS_1 0x6ffffffb
746 #define DT_VERDEF 0x6ffffffc
752 #define DT_VERDEF 0x6ffffffc
747 #define DT_VERDEFNUM 0x6ffffffd
753 #define DT_VERDEFNUM 0x6ffffffd
748 #define DT_VERNEED 0x6ffffffe
754 #define DT_VERNEED 0x6ffffffe
749 #define DT_VERNEEDNUM 0x6fffffff
755 #define DT_VERNEEDNUM 0x6fffffff
750
756
751 #define DT_AUXILIARY 0x7ffffffd
757 #define DT_AUXILIARY 0x7ffffffd
752 #define DT_USED 0x7ffffffe
758 #define DT_USED 0x7ffffffe
753 #define DT_FILTER 0x7fffffff
759 #define DT_FILTER 0x7fffffff
754
760
755 /*
761 /*
756 * GNU extensions
762 * GNU extensions
757 */
763 */
758 #define DT_VERSYM 0x6ffffff0
764 #define DT_VERSYM 0x6ffffff0
759
765
760 /*
766 /*
761 * DT_FEATURE_1 values
767 * DT_FEATURE_1 values
762 */
768 */
763 #define DTF_1_PARINIT 0x1
769 #define DTF_1_PARINIT 0x1
764 #define DTF_1_CONFEXP 0x2
770 #define DTF_1_CONFEXP 0x2
765
771
766 /*
772 /*
767 * DT_POSFLAG_1 values
773 * DT_POSFLAG_1 values
768 */
774 */
769 #define DF_P1_LAZYLOAD 0x1
775 #define DF_P1_LAZYLOAD 0x1
770 #define DF_P1_GROUPPERM 0x2
776 #define DF_P1_GROUPPERM 0x2
771
777
772 /*
778 /*
773 * DT_FLAGS_1 values
779 * DT_FLAGS_1 values
774 */
780 */
775 #define DF_1_NOW 0x00000001
781 #define DF_1_NOW 0x00000001
776 #define DF_1_GLOBAL 0x00000002
782 #define DF_1_GLOBAL 0x00000002
777 #define DF_1_GROUP 0x00000004
783 #define DF_1_GROUP 0x00000004
778 #define DF_1_NODELETE 0x00000008
784 #define DF_1_NODELETE 0x00000008
779 #define DF_1_LOADFLTR 0x00000010
785 #define DF_1_LOADFLTR 0x00000010
780 #define DF_1_INITFIRST 0x00000020
786 #define DF_1_INITFIRST 0x00000020
781 #define DF_1_NOOPEN 0x00000040
787 #define DF_1_NOOPEN 0x00000040
782 #define DF_1_ORIGIN 0x00000080
788 #define DF_1_ORIGIN 0x00000080
783 #define DF_1_DIRECT 0x00000100
789 #define DF_1_DIRECT 0x00000100
784 #define DF_1_TRANS 0x00000200
790 #define DF_1_TRANS 0x00000200
785 #define DF_1_INTERPOSE 0x00000400
791 #define DF_1_INTERPOSE 0x00000400
786 #define DF_1_NODEFLIB 0x00000800
792 #define DF_1_NODEFLIB 0x00000800
787 #define DF_1_NODUMP 0x00001000
793 #define DF_1_NODUMP 0x00001000
788 #define DF_1_CONFALT 0x00002000
794 #define DF_1_CONFALT 0x00002000
789 #define DF_1_ENDFILTEE 0x00004000
795 #define DF_1_ENDFILTEE 0x00004000
790 #define DF_1_DISPRELDNE 0x00008000
796 #define DF_1_DISPRELDNE 0x00008000
791 #define DF_1_DISPRELPND 0x00010000
797 #define DF_1_DISPRELPND 0x00010000
792
798
793 /*
799 /*
794 * Syminfo structure
800 * Syminfo structure
795 */
801 */
796 typedef struct {
802 typedef struct {
797 Elf32_Half si_boundto;
803 Elf32_Half si_boundto;
798 Elf32_Half si_flags;
804 Elf32_Half si_flags;
799 } Elf32_Syminfo;
805 } Elf32_Syminfo;
800
806
801 #if __LIBELF64
807 #if __LIBELF64
802 typedef struct {
808 typedef struct {
803 Elf64_Half si_boundto;
809 Elf64_Half si_boundto;
804 Elf64_Half si_flags;
810 Elf64_Half si_flags;
805 } Elf64_Syminfo;
811 } Elf64_Syminfo;
806 #endif /* __LIBELF64 */
812 #endif /* __LIBELF64 */
807
813
808 /*
814 /*
809 * Syminfo version (stored in unused first entry)
815 * Syminfo version (stored in unused first entry)
810 */
816 */
811 #define SYMINFO_NONE 0
817 #define SYMINFO_NONE 0
812 #define SYMINFO_CURRENT 1
818 #define SYMINFO_CURRENT 1
813 #define SYMINFO_NUM 2
819 #define SYMINFO_NUM 2
814
820
815 /*
821 /*
816 * si_boundto special values
822 * si_boundto special values
817 */
823 */
818 #define SYMINFO_BT_LOWRESERVE 0xff00
824 #define SYMINFO_BT_LOWRESERVE 0xff00
819 #define SYMINFO_BT_PARENT 0xfffe /* bound to parent */
825 #define SYMINFO_BT_PARENT 0xfffe /* bound to parent */
820 #define SYMINFO_BT_SELF 0xffff /* bound to self */
826 #define SYMINFO_BT_SELF 0xffff /* bound to self */
821
827
822 /*
828 /*
823 * si_flags
829 * si_flags
824 */
830 */
825 #define SYMINFO_FLG_DIRECT 0x01 /* bound to an object */
831 #define SYMINFO_FLG_DIRECT 0x01 /* bound to an object */
826 #define SYMINFO_FLG_PASSTHRU 0x02 /* pass-thru symbol */
832 #define SYMINFO_FLG_PASSTHRU 0x02 /* pass-thru symbol */
827 #define SYMINFO_FLG_COPY 0x04 /* result of a copy relocation */
833 #define SYMINFO_FLG_COPY 0x04 /* result of a copy relocation */
828 #define SYMINFO_FLG_LAZYLOAD 0x08 /* bound to lazy-loaded object */
834 #define SYMINFO_FLG_LAZYLOAD 0x08 /* bound to lazy-loaded object */
829
835
830 /*
836 /*
831 * Version definitions
837 * Version definitions
832 */
838 */
833 typedef struct {
839 typedef struct {
834 Elf32_Half vd_version;
840 Elf32_Half vd_version;
835 Elf32_Half vd_flags;
841 Elf32_Half vd_flags;
836 Elf32_Half vd_ndx;
842 Elf32_Half vd_ndx;
837 Elf32_Half vd_cnt;
843 Elf32_Half vd_cnt;
838 Elf32_Word vd_hash;
844 Elf32_Word vd_hash;
839 Elf32_Word vd_aux;
845 Elf32_Word vd_aux;
840 Elf32_Word vd_next;
846 Elf32_Word vd_next;
841 } Elf32_Verdef;
847 } Elf32_Verdef;
842
848
843 typedef struct {
849 typedef struct {
844 Elf32_Word vda_name;
850 Elf32_Word vda_name;
845 Elf32_Word vda_next;
851 Elf32_Word vda_next;
846 } Elf32_Verdaux;
852 } Elf32_Verdaux;
847
853
848 typedef struct {
854 typedef struct {
849 Elf32_Half vn_version;
855 Elf32_Half vn_version;
850 Elf32_Half vn_cnt;
856 Elf32_Half vn_cnt;
851 Elf32_Word vn_file;
857 Elf32_Word vn_file;
852 Elf32_Word vn_aux;
858 Elf32_Word vn_aux;
853 Elf32_Word vn_next;
859 Elf32_Word vn_next;
854 } Elf32_Verneed;
860 } Elf32_Verneed;
855
861
856 typedef struct {
862 typedef struct {
857 Elf32_Word vna_hash;
863 Elf32_Word vna_hash;
858 Elf32_Half vna_flags;
864 Elf32_Half vna_flags;
859 Elf32_Half vna_other;
865 Elf32_Half vna_other;
860 Elf32_Word vna_name;
866 Elf32_Word vna_name;
861 Elf32_Word vna_next;
867 Elf32_Word vna_next;
862 } Elf32_Vernaux;
868 } Elf32_Vernaux;
863
869
864 typedef Elf32_Half Elf32_Versym;
870 typedef Elf32_Half Elf32_Versym;
865
871
866 #if __LIBELF64
872 #if __LIBELF64
867
873
868 typedef struct {
874 typedef struct {
869 Elf64_Half vd_version;
875 Elf64_Half vd_version;
870 Elf64_Half vd_flags;
876 Elf64_Half vd_flags;
871 Elf64_Half vd_ndx;
877 Elf64_Half vd_ndx;
872 Elf64_Half vd_cnt;
878 Elf64_Half vd_cnt;
873 Elf64_Word vd_hash;
879 Elf64_Word vd_hash;
874 Elf64_Word vd_aux;
880 Elf64_Word vd_aux;
875 Elf64_Word vd_next;
881 Elf64_Word vd_next;
876 } Elf64_Verdef;
882 } Elf64_Verdef;
877
883
878 typedef struct {
884 typedef struct {
879 Elf64_Word vda_name;
885 Elf64_Word vda_name;
880 Elf64_Word vda_next;
886 Elf64_Word vda_next;
881 } Elf64_Verdaux;
887 } Elf64_Verdaux;
882
888
883 typedef struct {
889 typedef struct {
884 Elf64_Half vn_version;
890 Elf64_Half vn_version;
885 Elf64_Half vn_cnt;
891 Elf64_Half vn_cnt;
886 Elf64_Word vn_file;
892 Elf64_Word vn_file;
887 Elf64_Word vn_aux;
893 Elf64_Word vn_aux;
888 Elf64_Word vn_next;
894 Elf64_Word vn_next;
889 } Elf64_Verneed;
895 } Elf64_Verneed;
890
896
891 typedef struct {
897 typedef struct {
892 Elf64_Word vna_hash;
898 Elf64_Word vna_hash;
893 Elf64_Half vna_flags;
899 Elf64_Half vna_flags;
894 Elf64_Half vna_other;
900 Elf64_Half vna_other;
895 Elf64_Word vna_name;
901 Elf64_Word vna_name;
896 Elf64_Word vna_next;
902 Elf64_Word vna_next;
897 } Elf64_Vernaux;
903 } Elf64_Vernaux;
898
904
899 typedef Elf64_Half Elf64_Versym;
905 typedef Elf64_Half Elf64_Versym;
900
906
901 #endif /* __LIBELF64 */
907 #endif /* __LIBELF64 */
902
908
903 /*
909 /*
904 * vd_version
910 * vd_version
905 */
911 */
906 #define VER_DEF_NONE 0
912 #define VER_DEF_NONE 0
907 #define VER_DEF_CURRENT 1
913 #define VER_DEF_CURRENT 1
908 #define VER_DEF_NUM 2
914 #define VER_DEF_NUM 2
909
915
910 /*
916 /*
911 * vn_version
917 * vn_version
912 */
918 */
913 #define VER_NEED_NONE 0
919 #define VER_NEED_NONE 0
914 #define VER_NEED_CURRENT 1
920 #define VER_NEED_CURRENT 1
915 #define VER_NEED_NUM 2
921 #define VER_NEED_NUM 2
916
922
917 /*
923 /*
918 * vd_flags / vna_flags
924 * vd_flags / vna_flags
919 */
925 */
920 #define VER_FLG_BASE 0x1 /* vd_flags only */
926 #define VER_FLG_BASE 0x1 /* vd_flags only */
921 #define VER_FLG_WEAK 0x2
927 #define VER_FLG_WEAK 0x2
922
928
923 /*
929 /*
924 * Elf*_Versym special values
930 * Elf*_Versym special values
925 */
931 */
926 #define VER_NDX_LOCAL 0
932 #define VER_NDX_LOCAL 0
927 #define VER_NDX_GLOBAL 1
933 #define VER_NDX_GLOBAL 1
928
934
929 /*
935 /*
930 * Solaris extensions
936 * Solaris extensions
931 */
937 */
932
938
933 /*
939 /*
934 * Move section
940 * Move section
935 */
941 */
936 #if __LIBELF64
942 #if __LIBELF64
937
943
938 typedef struct {
944 typedef struct {
939 Elf32_Lword m_value;
945 Elf32_Lword m_value;
940 Elf32_Word m_info;
946 Elf32_Word m_info;
941 Elf32_Word m_poffset;
947 Elf32_Word m_poffset;
942 Elf32_Half m_repeat;
948 Elf32_Half m_repeat;
943 Elf32_Half m_stride;
949 Elf32_Half m_stride;
944 } Elf32_Move;
950 } Elf32_Move;
945
951
946 typedef struct {
952 typedef struct {
947 Elf64_Lword m_value;
953 Elf64_Lword m_value;
948 Elf64_Xword m_info;
954 Elf64_Xword m_info;
949 Elf64_Xword m_poffset;
955 Elf64_Xword m_poffset;
950 Elf64_Half m_repeat;
956 Elf64_Half m_repeat;
951 Elf64_Half m_stride;
957 Elf64_Half m_stride;
952 } Elf64_Move;
958 } Elf64_Move;
953
959
954 #define ELF32_M_SYM(info) ((info)>>8)
960 #define ELF32_M_SYM(info) ((info)>>8)
955 #define ELF32_M_SIZE(info) ((unsigned char)(info))
961 #define ELF32_M_SIZE(info) ((unsigned char)(info))
956 #define ELF32_M_INFO(sym, sz) (((sym)<<8)+(unsigned char)(sz))
962 #define ELF32_M_INFO(sym, sz) (((sym)<<8)+(unsigned char)(sz))
957
963
958 #define ELF64_M_SYM(info) ((Elf64_Xword)(info)>>8)
964 #define ELF64_M_SYM(info) ((Elf64_Xword)(info)>>8)
959 #define ELF64_M_SIZE(info) ((unsigned char)(info))
965 #define ELF64_M_SIZE(info) ((unsigned char)(info))
960 #define ELF64_M_INFO(sym, sz) (((Elf64_Xword)(sym)<<8)+(unsigned char)(sz))
966 #define ELF64_M_INFO(sym, sz) (((Elf64_Xword)(sym)<<8)+(unsigned char)(sz))
961
967
962 #endif /* __LIBELF64 */
968 #endif /* __LIBELF64 */
963
969
964 /*
970 /*
965 * Capabilities
971 * Capabilities
966 */
972 */
967
973
968 typedef struct {
974 typedef struct {
969 Elf32_Word c_tag;
975 Elf32_Word c_tag;
970 union {
976 union {
971 Elf32_Word c_val;
977 Elf32_Word c_val;
972 Elf32_Addr c_ptr;
978 Elf32_Addr c_ptr;
973 } c_un;
979 } c_un;
974 } Elf32_Cap;
980 } Elf32_Cap;
975
981
976 #if __LIBELF64
982 #if __LIBELF64
977
983
978 typedef struct {
984 typedef struct {
979 Elf64_Xword c_tag;
985 Elf64_Xword c_tag;
980 union {
986 union {
981 Elf64_Xword c_val;
987 Elf64_Xword c_val;
982 Elf64_Addr c_ptr;
988 Elf64_Addr c_ptr;
983 } c_un;
989 } c_un;
984 } Elf64_Cap;
990 } Elf64_Cap;
985
991
986 #endif /* __LIBELF64 */
992 #endif /* __LIBELF64 */
987
993
988 #define CA_SUNW_NULL 0 /* c_un ignored */
994 #define CA_SUNW_NULL 0 /* c_un ignored */
989 #define CA_SUNW_HW_1 1 /* c_un.c_val */
995 #define CA_SUNW_HW_1 1 /* c_un.c_val */
990 #define CA_SUNW_SF_1 2 /* c_un.c_val */
996 #define CA_SUNW_SF_1 2 /* c_un.c_val */
991
997
992 #ifdef __cplusplus
998 #ifdef __cplusplus
993 }
999 }
994 #endif /* __cplusplus */
1000 #endif /* __cplusplus */
995
1001
996 #endif /* _ELF_REPL_H */
1002 #endif /* _ELF_REPL_H */
General Comments 0
You need to be logged in to leave comments. Login now