Sunday, October 02, 2005

Writing multiboot PE kernels using Visual C++ - Part II


Sylvester Hesp said...

Hi. I wonder if you're ever going to read this, but I tried this out with MSVC++ 2008, and the problem is that it doesn't necessarily make the (object containing the) entry point the first function (/object) in the executable. This is fine for your example as you only have one object file, but for multiple the order in which the objects are placed in the PE seem kind of random. It worked at first, but as I changed and expanded my kernel it suddenly stopped working.

I've looked at the linker documentation and there doesn't seem to be any option to put a specific object file in front of everything else, or to define a section that comes even before .text. Of course I could use #pragma code_seg to define all my other functions to not be in .text, but that seems kind of a hassle.

Haven't yet triend manually invoking the linker from the commandline and adding the object files in the correct order though, but I much rather like to have it work using a regular devenv project build.

Do you have any suggestions?

Sylvester Hesp said...

I solved the problem by writing a simple tool that reads the produced PE to get the preferred base, entrypoint and size, and write the multiboot header somewhere in the MSDOS stub in the beginning of the binary. Works like a charm.

Jack said...

I'm getting a LNK1146 error, which is:

no argument specified with option '/OUT:'

I've placed it in with the Linker Command Line in Properties (I'm using Visual C++ 2010 Express Edition by the way).

ADmin said...

The altering and edit administration can improve the click here nature of the logical examination and scholastic paper for distribution in diaries or printing associations.