[FL-2627] Flipper applications: SDK, build and debug system (#1387)
* Added support for running applications from SD card (FAPs - Flipper Application Packages) * Added plugin_dist target for fbt to build FAPs * All apps of type FlipperAppType.EXTERNAL and FlipperAppType.PLUGIN are built as FAPs by default * Updated VSCode configuration for new fbt features - re-deploy stock configuration to use them * Added debugging support for FAPs with fbt debug & VSCode * Added public firmware API with automated versioning Co-authored-by: hedger <hedger@users.noreply.github.com> Co-authored-by: SG <who.just.the.doctor@gmail.com> Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
48
applications/main/fap_loader/elf_cpp/elf_hashtable.cpp
Normal file
48
applications/main/fap_loader/elf_cpp/elf_hashtable.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
#include "compilesort.hpp"
|
||||
#include "elf_hashtable.h"
|
||||
#include "elf_hashtable_entry.h"
|
||||
#include "elf_hashtable_checks.hpp"
|
||||
|
||||
#include <array>
|
||||
#include <algorithm>
|
||||
|
||||
/* Generated table */
|
||||
#include <symbols.h>
|
||||
|
||||
#define TAG "elf_hashtable"
|
||||
|
||||
static_assert(!has_hash_collisions(elf_api_table), "Detected API method hash collision!");
|
||||
|
||||
/**
|
||||
* Get function address by function name
|
||||
* @param name function name
|
||||
* @param address output for function address
|
||||
* @return true if the table contains a function
|
||||
*/
|
||||
|
||||
bool elf_resolve_from_hashtable(const char* name, Elf32_Addr* address) {
|
||||
bool result = false;
|
||||
uint32_t gnu_sym_hash = elf_gnu_hash(name);
|
||||
|
||||
sym_entry key = {
|
||||
.hash = gnu_sym_hash,
|
||||
.address = 0,
|
||||
};
|
||||
|
||||
auto find_res = std::lower_bound(elf_api_table.cbegin(), elf_api_table.cend(), key);
|
||||
if((find_res == elf_api_table.cend() || (find_res->hash != gnu_sym_hash))) {
|
||||
FURI_LOG_W(TAG, "Cant find symbol '%s' (hash %x)!", name, gnu_sym_hash);
|
||||
result = false;
|
||||
} else {
|
||||
result = true;
|
||||
*address = find_res->address;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
const ElfApiInterface hashtable_api_interface = {
|
||||
.api_version_major = (elf_api_version >> 16),
|
||||
.api_version_minor = (elf_api_version & 0xFFFF),
|
||||
.resolver_callback = &elf_resolve_from_hashtable,
|
||||
};
|
Reference in New Issue
Block a user