Implement support for module symbols (#475)

* **New Features**
  - Adds module symbol support and per-module symbol tables, including LVGL symbol exports moved into a dedicated table.
* **API**
  - Adds symbol-resolution APIs and an accessor to enable dynamic lookup between modules.
* **Bug Fixes / Chores**
  - Explicitly initializes module symbol pointers across device and platform modules to avoid uninitialized state.
* **Tests**
  - Updates tests to account for symbol pointer initialization.
This commit is contained in:
Ken Van Hoeylandt
2026-02-02 07:50:43 +01:00
committed by GitHub
parent 9f721e6655
commit 1f9e7f82fd
55 changed files with 563 additions and 357 deletions
+30
View File
@@ -1,4 +1,5 @@
#include <vector>
#include <string.h>
#include <algorithm>
#include <tactility/concurrent/mutex.h>
#include <tactility/module.h>
@@ -41,6 +42,21 @@ error_t module_parent_destruct(struct ModuleParent* parent) {
return ERROR_NONE;
}
bool module_parent_resolve_symbol(ModuleParent* parent, const char* symbol_name, uintptr_t* symbol_address) {
auto* data = static_cast<ModuleParentPrivate*>(parent->module_parent_private);
mutex_lock(&data->mutex);
for (auto* module : data->modules) {
if (!module_is_started(module))
continue;
if (module_resolve_symbol(module, symbol_name, symbol_address)) {
mutex_unlock(&data->mutex);
return true;
}
}
mutex_unlock(&data->mutex);
return false;
}
#pragma endregion
#pragma region module
@@ -102,6 +118,20 @@ error_t module_stop(struct Module* module) {
return error;
}
bool module_resolve_symbol(Module* module, const char* symbol_name, uintptr_t* symbol_address) {
if (!module_is_started(module)) return false;
auto* symbol_ptr = module->symbols;
if (symbol_ptr == nullptr) return false;
while (symbol_ptr->name != nullptr) {
if (strcmp(symbol_ptr->name, symbol_name) == 0) {
*symbol_address = reinterpret_cast<uintptr_t>(symbol_ptr->symbol);
return true;
}
symbol_ptr++;
}
return false;
}
#pragma endregion
}