##// 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 34 case EM_NONE :
35 strcpy(MachineName,"No machine");
35 machineName = " No machine ";
36 36 break;
37 37 case EM_M32 :
38 strcpy(MachineName,"AT&T WE 32100");
38 machineName = " AT&T WE 32100 ";
39 39 break;
40 40 case EM_SPARC :
41 strcpy(MachineName,"SUN SPARC");
41 machineName = " SUN SPARC ";
42 42 break;
43 43 case EM_386 :
44 strcpy(MachineName,"Intel 80386");
44 machineName = " Intel 80386 ";
45 45 break;
46 46 case EM_68K :
47 strcpy(MachineName,"Motorola m68k family");
47 machineName = " Motorola m68k family ";
48 48 break;
49 49 case EM_88K :
50 strcpy(MachineName,"Motorola m88k family");
50 machineName = " Motorola m88k family ";
51 51 break;
52 52 case EM_860 :
53 strcpy(MachineName,"Intel 80860");
53 machineName = " Intel 80860 ";
54 54 break;
55 55 case EM_MIPS :
56 strcpy(MachineName,"MIPS R3000 big-endian");
56 machineName = " MIPS R3000 big-endian ";
57 57 break;
58 58 case EM_S370 :
59 strcpy(MachineName,"IBM System\/370");
59 machineName = " IBM System/370 ";
60 60 break;
61 61 case EM_MIPS_RS3_LE :
62 strcpy(MachineName,"MIPS R3000 little-endian");
62 machineName = " MIPS R3000 little-endian ";
63 63 break;
64 64 case EM_PARISC :
65 strcpy(MachineName,"HPPA");
65 machineName = " HPPA ";
66 66 break;
67 67 case EM_VPP500 :
68 strcpy(MachineName,"Fujitsu VPP500");
68 machineName = " Fujitsu VPP500 ";
69 69 break;
70 70 case EM_SPARC32PLUS :
71 strcpy(MachineName,"Sun's \"v8plus\"");
71 machineName = " Sun's \"v8plus\" ";
72 72 break;
73 73 case EM_960 :
74 strcpy(MachineName,"Intel 80960");
74 machineName = " Intel 80960 ";
75 75 break;
76 76 case EM_PPC :
77 strcpy(MachineName,"PowerPC");
77 machineName = " PowerPC ";
78 78 break;
79 79 case EM_PPC64 :
80 strcpy(MachineName,"PowerPC 64-bit");
80 machineName = " PowerPC 64-bit ";
81 81 break;
82 82 case EM_S390 :
83 strcpy(MachineName,"IBM S390");
83 machineName = " IBM S390 ";
84 84 break;
85 85 case EM_V800 :
86 strcpy(MachineName,"NEC V800 series");
86 machineName = " NEC V800 series ";
87 87 break;
88 88 case EM_FR20 :
89 strcpy(MachineName,"Fujitsu FR20");
89 machineName = " Fujitsu FR20 ";
90 90 break;
91 91 case EM_RH32 :
92 strcpy(MachineName,"TRW RH-32");
92 machineName = " TRW RH-32 ";
93 93 break;
94 94 case EM_RCE :
95 strcpy(MachineName,"Motorola RCE");
95 machineName = " Motorola RCE ";
96 96 break;
97 97 case EM_ARM :
98 strcpy(MachineName,"ARM");
98 machineName = " ARM ";
99 break;
100 case EM_FAKE_ALPHA:
101 machineName = " Digital Alpha ";
99 102 break;
100 103 case EM_SH :
101 strcpy(MachineName,"Hitachi SH");
104 machineName = " Hitachi SH ";
102 105 break;
103 106 case EM_SPARCV9 :
104 strcpy(MachineName,"SPARC v9 64-bit");
107 machineName = " SPARC v9 64-bit ";
105 108 break;
106 109 case EM_TRICORE :
107 strcpy(MachineName,"Siemens Tricore");
110 machineName = " Siemens Tricore ";
108 111 break;
109 112 case EM_ARC :
110 strcpy(MachineName,"Argonaut RISC Core");
113 machineName = " Argonaut RISC Core ";
111 114 break;
112 115 case EM_H8_300 :
113 strcpy(MachineName,"Hitachi H8\/300");
116 machineName = " Hitachi H8/300 ";
114 117 break;
115 118 case EM_H8_300H :
116 strcpy(MachineName,"Hitachi H8\/300H");
119 machineName = " Hitachi H8/300H ";
117 120 break;
118 121 case EM_H8S :
119 strcpy(MachineName,"Hitachi H8S");
122 machineName = " Hitachi H8S ";
120 123 break;
121 124 case EM_H8_500 :
122 strcpy(MachineName,"Hitachi H8\/500");
125 machineName = " Hitachi H8/500 ";
123 126 break;
124 127 case EM_IA_64 :
125 strcpy(MachineName,"Intel Merced");
128 machineName = " Intel Merced ";
126 129 break;
127 130 case EM_MIPS_X :
128 strcpy(MachineName,"Stanford MIPS-X");
131 machineName = " Stanford MIPS-X ";
129 132 break;
130 133 case EM_COLDFIRE :
131 strcpy(MachineName,"Motorola Coldfire");
134 machineName = " Motorola Coldfire ";
132 135 break;
133 136 case EM_68HC12 :
134 strcpy(MachineName,"Motorola M68HC12");
137 machineName = " Motorola M68HC12 ";
135 138 break;
136 139 case EM_MMA :
137 strcpy(MachineName,"Fujitsu MMA Multimedia Accelerator");
140 machineName = " Fujitsu MMA Multimedia Accelerator";
138 141 break;
139 142 case EM_PCP :
140 strcpy(MachineName,"Siemens PCP");
143 machineName = " Siemens PCP ";
141 144 break;
142 145 case EM_NCPU :
143 strcpy(MachineName,"Sony nCPU embeeded RISC");
146 machineName = " Sony nCPU embeeded RISC ";
144 147 break;
145 148 case EM_NDR1 :
146 strcpy(MachineName,"Denso NDR1 microprocessor");
149 machineName = " Denso NDR1 microprocessor ";
147 150 break;
148 151 case EM_STARCORE :
149 strcpy(MachineName,"Motorola Start*Core processor");
152 machineName = " Motorola Start*Core processor ";
150 153 break;
151 154 case EM_ME16 :
152 strcpy(MachineName,"Toyota ME16 processor");
155 machineName = " Toyota ME16 processor ";
153 156 break;
154 157 case EM_ST100 :
155 strcpy(MachineName,"STMicroelectronic ST100 processor");
158 machineName = " STMicroelectronic ST100 processor ";
156 159 break;
157 160 case EM_TINYJ :
158 strcpy(MachineName,"Advanced Logic Corp. Tinyj emb.fam");
161 machineName = " Advanced Logic Corp. Tinyj emb.fam";
159 162 break;
160 163 case EM_X86_64 :
161 strcpy(MachineName,"AMD x86-64 architecture");
164 machineName = " AMD x86-64 architecture ";
162 165 break;
163 166 case EM_PDSP :
164 strcpy(MachineName,"Sony DSP Processor");
167 machineName = " Sony DSP Processor ";
165 168 break;
166 169 case EM_FX66 :
167 strcpy(MachineName,"Siemens FX66 microcontroller");
170 machineName = " Siemens FX66 microcontroller ";
168 171 break;
169 172 case EM_ST9PLUS :
170 strcpy(MachineName,"STMicroelectronics ST9+ 8\/16 mc");
173 machineName = " STMicroelectronics ST9+ 8/16 mc ";
171 174 break;
172 175 case EM_ST7 :
173 strcpy(MachineName,"STmicroelectronics ST7 8 bit mc");
176 machineName = " STmicroelectronics ST7 8 bit mc ";
174 177 break;
175 178 case EM_68HC16 :
176 strcpy(MachineName,"Motorola MC68HC16 microcontroller");
179 machineName = " Motorola MC68HC16 microcontroller ";
177 180 break;
178 181 case EM_68HC11 :
179 strcpy(MachineName,"Motorola MC68HC11 microcontroller");
182 machineName = " Motorola MC68HC11 microcontroller ";
180 183 break;
181 184 case EM_68HC08 :
182 strcpy(MachineName,"Motorola MC68HC08 microcontroller");
185 machineName = " Motorola MC68HC08 microcontroller ";
183 186 break;
184 187 case EM_68HC05 :
185 strcpy(MachineName,"Motorola MC68HC05 microcontroller");
188 machineName = " Motorola MC68HC05 microcontroller ";
186 189 break;
187 190 case EM_SVX :
188 strcpy(MachineName,"Silicon Graphics SVx");
191 machineName = " Silicon Graphics SVx ";
189 192 break;
190 193 case EM_ST19 :
191 strcpy(MachineName,"STMicroelectronics ST19 8 bit mc");
194 machineName = " STMicroelectronics ST19 8 bit mc ";
192 195 break;
193 196 case EM_VAX :
194 strcpy(MachineName,"Digital VAX");
197 machineName = " Digital VAX ";
195 198 break;
196 199 case EM_CRIS :
197 strcpy(MachineName,"Axis Communications 32-bit embedded processor");
200 machineName = " Axis Communications 32-bit embedded processor ";
198 201 break;
199 202 case EM_JAVELIN :
200 strcpy(MachineName,"Infineon Technologies 32-bit embedded processor");
203 machineName = " Infineon Technologies 32-bit embedded processor ";
201 204 break;
202 205 case EM_FIREPATH :
203 strcpy(MachineName,"Element 14 64-bit DSP Processor");
206 machineName = " Element 14 64-bit DSP Processor ";
204 207 break;
205 208 case EM_ZSP :
206 strcpy(MachineName,"LSI Logic 16-bit DSP Processor");
209 machineName = " LSI Logic 16-bit DSP Processor ";
207 210 break;
208 211 case EM_MMIX :
209 strcpy(MachineName,"Donald Knuth's educational 64-bit processor");
212 machineName = " Donald Knuth's educational 64-bit processor ";
210 213 break;
211 214 case EM_HUANY :
212 strcpy(MachineName,"Harvard University machine-independent object files");
215 machineName = " Harvard University machine-independent object files ";
213 216 break;
214 217 case EM_PRISM :
215 strcpy(MachineName,"SiTera Prism");
218 machineName = " SiTera Prism ";
216 219 break;
217 220 case EM_AVR :
218 strcpy(MachineName,"Atmel AVR 8-bit microcontroller");
221 machineName = " Atmel AVR 8-bit microcontroller ";
219 222 break;
220 223 case EM_FR30 :
221 strcpy(MachineName,"Fujitsu FR30");
224 machineName = " Fujitsu FR30 ";
222 225 break;
223 226 case EM_D10V :
224 strcpy(MachineName,"Mitsubishi D10V");
227 machineName = " Mitsubishi D10V ";
225 228 break;
226 229 case EM_D30V :
227 strcpy(MachineName,"Mitsubishi D30V");
230 machineName = " Mitsubishi D30V ";
228 231 break;
229 232 case EM_V850 :
230 strcpy(MachineName,"NEC v850");
233 machineName = " NEC v850 ";
231 234 break;
232 235 case EM_M32R :
233 strcpy(MachineName,"Mitsubishi M32R");
236 machineName = " Mitsubishi M32R ";
234 237 break;
235 238 case EM_MN10300 :
236 strcpy(MachineName,"Matsushita MN10300");
239 machineName = " Matsushita MN10300 ";
237 240 break;
238 241 case EM_MN10200 :
239 strcpy(MachineName,"Matsushita MN10200");
242 machineName = " Matsushita MN10200 ";
240 243 break;
241 244 case EM_PJ :
242 strcpy(MachineName,"picoJava");
245 machineName = " picoJava ";
243 246 break;
244 247 case EM_OPENRISC :
245 strcpy(MachineName,"OpenRISC 32-bit embedded processor");
248 machineName = " OpenRISC 32-bit embedded processor ";
246 249 break;
247 250 case EM_ARC_A5 :
248 strcpy(MachineName,"ARC Cores Tangent-A5");
251 machineName = " ARC Cores Tangent-A5 ";
249 252 break;
250 253 case EM_XTENSA :
251 strcpy(MachineName,"Tensilica Xtensa Architecture");
254 machineName = " Tensilica Xtensa Architecture ";
255 break;
256 case EM_AARCH64:
257 machineName = " ARM AARCH64 ";
258 break;
259 case EM_TILEPRO:
260 machineName = " Tilera TILEPro ";
261 break;
262 case EM_MICROBLAZE:
263 machineName = " Xilinx MicroBlaze ";
264 break;
265 case EM_TILEGX:
266 machineName = " Tilera TILE-Gx ";
267 break;
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