44 uint64_t mid = left + ((right - left) / 2);
67 uint64_t mid = left + ((right - left) / 2);
91 if (addrEntry ==
NULL)
96 addrEntry->
addr = addr;
99 addrEntry->
type = type;
112 if (outSymbol ==
NULL || addr ==
NULL)
140 if (outSymbol ==
NULL || name ==
NULL)
186 LOG_DEBUG(
"global symbol name conflict for '%s'\n", name);
195 bool groupWasCreated =
false;
196 bool nameWasCreated =
false;
200 if (symbolGroup ==
NULL)
203 if (symbolGroup ==
NULL)
209 symbolGroup->
id = groupId;
217 groupWasCreated =
true;
222 if (symbolName ==
NULL)
225 if (symbolName ==
NULL)
242 nameWasCreated =
true;
246 if (symbolAddr ==
NULL)
254 if (symbolAddr ==
NULL)
256 if (symbolName !=
NULL && nameWasCreated)
265 if (symbolName ==
NULL)
267 if (symbolGroup !=
NULL && groupWasCreated)
284 if (groupEntry ==
NULL)
292 if (
addrArray[readIdx]->groupId != groupId)
294 if (writeIdx != readIdx)
330 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_CREATE
Create a rwlock initializer.
#define RWLOCK_READ_SCOPE(lock)
Acquires a rwlock for reading for the reminder of the current scope.
#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.
#define MAP_CREATE
Create a map initializer.
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 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 list_entry_t * list_first(list_t *list)
Gets the first entry in the list without removing it.
static list_entry_t * list_pop_first(list_t *list)
Pops the first entry from the list.
static void list_push_back(list_t *list, list_entry_t *entry)
Pushes an entry to the end of the list.
static void list_remove(list_t *list, list_entry_t *entry)
Removes a list entry from its current 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 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)
list_t * list
The list this entry belongs to.
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 uint64_t addrCapacity
static uint64_t addrAmount
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)