fix: various kernel bug fixes
This commit is contained in:
@@ -18,7 +18,7 @@ namespace Montauk {
|
||||
|
||||
// Maximum libraries per process
|
||||
static constexpr int MaxLibsPerProcess = 8;
|
||||
static constexpr int MaxProcesses = 64;
|
||||
static constexpr int MaxProcesses = Sched::MaxProcesses;
|
||||
|
||||
// Library entry tracking
|
||||
struct LibEntry {
|
||||
@@ -28,15 +28,15 @@ namespace Montauk {
|
||||
bool inUse;
|
||||
};
|
||||
|
||||
static uint64_t GetLibSlotBase(int libSlot) {
|
||||
inline uint64_t GetLibSlotBase(int libSlot) {
|
||||
return Sched::LIB_BASE + (uint64_t(libSlot) * Sched::LIB_MAX_SIZE);
|
||||
}
|
||||
|
||||
// Per-process library table
|
||||
static LibEntry g_libTable[MaxProcesses][MaxLibsPerProcess];
|
||||
inline LibEntry g_libTable[MaxProcesses][MaxLibsPerProcess] = {};
|
||||
|
||||
// Initialize library table for a process slot
|
||||
static void InitLibTable(int slot) {
|
||||
inline void InitLibTable(int slot) {
|
||||
if (slot < 0 || slot >= MaxProcesses) return;
|
||||
for (int i = 0; i < MaxLibsPerProcess; i++) {
|
||||
g_libTable[slot][i].inUse = false;
|
||||
@@ -49,7 +49,7 @@ namespace Montauk {
|
||||
// Load a shared library into the current process's address space.
|
||||
// Returns a library handle (slot index + 1) on success, or 0 on failure.
|
||||
// The library is loaded at a fixed address based on the slot.
|
||||
static uint64_t Sys_LoadLib(const char* path) {
|
||||
inline uint64_t Sys_LoadLib(const char* path) {
|
||||
int slot = GetCurrentSlot();
|
||||
if (slot < 0) return 0;
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace Montauk {
|
||||
|
||||
// Unload a shared library.
|
||||
// Decrements refcount; actually unmaps when refcount reaches 0.
|
||||
static int Sys_UnloadLib(uint64_t handle) {
|
||||
inline int Sys_UnloadLib(uint64_t handle) {
|
||||
int slot = GetCurrentSlot();
|
||||
if (slot < 0) return -1;
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace Montauk {
|
||||
// handle = library handle from LoadLib
|
||||
// symbolOffset = ELF symbol value from the library's symbol table
|
||||
// Returns the virtual address of the symbol, or 0 if not found.
|
||||
static uint64_t Sys_DLSym(uint64_t handle, uint64_t symbolOffset) {
|
||||
inline uint64_t Sys_DLSym(uint64_t handle, uint64_t symbolOffset) {
|
||||
int slot = GetCurrentSlot();
|
||||
if (slot < 0) return 0;
|
||||
|
||||
@@ -153,7 +153,7 @@ namespace Montauk {
|
||||
}
|
||||
|
||||
// Get library relocation base / load bias (for userspace symbol resolution)
|
||||
static uint64_t Sys_GetLibBase(uint64_t handle) {
|
||||
inline uint64_t Sys_GetLibBase(uint64_t handle) {
|
||||
int slot = GetCurrentSlot();
|
||||
if (slot < 0) return 0;
|
||||
|
||||
@@ -166,7 +166,7 @@ namespace Montauk {
|
||||
}
|
||||
|
||||
// Cleanup library table for a process slot
|
||||
static void CleanupLibTable(int slot) {
|
||||
inline void CleanupLibTable(int slot) {
|
||||
if (slot < 0 || slot >= MaxProcesses) return;
|
||||
|
||||
auto* proc = Sched::GetProcessSlot(slot);
|
||||
|
||||
Reference in New Issue
Block a user