MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / DefineElfSymbol

Method DefineElfSymbol

view/elf/elfview.cpp:2454–2566  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2452
2453
2454void ElfView::DefineElfSymbol(BNSymbolType type, const string& incomingName, uint64_t addr, bool gotEntry,
2455 BNSymbolBinding binding, size_t size, Ref<Type> typeObj)
2456{
2457 // Ensure symbol is within the executable
2458 if (type != ExternalSymbol && !IsValidOffset(addr))
2459 return;
2460
2461 string name = incomingName;
2462 Ref<Type> symbolTypeRef;
2463 if ((type == ExternalSymbol) || (type == ImportAddressSymbol) || (type == ImportedDataSymbol))
2464 {
2465 QualifiedName n(name);
2466 Ref<TypeLibrary> lib = nullptr;
2467 symbolTypeRef = ImportTypeLibraryObject(lib, n);
2468 if (symbolTypeRef)
2469 {
2470 m_logger->LogDebug("elf: type Library '%s' found hit for '%s'", lib->GetName().c_str(), name.c_str());
2471 if (type != ExternalSymbol || addr != 0)
2472 {
2473 RecordImportedObjectLibrary(GetDefaultPlatform(), addr, lib, n);
2474 }
2475 }
2476 }
2477
2478 auto pos = name.rfind("@@");
2479 if (type == ExternalSymbol && pos != string::npos)
2480 {
2481 name = name.substr(0, pos);
2482 }
2483
2484 pos = name.rfind("@GLIBC");
2485 if (type == ExternalSymbol && pos != string::npos)
2486 {
2487 name = name.substr(0, pos);
2488 }
2489
2490 pos = name.rfind("@CXXABI");
2491 if (type == ExternalSymbol && pos != string::npos)
2492 {
2493 name = name.substr(0, pos);
2494 }
2495
2496
2497 // Deprioritize local label symbol names
2498 if (type == DataSymbol && binding == LocalBinding && !name.empty() && name[0] == '.')
2499 {
2500 type = LocalLabelSymbol;
2501 }
2502
2503 // If name is empty, symbol is not valid
2504 if (name.size() == 0)
2505 return;
2506
2507 if (!symbolTypeRef)
2508 symbolTypeRef = typeObj;
2509
2510 if (gotEntry)
2511 m_gotEntryLocations.emplace(addr);

Callers

nothing calls this directly

Calls 12

DemangleGenericFunction · 0.85
IntegerTypeClass · 0.85
LogDebugMethod · 0.80
c_strMethod · 0.80
Get<bool>Method · 0.80
GetStringAfterNameMethod · 0.80
GetFunctionByNameMethod · 0.80
GetNameMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45
GetStringMethod · 0.45
AppendMethod · 0.45

Tested by

no test coverage detected