Page 2 of 2

Re: Can use Multiboot1 for x86_64 kernel?

Posted: Mon Dec 20, 2021 1:35 am
by NeonLightions
kotovalexarian wrote:Here is some stack tracing example: https://github.com/josehu07/hux-kernel/ ... -&-Testing
Thank you, I will reference and make it as 64-bit form.

Re: Can use Multiboot1 for x86_64 kernel?

Posted: Mon Dec 20, 2021 3:04 am
by nullplan
kotovalexarian wrote:Here is some stack tracing example: https://github.com/josehu07/hux-kernel/ ... -&-Testing
Well, that code is horrible. You can clean it up a whole lot by just using a self-referential data structure:

Code: Select all

struct stackframe {
  struct stackframe *next;
  uint32_t ip;
};
This doesn't fix the problem that it just assumes the stackframe to be a certain way, that the compiler doesn't necessarily need to follow. But the alternative would be to build a parser for the DWARF structures in the exception frame (and instruct the compiler to insert instructions in there), but for that, you should probably use a library like libunwind. On the plus side, with libunwind, you can deal with whatever the compiler emits.

Linux doesn't bother with DWARF, by the way. They have a tool that turns the DWARF data into a simpler format of their invention, called ORC. And then they use that. So that is also a possibility.