Re: Visual C++ IDE Kernel Development - Flat Binary
Posted: Mon Dec 31, 2012 1:29 am
You can convert the format with objcopy, which comes with the gcc.
The Place to Start for Operating System Developers
http://f.osdev.org/
trinopoty wrote:Or, use the Microsoft compiler, instruct the IDE to skip link process and add a Post-Build event that will invoke binutils linker.
The latter option is neater if you are used to MSVC syntax.
Well I followed the OSDev tutorial for producing DLLs, and yeah I can compile etc (of course if I turn on /OPT:NOREF, there is no code (but there is data section!?)) but I might consider sticking to ASM with NASM because x64 compilers in Visual C++ don't allow inline ASM anymore. Compilation in Linux is...a mess. I really would prefer to stay away from Linux tools, even if they're ported...cross-compiles typically bring baggage and dependencies in my experiences. Maybe I'm just biased. I thought about stripping PE headers and the DOS stub, splitting my code and data section up and just allocating a kernel code and data section but I've no idea how addresses etc would be 'converted' to flat unless binutils would do that. I've been writing a side-project modem firmware in Linux, specifically ARM, and it is just a giant mess to build the toolchain, even compile half the time. Well that might be due to the toolchain's dependencies being 2007-2009 and 99% of those tools had to be fetched manually and compiled to specific dirs, vendor suppositories wouldn't carry them. I'm not trying to come off ignorant or just dickish, I just don't want to be one of those wasting 80% of development time on trying to compile and deploy a solution. :/ All been there before in some way right? Think I should just write something to strip the PE header, stub etc and just go back to back padded to 512-byte aligned sections (code then data)? How would I reach my data? X_x; I'm not the most familiar with linkers with this depth.mutex wrote:You can even write yourself a tool that takes the output EXE and stripping the PE/EXE headers outputing a "flat" object file. I myself use mingw compiler collection and use both PE and ELF for my os. Gcc-mingw gives you the best of both worlds, and you can use it on Windows, MacOs, Linux..Good luck and happy new year!
Code: Select all
#include "HelloWorld.h"
int main() //Ignore int, visual studio complains
{
char *string = "Hello World!", *ch;
unsigned short *vidmem = (unsigned short *) 0xB8000;
int i;
for(ch = string, i = 0; *ch; ch++, i++)
vidmem[i] = (unsigned char) *ch | 0x0700;
return 0; //Ignore, visual studio complains no return
}