Skip to content

Commit e2185e2

Browse files
committed
Only import undefined symbols in the section-less ELF scan ##bin
1 parent 31452f0 commit e2185e2

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

libr/bin/format/elf/elf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4607,7 +4607,7 @@ static bool _read_symbols_from_phdr(ELFOBJ *eo, ReadPhdrSymbolState *state) {
46074607
ut64 toffset = 0;
46084608
// Zero symbol is always empty
46094609
// Examine entry and maybe store
4610-
if (type == R_BIN_ELF_IMPORT_SYMBOLS && (new_symbol.st_shndx == SHT_NULL || new_symbol.st_shndx == SHT_DYNSYM)) {
4610+
if (type == R_BIN_ELF_IMPORT_SYMBOLS && is_imported) {
46114611
if (new_symbol.st_value) {
46124612
toffset = new_symbol.st_value;
46134613
} else if ((toffset = Elf_(plt_get_import_addr) (eo, i)) == UT64_MAX) {

test/db/formats/elf/dynimports

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,14 @@ EXPECT=<<EOF
5050
0x00001350 5 caller
5151
EOF
5252
RUN
53+
54+
NAME=ELF: section-less mips defined symbol is not an import
55+
FILE=bins/elf/analysis/mipsbe-ubusd
56+
CMDS=<<EOF
57+
iiq~_ftext
58+
isq~_ftext
59+
EOF
60+
EXPECT=<<EOF
61+
0x00400ec0 0 _ftext
62+
EOF
63+
RUN

0 commit comments

Comments
 (0)