Skip to content

Commit 300f8e0

Browse files
committed
Speed up processing of symbols slightly, by not checking for each entry
1 parent 9ace73a commit 300f8e0

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

pwnlib/elf/elf.py

+6-13
Original file line numberDiff line numberDiff line change
@@ -545,21 +545,14 @@ def _populate_symbols(self):
545545
continue
546546

547547
for symbol in section.iter_symbols():
548-
if not symbol.entry.st_value:
548+
value = symbol.entry.st_value
549+
if not value:
549550
continue
551+
self.symbols[symbol.name] = value
550552

551-
self.symbols[symbol.name] = symbol.entry.st_value
552-
553-
# Add 'plt.foo' and 'got.foo' to the symbols for entries,
554-
# iff there is no symbol for that address
555-
for sym, addr in self.plt.items():
556-
if addr not in self.symbols.values():
557-
self.symbols['plt.%s' % sym] = addr
558-
559-
for sym, addr in self.got.items():
560-
if addr not in self.symbols.values():
561-
self.symbols['got.%s' % sym] = addr
562-
553+
# Add 'plt.foo' and 'got.foo' to the symbols for entries
554+
self.symbols.update({'plt.%s' % sym: addr for sym, addr in self.plt.items()})
555+
self.symbols.update({'got.%s' % sym: addr for sym, addr in self.got.items()})
563556

564557
def _populate_got_plt(self):
565558
"""Loads the GOT and the PLT symbols and addresses.

0 commit comments

Comments
 (0)