Hi,
For context I'm playing with mini-os and xen and I try to implement something in Zig just to learn and fun.
I have a small piece of asm where I defined a symbol hypercall_page:
asm volatile (
\\.globl hypercall_page
\\ .align 4096
\\hypercall_page:
\\ .fill 4096,1,0
This code is in my kmain.zig file and it builds correctly and I can see the symbol hypercall_page at 0x13000 in the ELF file. So far so good.
The issue is that I want to use this variable at comptime in my kmain.zig to generate an ELF note using the address of this hypercall_page. So I added
extern const hypercall_page: usize;
But when I try to pass this constant to my function that generates ELF note at comptime I have the following error:
src/kmain.zig:36:41: error: unable to resolve comptime value
elfNote.genXenLong(.hypercall_page, hypercall_page);
^~~~~~~~~~~~~~
src/kmain.zig:36:41: note: parameter is comptime
I tried to add comptime instead of const before the hypercall_page but it is not the solution.
Any hint to solve this problem?
PS: the code for more information is here (it is really for fun and I have no other goal that trying stuff... and failing 🙂 ) : https://github.com/gthvn1/mini-zos/blob/1-add-elfnote/src/kmain.zig