##// END OF EJS Templates
ElfFile classes WIP.
jeandet -
r35:f6b4da9a999c default
parent child
Show More
@@ -0,0 +1,14
1 #include "elffilewidget.h"
2 #include "ui_elffilewidget.h"
3
4 elfFileWidget::elfFileWidget(QWidget *parent) :
5 QWidget(parent),
6 ui(new Ui::elfFileWidget)
7 {
8 ui->setupUi(this);
9 }
10
11 elfFileWidget::~elfFileWidget()
12 {
13 delete ui;
14 }
@@ -0,0 +1,22
1 #ifndef ELFFILEWIDGET_H
2 #define ELFFILEWIDGET_H
3
4 #include <QWidget>
5
6 namespace Ui {
7 class elfFileWidget;
8 }
9
10 class elfFileWidget : public QWidget
11 {
12 Q_OBJECT
13
14 public:
15 explicit elfFileWidget(QWidget *parent = 0);
16 ~elfFileWidget();
17
18 private:
19 Ui::elfFileWidget *ui;
20 };
21
22 #endif // ELFFILEWIDGET_H
@@ -0,0 +1,80
1 <?xml version="1.0" encoding="UTF-8"?>
2 <ui version="4.0">
3 <class>elfFileWidget</class>
4 <widget class="QWidget" name="elfFileWidget">
5 <property name="geometry">
6 <rect>
7 <x>0</x>
8 <y>0</y>
9 <width>622</width>
10 <height>398</height>
11 </rect>
12 </property>
13 <property name="minimumSize">
14 <size>
15 <width>0</width>
16 <height>0</height>
17 </size>
18 </property>
19 <property name="focusPolicy">
20 <enum>Qt::NoFocus</enum>
21 </property>
22 <property name="windowTitle">
23 <string>Form</string>
24 </property>
25 <layout class="QGridLayout" name="gridLayout">
26 <item row="0" column="0">
27 <widget class="QTabWidget" name="tabWidget">
28 <property name="currentIndex">
29 <number>0</number>
30 </property>
31 <widget class="QWidget" name="generalInfoTab">
32 <attribute name="title">
33 <string>General Informations</string>
34 </attribute>
35 </widget>
36 <widget class="QWidget" name="symbolsTab">
37 <attribute name="title">
38 <string>Symbols</string>
39 </attribute>
40 <layout class="QGridLayout" name="gridLayout_2">
41 <item row="0" column="0">
42 <widget class="QTableWidget" name="symbolsList"/>
43 </item>
44 </layout>
45 </widget>
46 <widget class="QWidget" name="sectionsTab">
47 <attribute name="title">
48 <string>Sections</string>
49 </attribute>
50 <layout class="QGridLayout" name="gridLayout_3">
51 <item row="0" column="0">
52 <widget class="QHexEdit" name="sectionsHexView" native="true">
53 <property name="minimumSize">
54 <size>
55 <width>100</width>
56 <height>0</height>
57 </size>
58 </property>
59 </widget>
60 </item>
61 <item row="0" column="1">
62 <widget class="QTableWidget" name="sectionsList"/>
63 </item>
64 </layout>
65 </widget>
66 </widget>
67 </item>
68 </layout>
69 </widget>
70 <customwidgets>
71 <customwidget>
72 <class>QHexEdit</class>
73 <extends>QWidget</extends>
74 <header location="global">qhexedit.h</header>
75 <container>1</container>
76 </customwidget>
77 </customwidgets>
78 <resources/>
79 <connections/>
80 </ui>
@@ -31,31 +31,6 abstractExecFile::abstractExecFile(const
31 31
32 32 }
33 33
34 bool abstractExecFile::openFile(const QString &File)
35 {
36
37 }
38
39 bool abstractExecFile::isopened()
40 {
41
42 }
43
44 int abstractExecFile::setFilename(const QString &name)
45 {
46
47 }
48
49 int abstractExecFile::closeFile()
50 {
51
52 }
53
54 QList<codeFragment> abstractExecFile::getFragments()
55 {
56
57 }
58
59 34
60 35 codeFragment::codeFragment()
61 36 {
@@ -39,15 +39,16 class abstractExecFile : public QObject
39 39 public:
40 40 abstractExecFile(QObject *parent = 0);
41 41 abstractExecFile(const QString& File,QObject *parent = 0);
42 virtual bool openFile(const QString& File);
43 virtual bool isopened();
44 virtual int setFilename(const QString& name);
45 virtual int closeFile();
46 virtual QList<codeFragment> getFragments();
42 virtual bool openFile(const QString& File)=0;
43 virtual bool isopened()=0;
44 virtual int closeFile()=0;
45 virtual QList<codeFragment> getFragments()=0;
47 46 signals:
48 47
49 48 public slots:
50 49
50 protected:
51 QString p_fileName;
51 52 };
52 53
53 54 #endif // ABSTRACTEXECFILE_H
@@ -83,7 +83,8 HEADERS += \
83 83 elf/elffile.h \
84 84 qipdialogbox.h \
85 85 PySocExplorer.h \
86 SocExplorerPlot.h
86 SocExplorerPlot.h \
87 elf/elffilewidget.h
87 88
88 89
89 90 SOURCES += \
@@ -101,7 +102,11 SOURCES += \
101 102 abstractexecfile.cpp \
102 103 elf/elffile.cpp \
103 104 qipdialogbox.cpp \
104 SocExplorerPlot.cpp
105 SocExplorerPlot.cpp \
106 elf/elffilewidget.cpp
107
108 FORMS += \
109 elf/elffilewidget.ui
105 110
106 111
107 112
@@ -16,8 +16,10
16 16 -- along with this program; if not, write to the Free Software
17 17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@member.fsf.org
19 /*-- Author :
20 Alexis Jeandet
21 -- Mail :
22 alexis.jeandet@member.fsf.org
21 23 ----------------------------------------------------------------------------*/
22 24 #include "elffile.h"
23 25
@@ -27,6 +29,76 ElfFile::ElfFile(QObject *parent) :
27 29 }
28 30
29 31 ElfFile::ElfFile(const QString &File, QObject *parent)
32 :abstractExecFile(parent)
30 33 {
34 this->p_fileName = File;
35 parser.setFilename(File);
36 }
37
38 bool ElfFile::openFile(const QString &File)
39 {
40 this->p_fileName = File;
41 parser.setFilename(File);
42 }
43
44 bool ElfFile::isopened()
45 {
46 return parser.isopened();
47 }
48
49 int ElfFile::closeFile()
50 {
51 return parser.closeFile();
52 }
53
54 QList<codeFragment> ElfFile::getFragments()
55 {
56 QList<codeFragment> fragments;
57 if (parser.isopened())
58 {
59 fragments.append(getFragment(".text"));
60 fragments.append(getFragment(".data"));
61 }
62 }
63
64 QList<codeFragment> ElfFile::getFragments(QStringList fragmentList)
65 {
66 QList<codeFragment> fragments;
67 if (parser.isopened())
68 {
69 for(int i =0;i<fragmentList.count();i++)
70 {
71 fragments.append(getFragment(fragmentList.at(i)));
72 }
73 }
74 }
75
76 codeFragment ElfFile::getFragment(const QString &name)
77 {
78 codeFragment fragment;
79 for(int i=0;i<parser.getSectioncount();i++)
80 {
81 if(parser.getSectionName(i) == name)
82 {
83 fragment.data =NULL;
84 fragment.size = parser.getSectionDatasz(i);
85 fragment.address = parser.getSectionPaddr(i);
86 parser.getSectionData(i,&fragment.data);
87 }
88 }
31 89
32 90 }
91
92
93
94
95
96
97
98
99
100
101
102
103
104
@@ -21,6 +21,9
21 21 ----------------------------------------------------------------------------*/
22 22 #include <abstractexecfile.h>
23 23 #include <elf.h>
24 #include "elfparser.h"
25 #include <QStringList>
26
24 27 #ifndef ELFFILE_H
25 28 #define ELFFILE_H
26 29
@@ -30,10 +33,17 class ElfFile : public abstractExecFile
30 33 public:
31 34 ElfFile(QObject *parent = 0);
32 35 ElfFile(const QString& File,QObject *parent = 0);
33
36 bool openFile(const QString& File);
37 bool isopened();
38 int closeFile();
39 QList<codeFragment> getFragments();
40 QList<codeFragment> getFragments(QStringList fragmentList);
34 41 signals:
35 42
36 43 public slots:
44 private:
45 elfparser parser;
46 codeFragment getFragment(const QString& name);
37 47
38 48 };
39 49
@@ -25,236 +25,254
25 25 #include <fcntl.h>
26 26 #include <unistd.h>
27 27
28 void elfresolveMachine(Elf64_Half e_machine,char* MachineName)
28 QString elfresolveMachine(Elf64_Half e_machine)
29 29 {
30
30 QString machineName;
31 31 //Update from with bash script don't write it by yourself!
32 32 switch(e_machine)
33 33 {
34 case EM_NONE :
35 strcpy(MachineName,"No machine");
34 case EM_NONE:
35 machineName = " No machine ";
36 36 break;
37 case EM_M32 :
38 strcpy(MachineName,"AT&T WE 32100");
37 case EM_M32:
38 machineName = " AT&T WE 32100 ";
39 39 break;
40 case EM_SPARC :
41 strcpy(MachineName,"SUN SPARC");
40 case EM_SPARC:
41 machineName = " SUN SPARC ";
42 42 break;
43 case EM_386 :
44 strcpy(MachineName,"Intel 80386");
43 case EM_386:
44 machineName = " Intel 80386 ";
45 45 break;
46 case EM_68K :
47 strcpy(MachineName,"Motorola m68k family");
46 case EM_68K:
47 machineName = " Motorola m68k family ";
48 48 break;
49 case EM_88K :
50 strcpy(MachineName,"Motorola m88k family");
49 case EM_88K:
50 machineName = " Motorola m88k family ";
51 51 break;
52 case EM_860 :
53 strcpy(MachineName,"Intel 80860");
52 case EM_860:
53 machineName = " Intel 80860 ";
54 54 break;
55 case EM_MIPS :
56 strcpy(MachineName,"MIPS R3000 big-endian");
55 case EM_MIPS:
56 machineName = " MIPS R3000 big-endian ";
57 57 break;
58 case EM_S370 :
59 strcpy(MachineName,"IBM System\/370");
58 case EM_S370:
59 machineName = " IBM System/370 ";
60 60 break;
61 case EM_MIPS_RS3_LE :
62 strcpy(MachineName,"MIPS R3000 little-endian");
61 case EM_MIPS_RS3_LE:
62 machineName = " MIPS R3000 little-endian ";
63 63 break;
64 case EM_PARISC :
65 strcpy(MachineName,"HPPA");
64 case EM_PARISC:
65 machineName = " HPPA ";
66 66 break;
67 case EM_VPP500 :
68 strcpy(MachineName,"Fujitsu VPP500");
67 case EM_VPP500:
68 machineName = " Fujitsu VPP500 ";
69 69 break;
70 case EM_SPARC32PLUS :
71 strcpy(MachineName,"Sun's \"v8plus\"");
70 case EM_SPARC32PLUS:
71 machineName = " Sun's \"v8plus\" ";
72 break;
73 case EM_960:
74 machineName = " Intel 80960 ";
72 75 break;
73 case EM_960 :
74 strcpy(MachineName,"Intel 80960");
76 case EM_PPC:
77 machineName = " PowerPC ";
75 78 break;
76 case EM_PPC :
77 strcpy(MachineName,"PowerPC");
79 case EM_PPC64:
80 machineName = " PowerPC 64-bit ";
78 81 break;
79 case EM_PPC64 :
80 strcpy(MachineName,"PowerPC 64-bit");
82 case EM_S390:
83 machineName = " IBM S390 ";
81 84 break;
82 case EM_S390 :
83 strcpy(MachineName,"IBM S390");
85 case EM_V800:
86 machineName = " NEC V800 series ";
84 87 break;
85 case EM_V800 :
86 strcpy(MachineName,"NEC V800 series");
88 case EM_FR20:
89 machineName = " Fujitsu FR20 ";
87 90 break;
88 case EM_FR20 :
89 strcpy(MachineName,"Fujitsu FR20");
91 case EM_RH32:
92 machineName = " TRW RH-32 ";
90 93 break;
91 case EM_RH32 :
92 strcpy(MachineName,"TRW RH-32");
94 case EM_RCE:
95 machineName = " Motorola RCE ";
93 96 break;
94 case EM_RCE :
95 strcpy(MachineName,"Motorola RCE");
97 case EM_ARM:
98 machineName = " ARM ";
96 99 break;
97 case EM_ARM :
98 strcpy(MachineName,"ARM");
100 case EM_FAKE_ALPHA:
101 machineName = " Digital Alpha ";
102 break;
103 case EM_SH:
104 machineName = " Hitachi SH ";
99 105 break;
100 case EM_SH :
101 strcpy(MachineName,"Hitachi SH");
106 case EM_SPARCV9:
107 machineName = " SPARC v9 64-bit ";
102 108 break;
103 case EM_SPARCV9 :
104 strcpy(MachineName,"SPARC v9 64-bit");
109 case EM_TRICORE:
110 machineName = " Siemens Tricore ";
105 111 break;
106 case EM_TRICORE :
107 strcpy(MachineName,"Siemens Tricore");
112 case EM_ARC:
113 machineName = " Argonaut RISC Core ";
108 114 break;
109 case EM_ARC :
110 strcpy(MachineName,"Argonaut RISC Core");
115 case EM_H8_300:
116 machineName = " Hitachi H8/300 ";
111 117 break;
112 case EM_H8_300 :
113 strcpy(MachineName,"Hitachi H8\/300");
118 case EM_H8_300H:
119 machineName = " Hitachi H8/300H ";
114 120 break;
115 case EM_H8_300H :
116 strcpy(MachineName,"Hitachi H8\/300H");
121 case EM_H8S:
122 machineName = " Hitachi H8S ";
117 123 break;
118 case EM_H8S :
119 strcpy(MachineName,"Hitachi H8S");
124 case EM_H8_500:
125 machineName = " Hitachi H8/500 ";
120 126 break;
121 case EM_H8_500 :
122 strcpy(MachineName,"Hitachi H8\/500");
127 case EM_IA_64:
128 machineName = " Intel Merced ";
123 129 break;
124 case EM_IA_64 :
125 strcpy(MachineName,"Intel Merced");
130 case EM_MIPS_X:
131 machineName = " Stanford MIPS-X ";
132 break;
133 case EM_COLDFIRE:
134 machineName = " Motorola Coldfire ";
126 135 break;
127 case EM_MIPS_X :
128 strcpy(MachineName,"Stanford MIPS-X");
136 case EM_68HC12:
137 machineName = " Motorola M68HC12 ";
129 138 break;
130 case EM_COLDFIRE :
131 strcpy(MachineName,"Motorola Coldfire");
139 case EM_MMA:
140 machineName = " Fujitsu MMA Multimedia Accelerator";
132 141 break;
133 case EM_68HC12 :
134 strcpy(MachineName,"Motorola M68HC12");
142 case EM_PCP:
143 machineName = " Siemens PCP ";
135 144 break;
136 case EM_MMA :
137 strcpy(MachineName,"Fujitsu MMA Multimedia Accelerator");
145 case EM_NCPU:
146 machineName = " Sony nCPU embeeded RISC ";
138 147 break;
139 case EM_PCP :
140 strcpy(MachineName,"Siemens PCP");
148 case EM_NDR1:
149 machineName = " Denso NDR1 microprocessor ";
141 150 break;
142 case EM_NCPU :
143 strcpy(MachineName,"Sony nCPU embeeded RISC");
151 case EM_STARCORE:
152 machineName = " Motorola Start*Core processor ";
144 153 break;
145 case EM_NDR1 :
146 strcpy(MachineName,"Denso NDR1 microprocessor");
154 case EM_ME16:
155 machineName = " Toyota ME16 processor ";
147 156 break;
148 case EM_STARCORE :
149 strcpy(MachineName,"Motorola Start*Core processor");
157 case EM_ST100:
158 machineName = " STMicroelectronic ST100 processor ";
150 159 break;
151 case EM_ME16 :
152 strcpy(MachineName,"Toyota ME16 processor");
160 case EM_TINYJ:
161 machineName = " Advanced Logic Corp. Tinyj emb.fam";
162 break;
163 case EM_X86_64:
164 machineName = " AMD x86-64 architecture ";
153 165 break;
154 case EM_ST100 :
155 strcpy(MachineName,"STMicroelectronic ST100 processor");
166 case EM_PDSP:
167 machineName = " Sony DSP Processor ";
156 168 break;
157 case EM_TINYJ :
158 strcpy(MachineName,"Advanced Logic Corp. Tinyj emb.fam");
169 case EM_FX66:
170 machineName = " Siemens FX66 microcontroller ";
159 171 break;
160 case EM_X86_64 :
161 strcpy(MachineName,"AMD x86-64 architecture");
172 case EM_ST9PLUS:
173 machineName = " STMicroelectronics ST9+ 8/16 mc ";
162 174 break;
163 case EM_PDSP :
164 strcpy(MachineName,"Sony DSP Processor");
175 case EM_ST7:
176 machineName = " STmicroelectronics ST7 8 bit mc ";
165 177 break;
166 case EM_FX66 :
167 strcpy(MachineName,"Siemens FX66 microcontroller");
178 case EM_68HC16:
179 machineName = " Motorola MC68HC16 microcontroller ";
168 180 break;
169 case EM_ST9PLUS :
170 strcpy(MachineName,"STMicroelectronics ST9+ 8\/16 mc");
181 case EM_68HC11:
182 machineName = " Motorola MC68HC11 microcontroller ";
171 183 break;
172 case EM_ST7 :
173 strcpy(MachineName,"STmicroelectronics ST7 8 bit mc");
184 case EM_68HC08:
185 machineName = " Motorola MC68HC08 microcontroller ";
174 186 break;
175 case EM_68HC16 :
176 strcpy(MachineName,"Motorola MC68HC16 microcontroller");
187 case EM_68HC05:
188 machineName = " Motorola MC68HC05 microcontroller ";
177 189 break;
178 case EM_68HC11 :
179 strcpy(MachineName,"Motorola MC68HC11 microcontroller");
190 case EM_SVX:
191 machineName = " Silicon Graphics SVx ";
192 break;
193 case EM_ST19:
194 machineName = " STMicroelectronics ST19 8 bit mc ";
180 195 break;
181 case EM_68HC08 :
182 strcpy(MachineName,"Motorola MC68HC08 microcontroller");
196 case EM_VAX:
197 machineName = " Digital VAX ";
183 198 break;
184 case EM_68HC05 :
185 strcpy(MachineName,"Motorola MC68HC05 microcontroller");
199 case EM_CRIS:
200 machineName = " Axis Communications 32-bit embedded processor ";
186 201 break;
187 case EM_SVX :
188 strcpy(MachineName,"Silicon Graphics SVx");
202 case EM_JAVELIN:
203 machineName = " Infineon Technologies 32-bit embedded processor ";
189 204 break;
190 case EM_ST19 :
191 strcpy(MachineName,"STMicroelectronics ST19 8 bit mc");
205 case EM_FIREPATH:
206 machineName = " Element 14 64-bit DSP Processor ";
192 207 break;
193 case EM_VAX :
194 strcpy(MachineName,"Digital VAX");
208 case EM_ZSP:
209 machineName = " LSI Logic 16-bit DSP Processor ";
195 210 break;
196 case EM_CRIS :
197 strcpy(MachineName,"Axis Communications 32-bit embedded processor");
211 case EM_MMIX:
212 machineName = " Donald Knuth's educational 64-bit processor ";
198 213 break;
199 case EM_JAVELIN :
200 strcpy(MachineName,"Infineon Technologies 32-bit embedded processor");
214 case EM_HUANY:
215 machineName = " Harvard University machine-independent object files ";
201 216 break;
202 case EM_FIREPATH :
203 strcpy(MachineName,"Element 14 64-bit DSP Processor");
217 case EM_PRISM:
218 machineName = " SiTera Prism ";
204 219 break;
205 case EM_ZSP :
206 strcpy(MachineName,"LSI Logic 16-bit DSP Processor");
220 case EM_AVR:
221 machineName = " Atmel AVR 8-bit microcontroller ";
222 break;
223 case EM_FR30:
224 machineName = " Fujitsu FR30 ";
207 225 break;
208 case EM_MMIX :
209 strcpy(MachineName,"Donald Knuth's educational 64-bit processor");
226 case EM_D10V:
227 machineName = " Mitsubishi D10V ";
210 228 break;
211 case EM_HUANY :
212 strcpy(MachineName,"Harvard University machine-independent object files");
229 case EM_D30V:
230 machineName = " Mitsubishi D30V ";
213 231 break;
214 case EM_PRISM :
215 strcpy(MachineName,"SiTera Prism");
232 case EM_V850:
233 machineName = " NEC v850 ";
216 234 break;
217 case EM_AVR :
218 strcpy(MachineName,"Atmel AVR 8-bit microcontroller");
235 case EM_M32R:
236 machineName = " Mitsubishi M32R ";
219 237 break;
220 case EM_FR30 :
221 strcpy(MachineName,"Fujitsu FR30");
238 case EM_MN10300:
239 machineName = " Matsushita MN10300 ";
222 240 break;
223 case EM_D10V :
224 strcpy(MachineName,"Mitsubishi D10V");
241 case EM_MN10200:
242 machineName = " Matsushita MN10200 ";
225 243 break;
226 case EM_D30V :
227 strcpy(MachineName,"Mitsubishi D30V");
244 case EM_PJ:
245 machineName = " picoJava ";
228 246 break;
229 case EM_V850 :
230 strcpy(MachineName,"NEC v850");
247 case EM_OPENRISC:
248 machineName = " OpenRISC 32-bit embedded processor ";
231 249 break;
232 case EM_M32R :
233 strcpy(MachineName,"Mitsubishi M32R");
250 case EM_ARC_A5:
251 machineName = " ARC Cores Tangent-A5 ";
234 252 break;
235 case EM_MN10300 :
236 strcpy(MachineName,"Matsushita MN10300");
253 case EM_XTENSA:
254 machineName = " Tensilica Xtensa Architecture ";
237 255 break;
238 case EM_MN10200 :
239 strcpy(MachineName,"Matsushita MN10200");
256 case EM_AARCH64:
257 machineName = " ARM AARCH64 ";
240 258 break;
241 case EM_PJ :
242 strcpy(MachineName,"picoJava");
259 case EM_TILEPRO:
260 machineName = " Tilera TILEPro ";
243 261 break;
244 case EM_OPENRISC :
245 strcpy(MachineName,"OpenRISC 32-bit embedded processor");
262 case EM_MICROBLAZE:
263 machineName = " Xilinx MicroBlaze ";
246 264 break;
247 case EM_ARC_A5 :
248 strcpy(MachineName,"ARC Cores Tangent-A5");
265 case EM_TILEGX:
266 machineName = " Tilera TILE-Gx ";
249 267 break;
250 case EM_XTENSA :
251 strcpy(MachineName,"Tensilica Xtensa Architecture");
268 case EM_NUM:
269 machineName = "";
252 270 break;
253 271 default:
254 strcpy(MachineName,"Unknow Machine");
272 machineName ="Unknow Machine";
255 273 break;
256 274 }
257
275 return machineName;
258 276 }
259 277
260 278
@@ -318,14 +336,11 bool elfparser::iself()
318 336
319 337 QString elfparser::getArchitecture()
320 338 {
321 QString arch("");
322 char archName[256]="";
323 339 if(this->e!=NULL)
324 340 {
325 elfresolveMachine(this->ehdr.e_machine,archName);
326 arch = archName;
341 return elfresolveMachine(this->ehdr.e_machine);
327 342 }
328 return arch;
343 return "";
329 344 }
330 345
331 346
General Comments 0
You need to be logged in to leave comments. Login now