You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Except the shared lib (test-mips-64bit-le-lib), these parse correctly, but selecting imported symbols/function is failing.
To Reproduce
I have the following python code to show list imported symbols/functions:
import lief
import sys
lief.logging.set_level(lief.logging.LOGGING_LEVEL.DEBUG)
l = lief.parse(sys.argv[1])
print("SYMBOLS", [s.name for s in l.symbols])
print("FUNCTIONS", [s.name for s in l.functions])
print("IMPORTED SYMBOLS", [s.name for s in l.imported_symbols])
print("IMPORTED FUNCTIONS", [s.name for s in l.imported_functions])
Expected behavior
Neither printf nor strcpy are listed in imported, while they should be.
For each ELF Symbol is_imported status is defined here:
bool Symbol::is_imported() const {
// An import must not be defined in a section
bool is_imported = shndx() == static_cast<uint16_t>(SYMBOL_SECTION_INDEX::SHN_UNDEF);
// An import must not have an address
is_imported = is_imported && value() == 0;
// its name must not be empty
is_imported = is_imported && !name().empty();
// It must have a GLOBAL or WEAK bind
is_imported = is_imported && (binding() == SYMBOL_BINDINGS::STB_GLOBAL ||
binding() == SYMBOL_BINDINGS::STB_WEAK);
// It must be a FUNC or an OBJECT
is_imported = is_imported && (type() == ELF_SYMBOL_TYPES::STT_FUNC ||
type() == ELF_SYMBOL_TYPES::STT_GNU_IFUNC ||
type() == ELF_SYMBOL_TYPES::STT_OBJECT);
return is_imported;
}
However on MIPS symbols have value:
Num: Value Size Type Bind Vis Ndx Name
10: 0000000120000d70 0 FUNC GLOBAL DEFAULT UND strcpy@GLIBC_2.0 (3)
13: 0000000120000d50 0 FUNC GLOBAL DEFAULT UND printf@GLIBC_2.0 (3)
While on other platforms (like arm/x86) they do not:
Num: Value Size Type Bind Vis Ndx Name
3: 00000000 0 FUNC GLOBAL DEFAULT UND printf@GLIBC_2.4 (3)
8: 00000000 0 FUNC GLOBAL DEFAULT UND strcpy@GLIBC_2.4 (3)
Getting the value in LIEF for printf using print("PRINTF VALUE", [(s.name, s.value) for s in l.symbols if s.name == 'printf']) also shows this:
On MIPS: PRINTF VALUE [('printf', 4831841616)]
On ARM32: PRINTF VALUE [('printf', 0)]
On X86_64: PRINTF VALUE [('printf', 0)]
Not sure if not having a value is a mandatory requirement for imported functions, radare2 also has a bit different definition:
Glad to see this issue open, I just noticed the same issue for an elf on powerpc and was just starting to investigate it
Likewise, on powerpc symbols have value:
74: 10014c14 84 FUNC GLOBAL DEFAULT UND strstr
75: 10014c1c 72 FUNC GLOBAL DEFAULT UND setgid
83: 10014c24 76 FUNC GLOBAL DEFAULT UND sscanf
running print("PRINTF VALUE", [(s.name, s.value) for s in l.symbols if s.name == 'printf']) also shows this:
Describe the bug
I have the following file (same as in #795).
Which is compiled to MIPS platforms:
test-mips.zip
Except the shared lib (test-mips-64bit-le-lib), these parse correctly, but selecting imported symbols/function is failing.
To Reproduce
I have the following python code to show list imported symbols/functions:
Running it results in the following:
Expected behavior
Neither
printf
norstrcpy
are listed in imported, while they should be.For each ELF Symbol
is_imported
status is defined here:However on MIPS symbols have
value
:While on other platforms (like arm/x86) they do not:
Getting the value in LIEF for
printf
usingprint("PRINTF VALUE", [(s.name, s.value) for s in l.symbols if s.name == 'printf'])
also shows this:On MIPS:
PRINTF VALUE [('printf', 4831841616)]
On ARM32:
PRINTF VALUE [('printf', 0)]
On X86_64:
PRINTF VALUE [('printf', 0)]
Not sure if not having a value is a mandatory requirement for imported functions, radare2 also has a bit different definition:
In
_r_bin_elf_get_symbols_imports
:The text was updated successfully, but these errors were encountered: