You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wrote a macro for my own project here feel free to use it. There are examples in the tests module and documentation in lib.rs. It does have a couple of quirks and issues, some that can be fixed easily and one which is a huge pain to deal with.
This resolves types names by trimming the last ident from the path to the constructor so constructing a tag using TagName{fields} will not work, you must use TagName::new(args)
Tags should have #[repr(align(8))], currently some tags need to be padded manually, which is a bit of a pain because of how the macro resolves type names.
Multiboot2BasicHeader doesn't have a public constructor, probably because of the size argument so the macro must define it's own.
Pointers cannot be cast to integers at compile time. rustc managed to foil all of my attempts to get a truncated pointer. There are ways to work around this, firstly store pointers using *const () on 32bit targets. 64bit targets are kinda SOL for this method, the way I'm working around this is just specifying addresses in in a linker script and giving the same address to tag constructors. I did notice that you can get a truncated pointer using inline asm but I'm pretty sure that exploiting this requires writing the entire header in an asm block.
I did also consider adding a "native" argument for the architecture to get the macro to resolve the arch itself, but with the huge selection of i386 or MIPS I think the user can handle this themselves.
It would be awesome to construct multiboot2-headers at runtime with macros.
For reference: That's how you write a header in assembly language: https://github.com/rust-osdev/multiboot2/blob/main/integration-test/bins/multiboot2_payload/src/multiboot2_header.S
The text was updated successfully, but these errors were encountered: