In relation to #304 (getting LLDB working under Darling), we need to move Mach-O loading to the kernel.
This has several benefits:
mldr will no longer be involved.And disadvantages:
/dev/mach from userspace. Open devmach fd inside the kernel Mach-O loader (and make it O_CLOEXEC)./dev/mach opening from libsystem_kernel. Maybe we could get the fd number via apple[] args to entry point?argv[] and this function would longjmp() back in order to rewind the stack.struct file*).ioctl() and do int 0x83 to make LKM calls.TODO: is some register saving needed?
call lkmcall
swapgs
iretq
void isr_install(void)
{
struct desc_ptr newidtr;
gate_desc *oldidt, *newidt;
unsigned long idtpage;
void* isr = NULL; // TODO: fill in func ptr here
struct desc_ptr idtreg;
store_idt(&idtreg);
oldidt = (gate_desc *)idtreg.address;
idtpage =__get_free_page(GFP_KERNEL);
if(!idtpage)
return;
newidtr.address = idtpage;
newidtr.size = idtreg.size;
newidt = (gate_desc *)newidtr.address;
memcpy(newidt, oldidt, idtreg.size);
pack_gate(&newidt[0x83], GATE_INTERRUPT, (unsigned long)isr, 0x3, 0, __KERNEL_CS);
load_idt((void *)&newidtr);
smp_call_function((smp_call_func_t) load_idt, &newidtr, 1);
}
LLDB observations:
TaskPortForProcessID:
PosixSpawnChildForPTraceDebugging:
:tada:
Most helpful comment
:tada: