summaryrefslogtreecommitdiffstats
path: root/src/module.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/module.c')
-rw-r--r--src/module.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/module.c b/src/module.c
index 13f0a8d..d549704 100644
--- a/src/module.c
+++ b/src/module.c
@@ -5,14 +5,13 @@
extern unsigned char _BitScanForward64(unsigned long *_Index, uint64_t _Mask);
struct module modules[64U] = { 0U };
-// u64 modules_list = ~0ULL; // TODO: Check if modules_list is supposed to be filled with one's ?
-u64 modules_list = 0ULL; // TODO: Filled modules_list with zeroes since we assert during the first call to add_module, see comment above
+u64 modules_list = ~0ULL;
// u64 module_symbols
u8 add_module(void) {
// struct module* add_module() {
- assert(!modules_list);
+ assert(modules_list);
u32 module_index = 0U;
_BitScanForward64((unsigned long*)&module_index, modules_list);
modules_list ^= (u64)(0x1 << module_index);
@@ -45,12 +44,12 @@ u32 find_function(struct module* module, u64 rip_offset) {
}
u32 min = 0U, max = module->functions_count - 1U;
- while(min != max) {
+ while((max - min) > 1U) {
u32 mid = (min + max) / 2U;
- if (module->functions_start[mid] < rip_offset) {
- min = mid + 1U;
+ if (rip_offset < module->functions_start[mid]) {
+ max = mid;
} else {
- max = mid - 1U;
+ min = mid;
}
}