Raw binary generation

So I’m trying to follow the “Writing a Bootlader” series. In part 3 the bootloader, after setup in assembly, calls a C++ function. Naturally, I wanted to replace the C++ part with Zig.

After some fiddling I got it to work. However, it currently generates an ELF binary which I then convert to raw via objcopy -Obinary.

Some more infos:

  • The tutorial uses OUTPUT_FORMAT("binary") in the linker script. Tried, didn’t work. ldd says unknown format. I assume I could switch out the linker too as an option?
  • There is an -ofmt=[fmt] option for zig build-exe but raw isn’t yet implemented
  • Also: I barely understand what I’m doing in general, so excuse me if any (all) of this makes little sense

Is there some way to output raw format directly with the Zig compiler? If you have any other improvements/suggestions “how to do this right” I’m happy to hear as well.