Merge commit '190562e8c65c9872c5c22391400931da8e4b5dae' into develop

This commit is contained in:
systems-assistant[bot]
2025-07-30 15:21:36 +00:00
66 changed files with 7379 additions and 492 deletions
@@ -488,6 +488,77 @@ find_function(image_t* app_image, const std::string& _name, const strset_t& _ext
return _func;
}
//======================================================================================//
//
// Find undefined function symbols (external references) in the binary
//
symtab_symbol_t*
find_undefined_function_symbol(image_t* app_image, const std::string& _name)
{
if(_name.empty()) return nullptr;
// Get all objects from the image
BPatch_Vector<BPatch_object*> app_objects;
app_image->getObjects(app_objects);
if(app_objects.empty())
{
verbprintf(3, "No objects found in image for symbol search\n");
return nullptr;
}
// Search helper lambda for code reuse
auto _find_symbol = [](SymTab::Symtab* symtab,
const std::string& target_name) -> symtab_symbol_t* {
if(!symtab) return nullptr;
std::vector<SymTab::Symbol*> all_symbols;
if(!symtab->getAllSymbols(all_symbols)) return nullptr;
for(auto* symbol : all_symbols)
{
if(!symbol || symbol->getType() != SymTab::Symbol::ST_FUNCTION ||
symbol->getRegion())
continue;
// Try all possible symbol name representations
std::string symbol_name = symbol->getPrettyName();
if(symbol_name.empty()) symbol_name = symbol->getMangledName();
if(symbol_name.empty()) symbol_name = symbol->getTypedName();
// Check for exact match and undefined function criteria
if(symbol_name == target_name) return symbol;
}
return nullptr;
};
// Search through each object
for(auto* app_object : app_objects)
{
if(!app_object) continue;
std::string binary_path = app_object->name();
// Open Symtab directly for comprehensive symbol access
SymTab::Symtab* symtab = nullptr;
if(!SymTab::Symtab::openFile(symtab, binary_path))
{
verbprintf(3, "Failed to open Symtab for: %s\n", binary_path.c_str());
continue;
}
// Search for the primary symbol name
auto* result = _find_symbol(symtab, _name);
if(result)
{
verbprintf(1, "Found undefined function symbol: '%s' in %s\n", _name.c_str(),
binary_path.c_str());
return result;
}
}
verbprintf(1, "Undefined function symbol: '%s' ... not found\n", _name.c_str());
return nullptr;
}
//======================================================================================//
//
// Get the realpath to this exe