Repository navigation
Conversation
|
THIS MESSAGE WAS GENERATED BY AN AUTOMATED PROCESS Head The public reproducer is The corpus comparison used 402 COFF objects. The objects were sampled 25 per
The sample cannot be shared. Corpus objects are identified by architecture, These figures were measured at
|
|
Corpus decompilation diffs can be found at angr/dec-snapshots@master...angr/cle_761 |
461bb73 to
22f6feb
Compare
A COFF object names what it needs from elsewhere by giving the symbol section number zero. The loader already allocates each of those an extern address and relocates against it, but the symbols never say they are imports, so Relocation.__init__ does not record them and self.imports stays empty. angr's Project._register_object iterates obj.imports and nothing else, so a COFF object gets nothing hooked: a call to an undefined external lands in the extern object's zero fill and is decoded as instructions, and under symbolic execution it executes that zero fill instead of a stub. Say so on the symbol; the generic relocation machinery does the rest, __imp_* entries included, which are data and so are listed without being hooked. A COFF symbol's Type field also says 0x20 for a function and 0 for nothing at all, which is what every GCC-family toolchain emits, and reading 0 as data meant those imports were listed and then skipped rather than hooked. TYPE_NONE is how CLE spells "the file did not say", and it is already what a relocatable ELF's STT_NOTYPE symbols become. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
22f6feb to
7acefe5
Compare
|
THIS MESSAGE WAS GENERATED BY AN AUTOMATED PROCESS The following reproducer prints the x86-64 COFF fixture's imports. It also Reproducerimport logging, os
logging.getLogger("cle").setLevel(logging.CRITICAL)
import cle
BIN = os.environ["BINARIES"] # a checkout of angr/binaries
T = lambda *p: os.path.join(BIN, "tests", *p)
path = T("x86_64", "fauxware.obj")
ld = cle.Loader(path, auto_load_libs=False)
obj = ld.main_object
print(f"obj.imports: {len(obj.imports)} entries")
for name in sorted(obj.imports):
reloc = obj.imports[name]
sym = reloc.resolvedby
where = ld.find_object_containing(sym.rebased_addr) if sym is not None else None
kind = reloc.symbol.type.name if reloc.symbol is not None else "?"
print(f" {name:<52} {kind:<14} -> {sym.rebased_addr:#x} in {type(where).__name__}"
if sym is not None else f" {name:<52} {kind:<14} unresolved")Before this change, the object's undefined externals do not appear in cle master at
|
|
THIS MESSAGE WAS GENERATED BY AN AUTOMATED PROCESS This change replaces a Sample. A seeded permutation selected 12,000 objects uniformly from an Method. The comparison loaded all 468 objects with the catalogue's declared Imports. On Analysis. Across 23 objects, recovered functions increase from 15,457 to Other COFF changes. Pull requests #724, #764, and #775 also change The sample cannot be shared. Its objects are described by architecture, format, session: sharpen |
THIS MESSAGE WAS GENERATED BY AN AUTOMATED PROCESS
Problem
COFF undefined externals do not appear in
self.imports. Thebinaries/tests/x86_64/fauxware.objfixture reports:Project._register_objectuses onlyself.importsto choose symbols tohook. Calls to
strcmporexittherefore go to zero-filled addresses inthe extern object. angr then decodes those addresses as instructions. All ten
undefined externals in this object are reachable from its code.
Root cause
A COFF symbol with section number zero is an undefined external. cle allocates
an extern address for each of these symbols and relocates against it. However,
the symbol is not marked as an import, so
self.importsstays empty.A COFF symbol type of
0x20means function. A type of0means that no typeinformation is available. GCC-family toolchains emit
0, but cle treats it asdata. cle lists a data import but does not hook it.
Fix
Mark each undefined external symbol as an import. The generic relocation
machinery then handles it. Map an untyped COFF symbol to
TYPE_NONE, as cledoes for a relocatable ELF
STT_NOTYPEsymbol, instead of mapping it to data.Fixes #746. Evidence: #761 (comment)
session: sharpen