added binary file loader, improved elf and srec loaders
jeandet -
r47:f8c5117dac7c default
Not Reviewed
Show More
Add another comment
TODOs: 0 unresolved 0 Resolved
COMMENTS: 0 General 0 Inline
@@ -0,0 +1,150
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
4 --
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
7 -- the Free Software Foundation; either version 2 of the License, or
8 -- (at your option) any later version.
9 --
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
14 --
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
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@member.fsf.org
21 ----------------------------------------------------------------------------*/
22 #include "binaryfile.h"
23
24 binaryFile::binaryFile()
25 {
26 }
27
28 binaryFile::binaryFile(const QString &File)
29 {
30 openFile(File);
31 }
32
33 binaryFile::binaryFile(const QStringList &Files)
34 {
35 openFiles(Files);
36 }
37
38 binaryFile::~binaryFile()
39 {
40
41 }
42
43 bool binaryFile::openFile(const QString &File)
44 {
45 return openFiles(QStringList()<<File);
46 }
47
48 bool binaryFile::openFiles(const QStringList &Files)
49 {
50 this->p_fileNames.clear();
51 this->p_fileNames.append(Files);
52 for(int i=0;i<p_files.count();i++)
53 {
54 delete p_files.at(i);
55 }
56 this->p_files.clear();
57 for(int i=0;i<Files.count();i++)
58 {
59 this->p_files.append(new QFile(Files.at(i)));
60 this->p_files.at(i)->open(QIODevice::ReadOnly);
61 loadFile(this->p_files.at(i));
62 }
63 return true;
64 }
65
66 bool binaryFile::isopened()
67 {
68 bool opened = true;
69 for(int i=0;i<this->p_files.count();i++)
70 {
71 opened &= p_files.at(i)->isOpen();
72 }
73 return opened;
74 }
75
76 int binaryFile::closeFile()
77 {
78 for(int i=0;i<p_files.count();i++)
79 {
80 delete p_files.at(i);
81 for(int j=0;j<p_fragments.count();j++)
82 {
83 if(p_fragments.at(j)->header == p_files.at(i)->fileName())
84 {
85 codeFragment* fragment = p_fragments.at(j);
86 p_fragments.removeAt(j);
87 free(fragment->data);
88 delete fragment;
89 }
90 }
91 }
92 p_files.clear();
93 p_fileName.clear();
94 return 0;
95 }
96
97 QList<codeFragment *> binaryFile::getFragments()
98 {
99 return p_fragments;
100 }
101
102 int binaryFile::getFragmentsCount()
103 {
104 return p_fragments.count();
105 }
106
107 int binaryFile::getFragmentAddress(int index)
108 {
109 if((index>=0)&&(index<p_fragments.count()))
110 return p_fragments.at(index)->address;
111 return 0;
112 }
113
114 int binaryFile::getFragmentSize(int index)
115 {
116 if((index>=0)&&(index<p_fragments.count()))
117 return p_fragments.at(index)->size;
118 return 0;
119 }
120
121 QString binaryFile::getFragmentHeader(int index)
122 {
123 if((index>=0)&&(index<p_fragments.count()))
124 return p_fragments.at(index)->header;
125 return "";
126 }
127
128 bool binaryFile::getFragmentData(int index, char **buffer)
129 {
130 if((index>=0)&&(index<p_fragments.count()))
131 {
132 *buffer = p_fragments.at(index)->data;
133 return true;
134 }
135 return false;
136 }
137
138 void binaryFile::loadFile(QFile *file)
139 {
140 if (file->isOpen())
141 {
142 codeFragment* fragment = new codeFragment();
143 fragment->header = file->fileName();
144 fragment->address = 0;
145 fragment->size = file->size();
146 fragment->data = (char*)malloc(file->size());
147 file->read(fragment->data,file->size());
148 p_fragments.append(fragment);
149 }
150 }
@@ -0,0 +1,60
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
4 --
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
7 -- the Free Software Foundation; either version 2 of the License, or
8 -- (at your option) any later version.
9 --
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
14 --
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
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@member.fsf.org
21 ----------------------------------------------------------------------------*/
22 #ifndef BINARYFILE_H
23 #define BINARYFILE_H
24 #include "abstractbinfile.h"
25 #include <QObject>
26 #include <QString>
27 #include <QList>
28 #include <QStringList>
29 #include <QFile>
30
31 class binaryFile : public abstractBinFile
32 {
33 Q_OBJECT
34 public:
35 explicit binaryFile();
36 binaryFile(const QString& File);
37 binaryFile(const QStringList& Files);
38 ~binaryFile();
39 bool openFile(const QString& File);
40 bool openFiles(const QStringList& Files);
41 bool isopened();
42 int closeFile();
43 QList<codeFragment*> getFragments();
44 int getFragmentsCount();
45 int getFragmentAddress(int index);
46 int getFragmentSize(int index);
47 QString getFragmentHeader(int index);
48 bool getFragmentData(int index, char **buffer);
49 signals:
50
51 public slots:
52
53 private:
54 void loadFile(QFile *file);
55 QStringList p_fileNames;
56 QList<QFile*>p_files;
57 QList<codeFragment*> p_fragments;
58 };
59
60 #endif // BINARYFILE_H
@@ -0,0 +1,82
1 #include "binaryfilewidget.h"
2 #include "ui_binaryfilewidget.h"
3 #include "qtablewidgetintitem.h"
4 #include <QtWidgets/QTableWidget>
5
6 binaryFileWidget::binaryFileWidget(QWidget *parent) :
7 QWidget(parent),
8 ui(new Ui::binaryFileWidget)
9 {
10 ui->setupUi(this);
11 connect(this->ui->fragmentList,SIGNAL(cellActivated(int,int)),this,SLOT(fragmentCellActivated(int,int)));
12 connect(this->ui->fragmentList,SIGNAL(cellChanged(int,int)),this,SLOT(fragmentCellChanged(int,int)));
13 }
14
15 binaryFileWidget::~binaryFileWidget()
16 {
17 delete ui;
18 }
19
20 void binaryFileWidget::updateBinaryFile(binaryFile *file)
21 {
22 this->p_binfile = file;
23 if(p_binfile->isopened())
24 {
25 updateFragments();
26 }
27 }
28
29 void binaryFileWidget::updateFragments()
30 {
31 this->ui->fragmentList->clear();
32 this->ui->fragmentList->setRowCount(p_binfile->getFragmentsCount());
33 this->ui->fragmentList->setHorizontalHeaderLabels(QStringList()<<"File"<<"Size"<<"Address");
34 for(int i=0;i<p_binfile->getFragmentsCount();i++)
35 {
36 QTableWidgetItem *newItem = new QTableWidgetItem(p_binfile->getFragmentHeader(i));
37 newItem->setFlags(newItem->flags() ^ Qt::ItemIsEditable);
38 this->ui->fragmentList->setItem(i, 0, newItem);
39
40 newItem = (QTableWidgetItem*)new QTableWidgetIntItem(QString("%1").arg(p_binfile->getFragmentSize(i)),DecimalItem);
41 newItem->setFlags(newItem->flags() ^ Qt::ItemIsEditable);
42 this->ui->fragmentList->setItem(i, 1, newItem);
43
44 newItem = (QTableWidgetItem*)new QTableWidgetIntItem(QString("0x%1").arg(p_binfile->getFragmentAddress(i),8,16).replace(" ","0"),HexaDecimalItem);
45 // newItem->setFlags(newItem->flags() ^ Qt::ItemIsEditable);
46 this->ui->fragmentList->setItem(i, 2, newItem);
47
48 }
49 this->ui->fragmentList->resizeColumnsToContents();
50 }
51
52 void binaryFileWidget::fragmentCellActivated(int row, int column)
53 {
54 Q_UNUSED(column)
55 char* buff=NULL;
56 int index = this->ui->fragmentList->item(row,0)->text().toInt();
57 if(index!=-1)
58 {
59 this->p_binfile->getFragmentData(index,&buff);
60 this->ui->hexViewer->setData(QByteArray(buff,this->p_binfile->getFragmentSize(index)));
61 this->ui->hexViewer->setAddressOffset(this->p_binfile->getFragmentAddress(index));
62 }
63 }
64
65 void binaryFileWidget::fragmentCellChanged(int row, int column)
66 {
67 if(column==2)
68 {
69 QString newAddressStr = this->ui->fragmentList->item(row,column)->text();
70 int newAddress = 0;
71 newAddressStr.remove(" ");
72 if(newAddressStr.at(0)=='0' && newAddressStr.at(1)=='x')
73 {
74 newAddress = newAddressStr.remove("0x").toUInt(0,16);
75 }
76 else
77 {
78 newAddress = newAddressStr.toUInt();
79 }
80 this->p_binfile->getFragments().at(row)->address = newAddress;
81 }
82 }
@@ -0,0 +1,32
1 #ifndef BINARYFILEWIDGET_H
2 #define BINARYFILEWIDGET_H
3
4 #include <QWidget>
5 #include "binaryfile.h"
6
7 namespace Ui {
8 class binaryFileWidget;
9 }
10
11 class binaryFileWidget : public QWidget
12 {
13 Q_OBJECT
14
15 public:
16 explicit binaryFileWidget(QWidget *parent = 0);
17 ~binaryFileWidget();
18
19 public slots:
20 void updateBinaryFile(binaryFile* file);
21 void updateFragments();
22
23 private slots:
24 void fragmentCellActivated(int row, int column);
25 void fragmentCellChanged(int row, int column);
26
27 private:
28 Ui::binaryFileWidget *ui;
29 binaryFile* p_binfile;
30 };
31
32 #endif // BINARYFILEWIDGET_H
@@ -0,0 +1,61
1 <?xml version="1.0" encoding="UTF-8"?>
2 <ui version="4.0">
3 <class>binaryFileWidget</class>
4 <widget class="QWidget" name="binaryFileWidget">
5 <property name="geometry">
6 <rect>
7 <x>0</x>
8 <y>0</y>
9 <width>637</width>
10 <height>342</height>
11 </rect>
12 </property>
13 <property name="windowTitle">
14 <string>Form</string>
15 </property>
16 <layout class="QGridLayout" name="gridLayout">
17 <item row="0" column="0">
18 <widget class="QSplitter" name="splitter">
19 <property name="orientation">
20 <enum>Qt::Horizontal</enum>
21 </property>
22 <widget class="QHexEdit" name="hexViewer" native="true">
23 <property name="minimumSize">
24 <size>
25 <width>200</width>
26 <height>0</height>
27 </size>
28 </property>
29 </widget>
30 <widget class="QTableWidget" name="fragmentList">
31 <column>
32 <property name="text">
33 <string>File</string>
34 </property>
35 </column>
36 <column>
37 <property name="text">
38 <string>Size</string>
39 </property>
40 </column>
41 <column>
42 <property name="text">
43 <string>Address</string>
44 </property>
45 </column>
46 </widget>
47 </widget>
48 </item>
49 </layout>
50 </widget>
51 <customwidgets>
52 <customwidget>
53 <class>QHexEdit</class>
54 <extends>QWidget</extends>
55 <header location="global">qhexedit.h</header>
56 <container>1</container>
57 </customwidget>
58 </customwidgets>
59 <resources/>
60 <connections/>
61 </ui>
@@ -122,7 +122,7 public:
122 virtual int baseAddress();
122 virtual int baseAddress();
123 //! Sets the base address of the current instance, for example if your plugin is supposed to drive
123 //! Sets the base address of the current instance, for example if your plugin is supposed to drive
124 //! an UART it will correspond to the address of it's first register. This address have at least to
124 //! an UART it will correspond to the address of it's first register. This address have at least to
125 //! be set by lppSocExplorer and it can be user accessible if you want.
125 //! be set by SocExplorer and it can be user accessible if you want.
126 virtual void setBaseAddress(unsigned int baseAddress);
126 virtual void setBaseAddress(unsigned int baseAddress);
127
127
128 genericPySysdriver* getPyObjectWrapper(){return this->pyObject;}
128 genericPySysdriver* getPyObjectWrapper(){return this->pyObject;}
@@ -13,3 +13,5
13 #include "QCustomPlot/qcustomplot.h"
13 #include "QCustomPlot/qcustomplot.h"
14 #include "srec/srecfile.h"
14 #include "srec/srecfile.h"
15 #include "srec/srecfilewidget.h"
15 #include "srec/srecfilewidget.h"
16 #include "BinFile/binaryfile.h"
17 #include "BinFile/binaryfilewidget.h"
@@ -44,7 +44,10 header.files = \
44 qtablewidgetintitem.h \
44 qtablewidgetintitem.h \
45 srec/srecfile.h \
45 srec/srecfile.h \
46 srec/srecfilewidget.h \
46 srec/srecfilewidget.h \
47 abstractbinfile.cpp
47 abstractbinfile.h \
48 BinFile/binaryfile.h \
49 BinFile/binaryfilewidget.h
50
48
51
49 win32{
52 win32{
50 elfheader.path = $$[QT_INSTALL_HEADERS]/SocExplorer/common/libelf
53 elfheader.path = $$[QT_INSTALL_HEADERS]/SocExplorer/common/libelf
@@ -92,7 +95,9 HEADERS += \
92 qtablewidgetintitem.h \
95 qtablewidgetintitem.h \
93 srec/srecfile.h \
96 srec/srecfile.h \
94 srec/srecfilewidget.h \
97 srec/srecfilewidget.h \
95 abstractbinfile.h
98 abstractbinfile.h \
99 BinFile/binaryfile.h \
100 BinFile/binaryfilewidget.h
96
101
97
102
98 SOURCES += \
103 SOURCES += \
@@ -114,11 +119,14 SOURCES += \
114 qtablewidgetintitem.cpp \
119 qtablewidgetintitem.cpp \
115 srec/srecfile.cpp \
120 srec/srecfile.cpp \
116 srec/srecfilewidget.cpp \
121 srec/srecfilewidget.cpp \
117 abstractbinfile.cpp
122 abstractbinfile.cpp \
123 BinFile/binaryfile.cpp \
124 BinFile/binaryfilewidget.cpp
118
125
119 FORMS += \
126 FORMS += \
120 elf/elffilewidget.ui \
127 elf/elffilewidget.ui \
121 srec/srecfilewidget.ui
128 srec/srecfilewidget.ui \
129 BinFile/binaryfilewidget.ui
122
130
123 OTHER_FILES += \
131 OTHER_FILES += \
124 ./pythongenerator.sh \
132 ./pythongenerator.sh \
@@ -29,7 +29,7 ElfFile::ElfFile()
29 {
29 {
30 this->opened = false;
30 this->opened = false;
31 this->type_elf = false;
31 this->type_elf = false;
32 this->elfFile = NULL;
32 this->elfFile = (int)NULL;
33 this->e = NULL;
33 this->e = NULL;
34 }
34 }
35
35
@@ -38,7 +38,7 ElfFile::ElfFile(const QString &File)
38 {
38 {
39 this->opened = false;
39 this->opened = false;
40 this->type_elf = false;
40 this->type_elf = false;
41 this->elfFile = NULL;
41 this->elfFile = (int)NULL;
42 this->e = NULL;
42 this->e = NULL;
43 this->p_fileName = File;
43 this->p_fileName = File;
44 openFile(File);
44 openFile(File);
@@ -76,7 +76,7 bool ElfFile::openFile(const QString &Fi
76 #else
76 #else
77 this->elfFile = open(File.toStdString().c_str(),O_RDONLY ,0);
77 this->elfFile = open(File.toStdString().c_str(),O_RDONLY ,0);
78 #endif
78 #endif
79 if(this->elfFile==NULL)return 0;
79 if(this->elfFile==(int)NULL)return 0;
80 this->e = elf_begin(this->elfFile,ELF_C_READ,NULL);
80 this->e = elf_begin(this->elfFile,ELF_C_READ,NULL);
81 if(this->e==NULL)return 0;
81 if(this->e==NULL)return 0;
82 this->ek = elf_kind(this->e);
82 this->ek = elf_kind(this->e);
@@ -96,7 +96,7 bool ElfFile::isopened()
96
96
97 int ElfFile::closeFile()
97 int ElfFile::closeFile()
98 {
98 {
99 if(this->elfFile!=NULL)
99 if(this->elfFile!=(int)NULL)
100 {
100 {
101 if(this->e!=NULL)
101 if(this->e!=NULL)
102 {
102 {
@@ -104,7 +104,7 int ElfFile::closeFile()
104 this->e = NULL;
104 this->e = NULL;
105 }
105 }
106 close(this->elfFile);
106 close(this->elfFile);
107 this->elfFile = NULL;
107 this->elfFile = (int)NULL;
108 }
108 }
109 this->opened = false;
109 this->opened = false;
110 return 0;
110 return 0;
@@ -502,6 +502,7 qint64 ElfFile::getVersion()
502 {
502 {
503 return this->ehdr.e_version;
503 return this->ehdr.e_version;
504 }
504 }
505 return -1;
505 }
506 }
506
507
507 qint64 ElfFile::getEntryPointAddress()
508 qint64 ElfFile::getEntryPointAddress()
@@ -510,6 +511,7 qint64 ElfFile::getEntryPointAddress()
510 {
511 {
511 return this->ehdr.e_entry;
512 return this->ehdr.e_entry;
512 }
513 }
514 return -1;
513 }
515 }
514
516
515
517
@@ -591,12 +593,12 QString ElfFile::getSegmentType(int inde
591
593
592 qint64 ElfFile::getSegmentOffset(int index)
594 qint64 ElfFile::getSegmentOffset(int index)
593 {
595 {
594 int64_t Offset;
596 qint64 Offset = -1;
595 if(this->e!=NULL)
597 if(this->e!=NULL)
596 {
598 {
597 if(index < this->Segments.count())
599 if(index < this->Segments.count())
598 {
600 {
599 Offset = (int64_t)this->Segments.at(index)->p_offset;
601 Offset = (qint64)this->Segments.at(index)->p_offset;
600 }
602 }
601 }
603 }
602 return Offset;
604 return Offset;
@@ -664,7 +666,14 qint64 ElfFile::getSectionDatasz(int ind
664 {
666 {
665 if(index < this->sections.count())
667 if(index < this->sections.count())
666 {
668 {
667 DataSz = (int64_t)this->sections.at(index)->data->d_size;
669 if(this->sections.at(index)->section_header->sh_type==SHT_NOBITS)
670 {
671 DataSz=0;
672 }
673 else
674 {
675 DataSz = (int64_t)this->sections.at(index)->data->d_size;
676 }
668 }
677 }
669 }
678 }
670 return DataSz;
679 return DataSz;
@@ -769,7 +778,7 void ElfFile::updateSegments()
769 free(this->Segments.at(i));
778 free(this->Segments.at(i));
770 }
779 }
771 this->Segments.clear();
780 this->Segments.clear();
772 for(int i=0;i<this->SegmentCount;i++)
781 for(int i=0;i<(int)this->SegmentCount;i++)
773 {
782 {
774 GElf_Phdr* header=(GElf_Phdr*)malloc(sizeof(GElf_Phdr));
783 GElf_Phdr* header=(GElf_Phdr*)malloc(sizeof(GElf_Phdr));
775 gelf_getphdr (this->e , i , header );
784 gelf_getphdr (this->e , i , header );
@@ -785,7 +794,7 void ElfFile::updateSymbols()
785 }
794 }
786 this->symbols.clear();
795 this->symbols.clear();
787 updateSections(); //Useless in most case but safer to do it
796 updateSections(); //Useless in most case but safer to do it
788 for(int i=0;i<SectionCount;i++)
797 for(int i=0;i<(int)SectionCount;i++)
789 {
798 {
790 //First find Symbol table
799 //First find Symbol table
791 if(this->getSectionName(i)==".symtab")
800 if(this->getSectionName(i)==".symtab")
@@ -793,7 +802,7 void ElfFile::updateSymbols()
793 Elf_Section* sec = sections.at(i);
802 Elf_Section* sec = sections.at(i);
794 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;
795 //Then list all symbols
804 //Then list all symbols
796 for(int j=0;j<this->SymbolCount;j++)
805 for(int j=0;j<(int)this->SymbolCount;j++)
797 {
806 {
798 GElf_Sym* esym = (GElf_Sym*)malloc(sizeof(GElf_Sym));
807 GElf_Sym* esym = (GElf_Sym*)malloc(sizeof(GElf_Sym));
799 gelf_getsym(sec->data, j, esym);
808 gelf_getsym(sec->data, j, esym);
@@ -813,9 +822,9 QString ElfFile::getSectionType(int inde
813 QString type("");
822 QString type("");
814 if(this->e!=NULL)
823 if(this->e!=NULL)
815 {
824 {
816 if(index < this->Segments.count())
825 if(index < this->sections.count())
817 {
826 {
818 switch(this->Segments.at(index)->p_type)
827 switch(this->sections.at(index)->section_header->sh_type)
819 {
828 {
820 case SHT_NULL : type = "Section header table entry unused"; break;
829 case SHT_NULL : type = "Section header table entry unused"; break;
821 case SHT_PROGBITS : type = "Program data"; break;
830 case SHT_PROGBITS : type = "Program data"; break;
@@ -857,13 +866,25 int ElfFile::getSectionIndex(QString nam
857 {
866 {
858 for(int i=0;i<sections.count();i++)
867 for(int i=0;i<sections.count();i++)
859 {
868 {
860 if(getSectionName(i)==name)
869 if(getSectionName(i)==name)
861 return i;
870 return i;
862 }
871 }
863 }
872 }
864 return -1;
873 return -1;
865 }
874 }
866
875
876 bool ElfFile::sectionIsNobits(int index)
877 {
878 if(this->e!=NULL)
879 {
880 if(index < this->sections.count())
881 {
882 return this->sections.at(index)->section_header->sh_type== SHT_NOBITS;
883 }
884 }
885 return false;
886 }
887
867 QString ElfFile::getSymbolName(int index)
888 QString ElfFile::getSymbolName(int index)
868 {
889 {
869 if(this->e!=NULL)
890 if(this->e!=NULL)
@@ -948,7 +969,7 QString ElfFile::getSymbolSectionName(in
948 {
969 {
949 if((index < this->symbols.count()) && (index>=0))
970 if((index < this->symbols.count()) && (index>=0))
950 {
971 {
951 return getSectionName(symbols.at(index)->sym->st_shndx-1);
972 return getSectionName(symbols.at(index)->sym->st_shndx-1);
952 }
973 }
953 }
974 }
954 return "none";
975 return "none";
@@ -960,7 +981,7 int ElfFile::getSymbolSectionIndex(int i
960 {
981 {
961 if((index < this->symbols.count()) && (index>=0))
982 if((index < this->symbols.count()) && (index>=0))
962 {
983 {
963 return symbols.at(index)->sym->st_shndx;
984 return symbols.at(index)->sym->st_shndx;
964 }
985 }
965 }
986 }
966 return 0;
987 return 0;
@@ -1031,9 +1052,9 bool ElfFile::isElf(const QString &File)
1031 char Magic[4];
1052 char Magic[4];
1032 if(file!=-1)
1053 if(file!=-1)
1033 {
1054 {
1034 read(file,Magic,4);
1055 size_t res = read(file,Magic,4);
1035 close(file);
1056 close(file);
1036 if(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))
1037 {
1058 {
1038 return true;
1059 return true;
1039 }
1060 }
@@ -88,16 +88,17 public:
88 qint64 getSegmentVaddr(int index);
88 qint64 getSegmentVaddr(int index);
89 qint64 getSegmentPaddr(int index);
89 qint64 getSegmentPaddr(int index);
90 qint64 getSegmentFilesz(int index);
90 qint64 getSegmentFilesz(int index);
91 qint64 getSectionDatasz(int index);
92 qint64 getSegmentMemsz(int index);
91 qint64 getSegmentMemsz(int index);
93 QString getSegmentFlags(int index);
92 QString getSegmentFlags(int index);
94
93
95 bool getSectionData(int index, char **buffer);
94 bool getSectionData(int index, char **buffer);
96 qint64 getSectionPaddr(int index);
95 qint64 getSectionPaddr(int index);
97 qint64 getSectionMemsz(int index);
96 qint64 getSectionMemsz(int index);
97 qint64 getSectionDatasz(int index);
98 QString getSectionName(int index);
98 QString getSectionName(int index);
99 QString getSectionType(int index);
99 QString getSectionType(int index);
100 int getSectionIndex(QString name);
100 int getSectionIndex(QString name);
101 bool sectionIsNobits(int index);
101
102
102 QString getSymbolName(int index);
103 QString getSymbolName(int index);
103 QString getSymbolType(int index);
104 QString getSymbolType(int index);
@@ -1,15 +1,52
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the SocExplorer Software
3