2023-03-14 14:29:28 +00:00
|
|
|
#include "api_hashtable.h"
|
|
|
|
|
|
|
|
#include <furi.h>
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
#define TAG "hashtable_api"
|
|
|
|
|
|
|
|
bool elf_resolve_from_hashtable(
|
|
|
|
const ElfApiInterface* interface,
|
2023-06-28 08:19:10 +00:00
|
|
|
uint32_t hash,
|
2023-03-14 14:29:28 +00:00
|
|
|
Elf32_Addr* address) {
|
2023-06-28 08:19:10 +00:00
|
|
|
bool result = false;
|
2023-03-14 14:29:28 +00:00
|
|
|
const HashtableApiInterface* hashtable_interface =
|
|
|
|
static_cast<const HashtableApiInterface*>(interface);
|
|
|
|
|
|
|
|
sym_entry key = {
|
2023-06-28 08:19:10 +00:00
|
|
|
.hash = hash,
|
2023-03-14 14:29:28 +00:00
|
|
|
.address = 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
auto find_res =
|
|
|
|
std::lower_bound(hashtable_interface->table_cbegin, hashtable_interface->table_cend, key);
|
2023-06-28 08:19:10 +00:00
|
|
|
if((find_res == hashtable_interface->table_cend || (find_res->hash != hash))) {
|
2023-03-14 14:29:28 +00:00
|
|
|
FURI_LOG_W(
|
2023-06-28 08:19:10 +00:00
|
|
|
TAG, "Can't find symbol with hash %lx @ %p!", hash, hashtable_interface->table_cbegin);
|
2023-03-14 14:29:28 +00:00
|
|
|
result = false;
|
|
|
|
} else {
|
|
|
|
result = true;
|
|
|
|
*address = find_res->address;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
2023-06-28 08:19:10 +00:00
|
|
|
|
|
|
|
uint32_t elf_symbolname_hash(const char* s) {
|
|
|
|
return elf_gnu_hash(s);
|
|
|
|
}
|