-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathELFSectionHeaderTable.lua
More file actions
58 lines (48 loc) · 2.25 KB
/
Copy pathELFSectionHeaderTable.lua
File metadata and controls
58 lines (48 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
local ELFSectionHeaderTable = {}
ELFSectionHeaderTable._fileReader = nil
ELFSectionHeaderTable._sectionHeaderTableInformation = nil
function ELFSectionHeaderTable:new(object, fileReader, header)
object = object or {}
setmetatable(object, self)
self.__index = self
if header and fileReader then
self._fileReader = fileReader
self._sectionHeaderTableInformation = header:readSectionHeaderTableInformation()
end
return object
end
function ELFSectionHeaderTable:_readSectionHeaderFlagsByOffset(offset)
end
function ELFSectionHeaderTable:_readSectionHeaderInformationByOffset(offset)
end
function ELFSectionHeaderTable:mIsDynamicLinkingSymbolSection(sectionHeaderType)
return sectionHeaderType == 0x0b
end
function ELFSectionHeaderTable:mIsDynamicLinkingStringSection(sectionHeaderType, sectionHeaderFlags)
return sectionHeaderType == 0x3 and sectionHeaderFlags == 0x2
end
function ELFSectionHeaderTable:readInformationDynamicLinkingSections()
local informationDynamicLinkingSections = {}
do
local sectionHeaderOffset = self._sectionHeaderTableInformation.off
local sectionType, sectionFlags
local loopBreaks = 0
for i = 1, self._sectionHeaderTableInformation.num do
sectionHeaderType = self._fileReader:readInteger32ByOffset(sectionHeaderOffset + 0x4)
sectionHeaderFlags = self:_readSectionHeaderFlagsByOffset(sectionHeaderOffset)
if self:mIsDynamicLinkingSymbolSection(sectionHeaderType) then
informationDynamicLinkingSections.dynsym = self:_readSectionHeaderInformationByOffset(sectionHeaderOffset)
loopBreaks = loopBreaks + 1
elseif self:mIsDynamicLinkingStringSection(sectionHeaderType, sectionHeaderFlags) then
informationDynamicLinkingSections.dynstr = self:_readSectionHeaderInformationByOffset(sectionHeaderOffset)
loopBreaks = loopBreaks + 1
end
if(LoopBreaks == 2) then
break
end
sectionHeaderOffset = sectionHeaderOffset + self._sectionHeaderTableInformation.entsize
end
end
return informationDynamicLinkingSections
end
return ELFSectionHeaderTable