6
6
from typing import FrozenSet , List , Optional
7
7
8
8
import lief
9
- from lief .ELF import E_TYPE
10
9
11
10
from .binary import BinarySecurity
12
11
from .errors import ErrorParsingFailed
@@ -118,20 +117,20 @@ def set_dyn_syms(self) -> FrozenSet[str]:
118
117
119
118
@property
120
119
def relro (self ) -> RelroType :
121
- if self .bin .get (lief .ELF .SEGMENT_TYPES .GNU_RELRO ) is None :
120
+ if self .bin .get (lief .ELF .Segment . TYPE .GNU_RELRO ) is None :
122
121
return RelroType .No
123
122
124
- flags = self .bin .get (lief .ELF .DYNAMIC_TAGS .FLAGS )
123
+ flags = self .bin .get (lief .ELF .DynamicEntry . TAG .FLAGS )
125
124
if flags is None :
126
125
bind_now = False
127
126
else :
128
- bind_now = lief .ELF .DYNAMIC_FLAGS . BIND_NOW in flags
127
+ bind_now = flags . has ( lief .ELF .DynamicEntryFlags . FLAG . BIND_NOW )
129
128
130
- flags_1 = self .bin .get (lief .ELF .DYNAMIC_TAGS .FLAGS_1 )
129
+ flags_1 = self .bin .get (lief .ELF .DynamicEntry . TAG .FLAGS_1 )
131
130
if flags_1 is None :
132
131
now = False
133
132
else :
134
- now = lief .ELF .DYNAMIC_FLAGS_1 . NOW in flags_1
133
+ now = flags_1 . has ( lief .ELF .DynamicEntryFlags . FLAG . NOW )
135
134
136
135
if bind_now or now :
137
136
return RelroType .Full
@@ -151,44 +150,38 @@ def has_canary(self) -> bool:
151
150
152
151
@property
153
152
def pie (self ) -> PIEType :
154
- if self .bin .header .file_type == E_TYPE . DYNAMIC :
155
- if self .bin .has (lief .ELF .DYNAMIC_TAGS . DEBUG ):
153
+ if self .bin .header .file_type == lief . ELF . Header . FILE_TYPE . DYN :
154
+ if self .bin .has (lief .ELF .DynamicEntry . TAG . DEBUG_TAG ):
156
155
return PIEType .PIE
157
156
else :
158
157
return PIEType .DSO
159
- elif self .bin .header .file_type == E_TYPE . RELOCATABLE :
158
+ elif self .bin .header .file_type == lief . ELF . Header . FILE_TYPE . REL :
160
159
return PIEType .REL
161
160
return PIEType .No
162
161
163
162
@property
164
163
def has_rpath (self ) -> bool :
165
- try :
166
- if self .bin .get (lief .ELF .DYNAMIC_TAGS .RPATH ):
167
- return True
168
- except lief .not_found :
169
- pass
164
+ if self .bin .get (lief .ELF .DynamicEntry .TAG .RPATH ):
165
+ return True
170
166
return False
171
167
172
168
@property
173
169
def has_runpath (self ) -> bool :
174
- try :
175
- if self .bin .get (lief .ELF .DYNAMIC_TAGS .RUNPATH ):
176
- return True
177
- except lief .not_found :
178
- pass
170
+ if self .bin .get (lief .ELF .DynamicEntry .TAG .RUNPATH ):
171
+ return True
179
172
return False
180
173
181
174
@property
182
175
@lru_cache ()
183
176
def symbols (self ) -> List [str ]:
184
- return [symbol .name for symbol in self .bin .static_symbols ]
177
+ return [symbol .name for symbol in self .bin .symtab_symbols ]
185
178
186
179
@property
187
180
def is_stripped (self ) -> bool :
188
- # TODO: hwo to reset static_symbols iterator for the next call to symbols() ?
181
+ # TODO: how to reset symtab_symbols iterator for the next call to symbols() ?
189
182
# consumes only the first symbol from iterator, saving CPU cycles
190
183
try :
191
- next (self .bin .static_symbols )
184
+ next (self .bin .symtab_symbols )
192
185
except StopIteration :
193
186
return True
194
187
else :
0 commit comments