feat: use PIC code model for shared libraries, fix shared library bugs
This commit is contained in:
+14
-6
@@ -71,6 +71,13 @@ namespace Hal {
|
||||
return frame->CS;
|
||||
}
|
||||
|
||||
static System::PanicFrame* GetExceptionRegs(uint8_t vector, System::PanicFrame* frame) {
|
||||
if (ExceptionHasErrorCode(vector)) {
|
||||
return (System::PanicFrame*)((uint8_t*)frame + sizeof(uint64_t));
|
||||
}
|
||||
return frame;
|
||||
}
|
||||
|
||||
template<size_t i>
|
||||
__attribute__((interrupt)) void ExceptionHandler(System::PanicFrame* frame)
|
||||
{
|
||||
@@ -85,6 +92,7 @@ namespace Hal {
|
||||
// instead of panicking the entire system.
|
||||
if (fromUser && Sched::GetCurrentPid() >= 0) {
|
||||
auto* proc = Sched::GetCurrentProcessPtr();
|
||||
auto* regs = GetExceptionRegs(i, frame);
|
||||
Kt::KernelLogStream(Kt::ERROR, "Exception")
|
||||
<< ExceptionStrings[i] << " in process \""
|
||||
<< proc->name << "\" (pid " << proc->pid
|
||||
@@ -99,11 +107,11 @@ namespace Hal {
|
||||
rep.exceptionVector = i;
|
||||
for (int j = 0; j < 32 && ExceptionStrings[i][j]; j++) rep.exceptionName[j] = ExceptionStrings[i][j];
|
||||
rep.exceptionName[31] = '\0';
|
||||
rep.instructionPointer = frame->IP;
|
||||
rep.codeSegment = frame->CS;
|
||||
rep.flags = frame->Flags;
|
||||
rep.stackPointer = frame->SP;
|
||||
rep.stackSegment = frame->SS;
|
||||
rep.instructionPointer = regs->IP;
|
||||
rep.codeSegment = regs->CS;
|
||||
rep.flags = regs->Flags;
|
||||
rep.stackPointer = regs->SP;
|
||||
rep.stackSegment = regs->SS;
|
||||
|
||||
if (i == 0x0E) {
|
||||
// Page fault: read CR2 for faulting address
|
||||
@@ -215,4 +223,4 @@ namespace Hal {
|
||||
void IDTReload() {
|
||||
LoadIDT(IDTR);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user