44 uint64_t mid = left + ((right - left) / 2);
67 uint64_t mid = left + ((right - left) / 2);
91 if (addrEntry ==
NULL)
96 addrEntry->
name = symbolName;
97 addrEntry->
addr = addr;
100 addrEntry->
type = type;
113 if (outSymbol ==
NULL || addr ==
NULL)
141 if (outSymbol ==
NULL || name ==
NULL)
187 LOG_DEBUG(
"global symbol name conflict for '%s'\n", name);
196 bool groupWasCreated =
false;
197 bool nameWasCreated =
false;
201 if (symbolGroup ==
NULL)
204 if (symbolGroup ==
NULL)
210 symbolGroup->
id = groupId;
218 groupWasCreated =
true;
223 if (symbolName ==
NULL)
226 if (symbolName ==
NULL)
243 nameWasCreated =
true;
247 if (symbolAddr ==
NULL)
255 if (symbolAddr ==
NULL)
257 if (symbolName !=
NULL && nameWasCreated)
266 if (symbolName ==
NULL)
268 if (symbolGroup !=
NULL && groupWasCreated)
285 if (groupEntry ==
NULL)
297 for (
size_t readIdx = 0; readIdx <
addrAmount; readIdx++)
300 if (addrEntry->
groupId == groupId)
316 if (writeIdx != readIdx)
338 if (newArray !=
NULL)
#define LOG_DEBUG(format,...)
uint64_t symbol_resolve_name(symbol_info_t *outSymbol, const char *name)
Resolve a symbol by name.
uint64_t symbol_group_id_t
Symbol group identifier type.
uint64_t symbol_resolve_addr(symbol_info_t *outSymbol, void *addr)
Resolve a symbol by address.
uint64_t symbol_add(const char *name, void *addr, symbol_group_id_t groupId, Elf64_Symbol_Binding binding, Elf64_Symbol_Type type)
Add a symbol to the kernel symbol table.
#define SYMBOL_MAX_NAME
Maximum length of a symbol name.
void symbol_remove_group(symbol_group_id_t groupId)
Remove all symbols from the kernel symbol table in the given group.
symbol_group_id_t symbol_generate_group_id(void)
Generate a unique symbol group identifier.
#define RWLOCK_READ_SCOPE(lock)
Acquires a rwlock for reading for the reminder of the current scope.
#define RWLOCK_CREATE()
Create a rwlock initializer.
#define RWLOCK_WRITE_SCOPE(lock)
Acquires a rwlock for writing for the reminder of the current scope.
void map_entry_init(map_entry_t *entry)
Initialize a map entry.
static map_key_t map_key_uint64(uint64_t uint64)
Create a map key from a uint64_t.
uint64_t map_insert(map_t *map, const map_key_t *key, map_entry_t *value)
Insert a key-value pair into the map.
void map_remove(map_t *map, map_entry_t *entry)
Remove a entry from the map.
map_entry_t * map_get(map_t *map, const map_key_t *key)
Get a value from the map by key.
static map_key_t map_key_string(const char *str)
Create a map key from a string.
#define MAP_CREATE()
Create a map initializer.
#define ENOENT
No such file or directory.
#define EEXIST
File exists.
#define EINVAL
Invalid argument.
#define errno
Error number variable.
Elf64_Symbol_Binding
Symbol binding values stored in st_info.
Elf64_Symbol_Type
Symbol type values stored in st_info.
@ STB_GLOBAL
Global symbol, visible to all object files being combined.
@ STT_FUNC
Symbol is a code object.
@ STT_OBJECT
Symbol is a data object.
static void list_remove(list_entry_t *entry)
Removes a list entry from its current list.
static list_entry_t * list_first(list_t *list)
Gets the first entry in the list without removing it.
static void list_push_back(list_t *list, list_entry_t *entry)
Pushes an entry to the end of the list.
static bool list_is_empty(list_t *list)
Checks if a list is empty.
static void list_entry_init(list_entry_t *entry)
Initializes a list entry.
static list_entry_t * list_pop_front(list_t *list)
Pops the first entry from the list.
static void list_init(list_t *list)
Initializes a list.
#define NULL
Pointer error value.
#define ERR
Integer error value.
#define CONTAINER_OF(ptr, type, member)
Container of macro.
#define CONTAINER_OF_SAFE(ptr, type, member)
Safe container of macro.
errno_t memmove_s(void *s1, rsize_t s1max, const void *s2, rsize_t n)
#define atomic_fetch_add_explicit(object, operand, order)
#define ATOMIC_VAR_INIT(value)
_PUBLIC void * realloc(void *ptr, size_t size)
_PUBLIC void * malloc(size_t size)
_PUBLIC void free(void *ptr)
_PUBLIC char * strerror(int errnum)
errno_t strncpy_s(char *_RESTRICT s1, rsize_t s1max, const char *_RESTRICT s2, rsize_t n)
Read-Write Ticket Lock structure.
Symbol address mapping structure.
symbol_group_id_t groupId
Elf64_Symbol_Binding binding
Symbol information structure.
symbol_group_id_t groupId
Elf64_Symbol_Binding binding
char name[SYMBOL_MAX_NAME]
Symbol name mapping structure.
char name[SYMBOL_MAX_NAME]
static symbol_addr_t * symbol_insert_address(void *addr, symbol_group_id_t groupId, Elf64_Symbol_Binding binding, Elf64_Symbol_Type type, symbol_name_t *symbolName)
static symbol_addr_t ** addrArray
static uint64_t symbol_get_floor_index_for_addr(void *addr)
static size_t addrCapacity
static uint64_t symbol_resolve_addr_unlocked(symbol_info_t *outSymbol, void *addr)
static uint64_t symbol_resolve_name_unlocked(symbol_info_t *outSymbol, const char *name)