if you mean using the "--oformat binary" in the ld cmd, it doesn't work, it gives the following error: "ld cannot perform pe operations on non pe output file 'kernel.bin'", and how do i include the .rodata section too?Octocontrabass wrote:Strings are usually stored in the .rodata section, but you're discarding everything except the .text section. Any particular reason you use objcopy here instead of passing "--oformat binary" to ld like the tutorial does?Code: Select all
objcopy -O binary -j .text kernel\kernel.out kernel\kernel.bin
My VGA driver prints garbage on screen
-
- Posts: 13
- Joined: Sun Jun 14, 2020 5:15 pm
- Libera.chat IRC: mrfrust
Re: My VGA driver prints garbage on screen
-
- Member
- Posts: 797
- Joined: Fri Aug 26, 2016 1:41 pm
- Libera.chat IRC: mpetch
Re: My VGA driver prints garbage on screen
One other issue I see is that when you use objcopy you tell it to only include the `.text` section in the resulting binary. So if you properly link with `-Ttext 0x1000` nothing in any of your other sections will be emitted and likely that includes the string you want to print. Any reason you don't do:
Code: Select all
objcopy -O binary kernel\kernel.out kernel\kernel.bin
-
- Member
- Posts: 797
- Joined: Fri Aug 26, 2016 1:41 pm
- Libera.chat IRC: mpetch
Re: My VGA driver prints garbage on screen
It should be noted that for native windows applications (which is what your MinGW tool chain is generating) the read only data section is actually called .rdata instead of .rodata and it can be a number of sections that start with `.rdata` so it is more like `.rdata*`
Last edited by MichaelPetch on Mon Jun 15, 2020 8:56 am, edited 1 time in total.
-
- Posts: 13
- Joined: Sun Jun 14, 2020 5:15 pm
- Libera.chat IRC: mrfrust
Re: My VGA driver prints garbage on screen
It worked!!! Thanks! It was the objcopy, this was giving me a headache since saturday!MichaelPetch wrote:One other issue I see is that when you use objcopy you tell it to only include the `.text` section in the resulting binary. So if you properly link with `-Ttext 0x1000` nothing in any of your other sections will be emitted and likely that includes the string you want to print. Any reason you don't do:Code: Select all
objcopy -O binary kernel\kernel.out kernel\kernel.bin
-
- Member
- Posts: 5575
- Joined: Mon Mar 25, 2013 7:01 pm
Re: My VGA driver prints garbage on screen
You might have an easier time if you use a proper cross-compiler, like everyone else does.
If you're using Windows 10, you might try installing WSL and build a cross-compiler there. (But it's tricky to get QEMU to launch from a build script, since you'd need to set up GUI support.)
If you're not using Windows 10, or if you want something slightly more "native" to Windows, try MSYS2. (The Windows version of QEMU works here.)
If you're using Windows 10, you might try installing WSL and build a cross-compiler there. (But it's tricky to get QEMU to launch from a build script, since you'd need to set up GUI support.)
If you're not using Windows 10, or if you want something slightly more "native" to Windows, try MSYS2. (The Windows version of QEMU works here.)
-
- Member
- Posts: 797
- Joined: Fri Aug 26, 2016 1:41 pm
- Libera.chat IRC: mpetch
Re: My VGA driver prints garbage on screen
. I agree with you on the cross compiler. I had commented about that on Stackoverflow where this question was cross posted.Octocontrabass wrote:You might have an easier time if you use a proper cross-compiler, like everyone else does.
If you're using Windows 10, you might try installing WSL and build a cross-compiler there. (But it's tricky to get QEMU to launch from a build script, since you'd need to set up GUI support.)
Getting X Windows working on WSL isn't too difficult. Download Xming X11 server from: https://sourceforge.net/projects/xming/ . Then launch into a WSL prompt and modify ~/.bashrc by adding this line to the bottom:
Code: Select all
export DISPLAY=:0
-
- Posts: 13
- Joined: Sun Jun 14, 2020 5:15 pm
- Libera.chat IRC: mrfrust
Re: My VGA driver prints garbage on screen
Wich stackoverflow question? I posted this just here...MichaelPetch wrote:. I agree with you on the cross compiler. I had commented about that on Stackoverflow where this question was cross posted.Octocontrabass wrote:You might have an easier time if you use a proper cross-compiler, like everyone else does.
If you're using Windows 10, you might try installing WSL and build a cross-compiler there. (But it's tricky to get QEMU to launch from a build script, since you'd need to set up GUI support.)
Getting X Windows working on WSL isn't too difficult. Download Xming X11 server from: https://sourceforge.net/projects/xming/ . Then launch into a WSL prompt and modify ~/.bashrc by adding this line to the bottom:. Exit out of the WSL shell and relaunch it. Then all you need to do is make sure the XMing server is running and the X11 output from WSL should appear. qemu should work as expected.Code: Select all
export DISPLAY=:0
-
- Member
- Posts: 797
- Joined: Fri Aug 26, 2016 1:41 pm
- Libera.chat IRC: mpetch
Re: My VGA driver prints garbage on screen
I happened to ask if you were one in the same on the Stackoverflow question, but didn't get a response there. That question uses the same tutorial and had a problem with printing using the same vga driver, uses MinGW and BOCHS on Windows. That question was here: https://stackoverflow.com/questions/623 ... y#62378540 . The output they were getting is an identical screenshot as to the one you posted here: https://prnt.sc/szpyztmrfrustrationman wrote:Wich stackoverflow question? I posted this just here...
Sorry if you are not the same person - you have my apologies. It is pretty coincidental that two users ask nearly the identical question in 48 hours. Maybe this is for a course and it was a classmate?
Re: My VGA driver prints garbage on screen
You can execute regular windows .exe programs through WSL, including both Bochs and QEMU. You just have to point to its path on the C: drive i.e
$> /mnt/c/Program\ Files/qemu/qemu-system-i386.exe -s -S -kernel myos.bin
So no need to try and get X to work
$> /mnt/c/Program\ Files/qemu/qemu-system-i386.exe -s -S -kernel myos.bin
So no need to try and get X to work