##// END OF EJS Templates
Elf Symbol enumeration working, elf update buggy!
jeandet -
r42:302baaf8abc1 default
parent child
Show More
@@ -708,8 +708,12 QString ElfFile::getSegmentFlags(int ind
708
708
709 QString ElfFile::getSectionName(int index)
709 QString ElfFile::getSectionName(int index)
710 {
710 {
711 char* nameChr = elf_strptr(this->e , this->shstrndx , this->sections.at(index)->section_header->sh_name);
711 if((index<sections.count()) && (index>=0))
712 return QString(nameChr);
712 {
713 char* nameChr = elf_strptr(this->e , this->shstrndx , this->sections.at(index)->section_header->sh_name);
714 return QString(nameChr);
715 }
716 return "";
713 }
717 }
714
718
715
719
@@ -824,6 +828,162 QString ElfFile::getSectionType(int inde
824 return type;
828 return type;
825 }
829 }
826
830
831 QString ElfFile::getSymbolName(int index)
832 {
833 if(this->e!=NULL)
834 {
835 if(index < this->symbols.count())
836 {
837 return symbols.at(index)->name;
838 }
839 }
840 return "";
841 }
842
843 QString ElfFile::getSymbolType(int index)
844 {
845 if(this->e!=NULL)
846 {
847 if(index < this->symbols.count())
848 {
849 int type = GELF_ST_TYPE(symbols.at(index)->sym->st_info);
850 switch(type)
851 {
852 case STT_NOTYPE:
853 return "No Type";
854 break;
855 case STT_OBJECT:
856 return "Object";
857 break;
858 case STT_FUNC:
859 return "Function";
860 break;
861 case STT_SECTION:
862 return "Section";
863 break;
864 case STT_FILE:
865 return "File";
866 break;
867 case STT_COMMON:
868 return "Common data object";
869 break;
870 case STT_TLS:
871 return "Thread-local data object";
872 break;
873 case STT_NUM:
874 return "Number of defined types";
875 break;
876 case STT_LOOS:
877 return "Start of OS-specific";
878 break;
879 case STT_HIOS:
880 return "End of OS-specific";
881 break;
882 case STT_LOPROC:
883 return "Start of processor-specific";
884 break;
885 case STT_HIPROC:
886 return "End of processor-specific";
887 break;
888 default:
889 return "none";
890 break;
891 }
892 }
893 }
894 return "none";
895 }
896
897 quint64 ElfFile::getSymbolSize(int index)
898 {
899 if(this->e!=NULL)
900 {
901 if((index < this->symbols.count()) && (index>=0))
902 {
903 return symbols.at(index)->sym->st_size;
904 }
905 }
906 return 0;
907 }
908
909 QString ElfFile::getSymbolSectionName(int index)
910 {
911 if(this->e!=NULL)
912 {
913 if((index < this->symbols.count()) && (index>=0))
914 {
915 return getSectionName(symbols.at(index)->sym->st_shndx-1);
916 }
917 }
918 return "none";
919 }
920
921 int ElfFile::getSymbolSectionIndex(int index)
922 {
923 if(this->e!=NULL)
924 {
925 if((index < this->symbols.count()) && (index>=0))
926 {
927 return symbols.at(index)->sym->st_shndx;
928 }
929 }
930 return 0;
931 }
932
933 quint64 ElfFile::getSymbolAddress(int index)
934 {
935 if(this->e!=NULL)
936 {
937 if((index < this->symbols.count()) && (index>=0))
938 {
939 return symbols.at(index)->sym->st_value;
940 }
941 }
942 return 0;
943 }
944
945 QString ElfFile::getSymbolLinkType(int index)
946 {
947 if(this->e!=NULL)
948 {
949 if(index < this->symbols.count())
950 {
951 int btype = GELF_ST_BIND(symbols.at(index)->sym->st_info);
952 switch(btype)
953 {
954 case STB_LOCAL:
955 return "Local";
956 break;
957 case STB_GLOBAL:
958 return "Global";
959 break;
960 case STB_WEAK:
961 return "Weak";
962 break;
963 case STB_NUM:
964 return "Number of defined types";
965 break;
966 case STB_LOOS:
967 return "Start of OS-specific";
968 break;
969 case STB_HIOS:
970 return "End of OS-specific";
971 break;
972 case STB_LOPROC:
973 return "Start of processor-specific";
974 break;
975 case STB_HIPROC:
976 return "End of processor-specific";
977 break;
978 default:
979 return "none";
980 break;
981 }
982 }
983 }
984 return "none";
985 }
986
827 bool ElfFile::isElf(const QString &File)
987 bool ElfFile::isElf(const QString &File)
828 {
988 {
829 int file =0;
989 int file =0;
@@ -77,22 +77,33 public:
77 QString getABI();
77 QString getABI();
78 qint64 getVersion();
78 qint64 getVersion();
79 qint64 getEntryPointAddress();
79 qint64 getEntryPointAddress();
80
80 int getSectionCount();
81 int getSectionCount();
81 int getSymbolCount();
82 int getSymbolCount();
82 int getSegmentCount();
83 int getSegmentCount();
84
83 QString getSegmentType(int index);
85 QString getSegmentType(int index);
84 qint64 getSegmentOffset(int index);
86 qint64 getSegmentOffset(int index);
85 qint64 getSegmentVaddr(int index);
87 qint64 getSegmentVaddr(int index);
86 qint64 getSegmentPaddr(int index);
88 qint64 getSegmentPaddr(int index);
87 qint64 getSectionPaddr(int index);
88 qint64 getSegmentFilesz(int index);
89 qint64 getSegmentFilesz(int index);
89 qint64 getSectionDatasz(int index);
90 qint64 getSectionDatasz(int index);
91 qint64 getSegmentMemsz(int index);
92 QString getSegmentFlags(int index);
93
90 bool getSectionData(int index, char **buffer);
94 bool getSectionData(int index, char **buffer);
91 qint64 getSegmentMemsz(int index);
95 qint64 getSectionPaddr(int index);
92 qint64 getSectionMemsz(int index);
96 qint64 getSectionMemsz(int index);
93 QString getSegmentFlags(int index);
94 QString getSectionName(int index);
97 QString getSectionName(int index);
95 QString getSectionType(int index);
98 QString getSectionType(int index);
99
100 QString getSymbolName(int index);
101 QString getSymbolType(int index);
102 quint64 getSymbolSize(int index);
103 QString getSymbolSectionName(int index);
104 int getSymbolSectionIndex(int index);
105 quint64 getSymbolAddress(int index);
106 QString getSymbolLinkType(int index);
96 bool iself();
107 bool iself();
97 static bool isElf(const QString& File);
108 static bool isElf(const QString& File);
98
109
@@ -1,5 +1,6
1 #include "elffilewidget.h"
1 #include "elffilewidget.h"
2 #include "ui_elffilewidget.h"
2 #include "ui_elffilewidget.h"
3 #include <QtWidgets/QTableWidgetItem>
3
4
4 elfFileWidget::elfFileWidget(QWidget *parent) :
5 elfFileWidget::elfFileWidget(QWidget *parent) :
5 QWidget(parent),
6 QWidget(parent),
@@ -28,6 +29,41 void elfFileWidget::updateElfFile(ElfFil
28 this->ui->sectionCountLabel->setText(QString::number(p_elf->getSectionCount()));
29 this->ui->sectionCountLabel->setText(QString::number(p_elf->getSectionCount()));
29 this->ui->symbolCountLabel->setText(QString::number(p_elf->getSymbolCount()));
30 this->ui->symbolCountLabel->setText(QString::number(p_elf->getSymbolCount()));
30 }
31 }
32 updateSymbols();
33 }
34
35 void elfFileWidget::updateSymbols()
36 {
37 this->ui->symbolsList->clear();
38 this->ui->symbolsList->setRowCount(p_elf->getSymbolCount());
39 this->ui->symbolsList->setHorizontalHeaderLabels(QStringList()<<"Value"<<"Size"<<"Type"<<"Link"<<"Section"<<"Name");
40 for(int i=0;i<p_elf->getSymbolCount();i++)
41 {
42 QTableWidgetItem *newItem = new QTableWidgetItem(QString("0x%1").arg(p_elf->getSymbolAddress(i),8,16));
43 newItem->setFlags(newItem->flags() ^ Qt::ItemIsEditable);
44 this->ui->symbolsList->setItem(i, 0, newItem);
45
46 newItem = new QTableWidgetItem(QString("0x%1").arg(p_elf->getSymbolSize(i),8,16));
47 newItem->setFlags(newItem->flags() ^ Qt::ItemIsEditable);
48 this->ui->symbolsList->setItem(i, 1, newItem);
49
50 newItem = new QTableWidgetItem(p_elf->getSymbolType(i));
51 newItem->setFlags(newItem->flags() ^ Qt::ItemIsEditable);
52 this->ui->symbolsList->setItem(i, 2, newItem);
53
54 newItem = new QTableWidgetItem(p_elf->getSymbolLinkType(i));
55 newItem->setFlags(newItem->flags() ^ Qt::ItemIsEditable);
56 this->ui->symbolsList->setItem(i, 3, newItem);
57
58 newItem = new QTableWidgetItem(p_elf->getSymbolSectionName(i));
59 newItem->setFlags(newItem->flags() ^ Qt::ItemIsEditable);
60 this->ui->symbolsList->setItem(i, 4, newItem);
61
62 newItem = new QTableWidgetItem(p_elf->getSymbolName(i));
63 newItem->setFlags(newItem->flags() ^ Qt::ItemIsEditable);
64 this->ui->symbolsList->setItem(i, 5, newItem);
65 }
66 this->ui->symbolsList->resizeColumnsToContents();
31 }
67 }
32
68
33
69
@@ -43,4 +79,3 void elfFileWidget::updateElfFile(ElfFil
43
79
44
80
45
81
46
@@ -18,6 +18,7 public:
18
18
19 public slots:
19 public slots:
20 void updateElfFile(ElfFile* file);
20 void updateElfFile(ElfFile* file);
21 void updateSymbols();
21
22
22 private:
23 private:
23 Ui::elfFileWidget *ui;
24 Ui::elfFileWidget *ui;
@@ -6,8 +6,8
6 <rect>
6 <rect>
7 <x>0</x>
7 <x>0</x>
8 <y>0</y>
8 <y>0</y>
9 <width>622</width>
9 <width>786</width>
10 <height>398</height>
10 <height>387</height>
11 </rect>
11 </rect>
12 </property>
12 </property>
13 <property name="minimumSize">
13 <property name="minimumSize">
@@ -26,7 +26,7
26 <item row="0" column="0">
26 <item row="0" column="0">
27 <widget class="QTabWidget" name="tabWidget">
27 <widget class="QTabWidget" name="tabWidget">
28 <property name="currentIndex">
28 <property name="currentIndex">
29 <number>0</number>
29 <number>1</number>
30 </property>
30 </property>
31 <widget class="QWidget" name="generalInfoTab">
31 <widget class="QWidget" name="generalInfoTab">
32 <attribute name="title">
32 <attribute name="title">
@@ -185,7 +185,41
185 </attribute>
185 </attribute>
186 <layout class="QGridLayout" name="gridLayout_2">
186 <layout class="QGridLayout" name="gridLayout_2">
187 <item row="0" column="0">
187 <item row="0" column="0">
188 <widget class="QTableWidget" name="symbolsList"/>
188 <widget class="QTableWidget" name="symbolsList">
189 <property name="sortingEnabled">
190 <bool>true</bool>
191 </property>
192 <column>
193 <property name="text">
194 <string>Value</string>
195 </property>
196 </column>
197 <column>
198 <property name="text">
199 <string>Size</string>
200 </property>
201 </column>
202 <column>
203 <property name="text">
204 <string>Type</string>
205 </property>
206 </column>
207 <column>
208 <property name="text">
209 <string>Link</string>
210 </property>
211 </column>
212 <column>
213 <property name="text">
214 <string>Section</string>
215 </property>
216 </column>
217 <column>
218 <property name="text">
219 <string>Name</string>
220 </property>
221 </column>
222 </widget>
189 </item>
223 </item>
190 </layout>
224 </layout>
191 </widget>
225 </widget>
General Comments 0
You need to be logged in to leave comments. Login now