Merge pull request #54 from georgemoralis/skmp/stub-log-unknown-nids
Stubs: Log nids for unknown ones
This commit is contained in:
commit
22cbfd860d
|
@ -623,11 +623,11 @@ void Linker::Resolve(const std::string& name, int Symtype, Module* m, SymbolReco
|
||||||
if (aeronid) {
|
if (aeronid) {
|
||||||
return_info->name = aeronid->name;
|
return_info->name = aeronid->name;
|
||||||
return_info->virtual_address = GetStub(aeronid->nid);
|
return_info->virtual_address = GetStub(aeronid->nid);
|
||||||
LOG_ERROR_IF(debug_loader, "Linker: Stub resolved {} as {} (lib: {}, mod: {}) \n", sr.name, return_info->name, library->name, module->name);
|
|
||||||
} else {
|
} else {
|
||||||
return_info->virtual_address = (u64)&UnresolvedStub;
|
return_info->virtual_address = GetStub(sr.name.c_str());
|
||||||
return_info->name = "Unresolved!!!";
|
return_info->name = "Unknown !!!";
|
||||||
}
|
}
|
||||||
|
LOG_ERROR_IF(debug_loader, "Linker: Stub resolved {} as {} (lib: {}, mod: {}) \n", sr.name, return_info->name, library->name, module->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -19,23 +19,27 @@
|
||||||
#define MAX_STUBS 128
|
#define MAX_STUBS 128
|
||||||
|
|
||||||
u64 UnresolvedStub() {
|
u64 UnresolvedStub() {
|
||||||
LOG_ERROR("Unknown Stub: called, returning zero\n");
|
LOG_ERROR("Unresolved Stub: called, returning zero\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static u64 UnknownStub() {
|
static u64 UnknownStub() {
|
||||||
LOG_ERROR("Unknown Stub: called, returning zero\n");
|
LOG_ERROR("Stub: Unknown (nid: Unknown) called, returning zero\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static aerolib::nid_entry* stub_nids[MAX_STUBS];
|
static aerolib::nid_entry* stub_nids[MAX_STUBS];
|
||||||
|
static std::string stub_nids_unknown[MAX_STUBS];
|
||||||
|
|
||||||
template <int stub_index>
|
template <int stub_index>
|
||||||
static u64 CommonStub() {
|
static u64 CommonStub() {
|
||||||
auto entry = stub_nids[stub_index];
|
auto entry = stub_nids[stub_index];
|
||||||
|
if (entry) {
|
||||||
LOG_ERROR("Stub: {} ({}) called, returning zero\n", entry->name, entry->nid);
|
LOG_ERROR("Stub: {} (nid: {}) called, returning zero\n", entry->name, entry->nid);
|
||||||
|
} else {
|
||||||
|
LOG_ERROR("Stub: Unknown (nid: {}) called, returning zero\n", stub_nids_unknown[stub_index]);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,11 +65,16 @@ static u64 (*stub_handlers[MAX_STUBS])() = {
|
||||||
};
|
};
|
||||||
|
|
||||||
u64 GetStub(const char* nid) {
|
u64 GetStub(const char* nid) {
|
||||||
auto entry = aerolib::find_by_nid(nid);
|
if (UsedStubEntries >= MAX_STUBS) {
|
||||||
if (!entry || UsedStubEntries >= MAX_STUBS) {
|
|
||||||
return (u64)&UnknownStub;
|
return (u64)&UnknownStub;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto entry = aerolib::find_by_nid(nid);
|
||||||
|
if (!entry) {
|
||||||
|
stub_nids_unknown[UsedStubEntries] = nid;
|
||||||
} else {
|
} else {
|
||||||
stub_nids[UsedStubEntries] = entry;
|
stub_nids[UsedStubEntries] = entry;
|
||||||
|
}
|
||||||
|
|
||||||
return (u64)stub_handlers[UsedStubEntries++];
|
return (u64)stub_handlers[UsedStubEntries++];
|
||||||
}
|
}
|
||||||
}
|
|
Loading…
Reference in New Issue