Baremetal riscv gcc compiled code and linked. I can load my program at any address. firmware calls my program using pointer to my function. I am not able to print the global variables address, its printing offsets instead of absolute address. what to do? running on qemu. If I am giving fixed address to ram in memory map. I am getting correct address but without giving memory map I am getting offset as its actual absolute address. But thats not I wanted.
this is the below code
void fun() {
__attribute__((used)) static const int lsc = 0x55; //.const
printf("%d %x %x\n",lsc,lsc,&lsc);
}
when printing the address of local_static_const, I am getting some offset 0xd0, but not absolute address.
I randomly found out that -Wl,-mno-relax giving me correct output but if I am removing then again its giving me wrong output .i.e giving offset address. I am not able to understand why.
Note: %p is not the issue, I have changed it to %x, its working in the same way listed above.