-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I suggest a successful compilation for the version 0.11.0-dev #14
base: master
Are you sure you want to change the base?
Conversation
Even if it's not merged, big thanks for doing that @isoux! Interestingly, on my MacBook AIR M1 w/ macOS 13.4, ➜ HellOS git:(0.11.0-dev) zig build-exe hellos.zig -target x86-freestanding -T linker.ld
➜ HellOS git:(0.11.0-dev) ✗ qemu-system-i386 -kernel hellos
qemu-system-i386: Error loading uncompressed kernel without PVH ELF Note |
I tried this, it's not working on my OS as well. I'm on I modify the code a bit because error message I got is the same:
|
Tried this with 0.11.0 with the ptrFromInt change. Compilation fails as below. Any ideas?
edit/update: I modified it to get rid of the .Naked modifier. I assume this will mess with the intended stack setup, but without digging deep into this, my hope was that it would just add some harmless setup and teardown cruft. Anyhow, I was able to build after that change. But then I get the same "qemu-system-i386: Error loading uncompressed kernel without PVH ELF Note" issue. I try running this: $ grub-file --is-x86-multiboot hellos This returns error 1. From what I've read, this tends to be explained by the multiboot header magic number not showing up in the first 8K of the binary. So I check using xxd, and "02b0 ad1b" (little-endian) shows up exactly at the first byte after 8K. So it seems like the linker script is putting .multiboot in the data section rather than the text section (edit: this was a mistaken conclusion - see update 3 below). Unfortunately, I'm not sure how to fix this. edit/update 2: Hacking away... I tried making a number of changes to the linker script. By reducing each section to ALIGN(1K), I got it so that it passed the grub-file test, with the multiboot header showing up within the first 8K. The kernel boots and displays the Hello Kernel World message. Obviously it's not ideal to have these two hacks (removing .Naked and reducing section alignment) but I was happy to get it working at all. edit/update 3: TL;DR: Change the linker script's .rodata section to have a trailing * after the rodata input specifier.
Longer story: running "objdump -h hellos" shows that that there are 2 rodata sections, named "rodata.cst8" and "rodata.str1.1". These do not match the linker script specification for rodata inputs, so the linker throws these into the output, disregarding our desired ordering. To fix, change the input specifier so that it matches these sections. |
I have created a new branch for the above mentioned version with necessary small changes, because I think it is useful for everyone to be able to successfully try this code for the latest version of ZIG.