Hi there,
First of all thanks to Maxime Villard and the team for the different approach on KASLR implementation, "prekern".
Out of curiosity, I am learning about the internals of the prekern by reading the source code and also trying to attach the debugger as well to read the code with the flow.
I have tried some setups but none of them is working to put a break point on the functions mentioned in prekern.c file, like init_prekern(), etc.
My setup includes
Debugger machine : NetBSD-9.RC1 amd64
Debuggee machine : NetBSD-9.RC1 amd64
I have compiled the code on debugger machine and copied the netbsd_kaslr and prekern binary (prekern from /usr/mdec/prekern) to the taget debuggee machine.
Then, invoked the target debuggee machine using qemu-system-x86_64 with -S and -s options and attached the gdb from debugger machine to debuggee machine using :1234 port.
I am able to see the code files and able to put the breakpoints on other functions/syscalls but not able to put breakpoint on init_prekern(). It seems that the init_prekern() is not in the debug symbols, not sure why?.
Now, I am thinking to put some printfs in the code, but could someone please let me know about the debugging through qemu for prekern.
Regards and Thanks,
Neeraj