Skip to content

Commit c94b5d0

Browse files
committed
[SharedCache] Use DefineAutoUserSymbol instead of DefineAutoSymbol
This makes it so that we persist the symbols within the regular symbol list in storage
1 parent a5998f6 commit c94b5d0

File tree

2 files changed

+3
-85
lines changed

2 files changed

+3
-85
lines changed

view/sharedcache/core/DSCView.cpp

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -614,32 +614,6 @@ bool DSCView::Init()
614614
Ref<Type> filesetEntryCommandType = Type::StructureType(filesetEntryCommandStruct);
615615
DefineType(filesetEntryCommandTypeId, filesetEntryCommandName, filesetEntryCommandType);
616616

617-
if (auto metadata = SharedCacheCore::SharedCacheMetadata::LoadFromView(this))
618-
{
619-
BeginBulkModifySymbols();
620-
for (const auto& [imageBaseAddr, exportMap] : metadata->ExportInfos())
621-
{
622-
auto typelib = GetTypeLibrary(metadata->InstallNameForImageBaseAddress(imageBaseAddr));
623-
624-
for (const auto& [address, symbol] : *exportMap)
625-
{
626-
if (!IsValidOffset(address))
627-
continue;
628-
629-
if (typelib)
630-
{
631-
if (auto type = typelib->GetNamedObject(symbol->GetFullName()))
632-
{
633-
DefineAutoSymbolAndVariableOrFunction(GetDefaultPlatform(), symbol, type);
634-
continue;
635-
}
636-
}
637-
DefineAutoSymbol(symbol);
638-
}
639-
}
640-
EndBulkModifySymbols();
641-
}
642-
643617
// uint32_t at 0x10 is offset to mapping table.
644618
// first mapping struct in that table is base of primary
645619
// first uint64_t in that struct is the base address of the primary

view/sharedcache/core/SharedCache.cpp

Lines changed: 3 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -2362,14 +2362,15 @@ void SharedCache::ApplySymbol(Ref<BinaryView> view, Ref<TypeLibrary> typeLib, Re
23622362
if (typeLib)
23632363
{
23642364
auto type = m_dscView->ImportTypeLibraryObject(typeLib, {symbol->GetFullName()});
2365+
// TODO: This is still auto
23652366
if (type)
23662367
view->DefineAutoSymbolAndVariableOrFunction(view->GetDefaultPlatform(), symbol, type);
23672368
else
2368-
view->DefineAutoSymbol(symbol);
2369+
view->DefineAutoUserSymbol(symbol);
23692370
}
23702371
else
23712372
{
2372-
view->DefineAutoSymbol(symbol);
2373+
view->DefineAutoUserSymbol(symbol);
23732374
}
23742375

23752376
if (!func)
@@ -3274,59 +3275,6 @@ void Serialize(SerializationContext& context, const std::shared_ptr<std::vector<
32743275
Serialize(context, *value);
32753276
}
32763277

3277-
void Deserialize(DeserializationContext& context, std::string_view name,
3278-
std::unordered_map<uint64_t, std::shared_ptr<std::unordered_map<uint64_t, Ref<Symbol>>>>& value)
3279-
{
3280-
auto array = context.doc[name.data()].GetArray();
3281-
for (auto& pair : array)
3282-
{
3283-
auto symbols_array = pair[1].GetArray();
3284-
std::unordered_map<uint64_t, Ref<Symbol>> symbols;
3285-
for (auto& symbol_value : symbols_array)
3286-
{
3287-
auto symbol_array = symbol_value.GetArray();
3288-
std::string symbolName = symbol_array[0].GetString();
3289-
uint64_t address = symbol_array[1].GetUint64();
3290-
BNSymbolType type = (BNSymbolType)symbol_array[2].GetUint();
3291-
3292-
QualifiedName demangledName = {};
3293-
std::string shortName = symbolName;
3294-
if (DemangleLLVM(symbolName, demangledName, true))
3295-
shortName = demangledName.GetString();
3296-
Ref<Symbol> sym = new Symbol(type, shortName, shortName, symbolName, address, nullptr);
3297-
symbols.insert({address, sym});
3298-
}
3299-
value[pair[0].GetUint64()] = std::make_shared<std::unordered_map<uint64_t, Ref<Symbol>>>(std::move(symbols));
3300-
}
3301-
}
3302-
3303-
void Deserialize(DeserializationContext& context, std::string_view name,
3304-
std::unordered_map<uint64_t, std::shared_ptr<std::vector<Ref<Symbol>>>>& value)
3305-
{
3306-
auto array = context.doc[name.data()].GetArray();
3307-
for (auto& pair : array)
3308-
{
3309-
auto symbols_array = pair[1].GetArray();
3310-
std::vector<Ref<Symbol>> symbols;
3311-
symbols.reserve(symbols_array.Size());
3312-
for (auto& symbol_value : symbols_array)
3313-
{
3314-
auto symbol_array = symbol_value.GetArray();
3315-
std::string symbolName = symbol_array[0].GetString();
3316-
uint64_t address = symbol_array[1].GetUint64();
3317-
BNSymbolType type = (BNSymbolType)symbol_array[2].GetUint();
3318-
3319-
QualifiedName demangledName = {};
3320-
std::string shortName = symbolName;
3321-
if (DemangleLLVM(symbolName, demangledName, true))
3322-
shortName = demangledName.GetString();
3323-
Ref<Symbol> sym = new Symbol(type, shortName, shortName, symbolName, address, nullptr);
3324-
symbols.emplace_back(sym);
3325-
}
3326-
value[pair[0].GetUint64()] = std::make_shared<std::vector<Ref<Symbol>>>(std::move(symbols));
3327-
}
3328-
}
3329-
33303278
void Deserialize(DeserializationContext& context, std::string_view name, std::optional<DSCViewState>& viewState)
33313279
{
33323280
auto& value = context.doc[name.data()];
@@ -3399,8 +3347,6 @@ std::optional<SharedCache::CacheInfo> SharedCache::CacheInfo::Load(Deserializati
33993347
void State::Store(SerializationContext& context, std::optional<DSCViewState> viewState) const
34003348
{
34013349
MSS(memoryRegionStatus);
3402-
MSS(exportInfos);
3403-
MSS(symbolInfos);
34043350
MSS(viewState);
34053351
}
34063352

@@ -3413,8 +3359,6 @@ SharedCache::ModifiedState SharedCache::ModifiedState::Load(DeserializationConte
34133359
{
34143360
SharedCache::ModifiedState state;
34153361
state.MSL(memoryRegionStatus);
3416-
state.MSL(exportInfos);
3417-
state.MSL(symbolInfos);
34183362
state.MSL(viewState);
34193363
return state;
34203364
}

0 commit comments

Comments
 (0)