Skip to content

Commit c0f003e

Browse files
committed
Properly handle the case when .symtab does not exist in a file
* bdx/binary.py (_read_symbols_in_file): Return no symbols if the symbol table does not exist, in order to prevent the file from being always treated as unindexed.
1 parent 73d32a4 commit c0f003e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

bdx/binary.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from elftools.elf.sections import SymbolTableSection
2323
from sortedcontainers import SortedList
2424

25-
from bdx import debug, info, make_progress_bar, trace
25+
from bdx import debug, info, log, make_progress_bar, trace
2626

2727

2828
class NameDemangler:
@@ -313,6 +313,9 @@ def _read_symbols_in_file(
313313
use_dwarfdump: bool,
314314
) -> list[Symbol]:
315315
symtab = elf.get_section_by_name(".symtab")
316+
if symtab is None:
317+
log("warning: {}: .symtab section does not exist", file, symtab)
318+
return []
316319
if not isinstance(symtab, SymbolTableSection):
317320
msg = ".symtab is not a SymbolTableSection"
318321
raise RuntimeError(msg)

0 commit comments

Comments
 (0)