Can use Multiboot1 for x86_64 kernel?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
NeonLightions
Member
Member
Posts: 102
Joined: Wed Oct 20, 2021 6:00 pm
Location: Paraguay

Re: Can use Multiboot1 for x86_64 kernel?

Post 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.
nullplan
Member
Member
Posts: 1790
Joined: Wed Aug 30, 2017 8:24 am

Re: Can use Multiboot1 for x86_64 kernel?

Post 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.
Carpe diem!
Post Reply