[Solved] Unable to access data; probably linking issue
Posted: Tue May 03, 2022 5:39 pm
I'm at a very beginning of writing OS. I'm in protected mode attempting to write the simple physical memory manager and later enable paging. I've noticed that when I define some global variables my printing stops to work. I can't wrap my head around it why.
This is my repo: mios. Everything is working ok if this variable is not defined. I used the "cli;hlt" to stop in the function, I set the breakpoint in gdb and send nmi from qemu monitor to continue. The issue is:
String 0xfedf is empty. If I manually modify 0xfedf via gdb to some string I do get the expected results.
I also tried to define big array after this variable (and instead of it) just to see what it does. Did even char bigbuf[10240] = "AAA .... A" and test it with it. Print was not working but gdb dump shows that I didn't have array full of 10240 "A" in memory, just partially. As if even that was overwritten by 0s.
In the linker script I created a signature section to verify that the whole binary is loaded to memory.
When I dumped the memory from gdb I was able to find the string there. It can't be coincidence that it's at 0x1fedf. But I don't understand why. mm.o module is 32b.
This is my repo: mios. Everything is working ok if this variable is not defined. I used the "cli;hlt" to stop in the function, I set the breakpoint in gdb and send nmi from qemu monitor to continue. The issue is:
Code: Select all
0x0000f3ae: push 0x81d8
0x0000f3b3: push 0xfedf <-- str to print
0x0000f3b8: call 0xdb95
0x0000f3bd: cli
0x0000f3be: hlt
=> 0x0000f3bf: mov ebx,0x81d8
0x0000f3c4: add esp,0x10
I also tried to define big array after this variable (and instead of it) just to see what it does. Did even char bigbuf[10240] = "AAA .... A" and test it with it. Print was not working but gdb dump shows that I didn't have array full of 10240 "A" in memory, just partially. As if even that was overwritten by 0s.
In the linker script I created a signature section to verify that the whole binary is loaded to memory.
When I dumped the memory from gdb I was able to find the string there. It can't be coincidence that it's at 0x1fedf. But I don't understand why. mm.o module is 32b.