www.digitalmars.com         C & C++   DMDScript  

c++ - Linker and /BASE for binary output format


First of all, sorry if this is the wrong group, but there doesn't seem to be
one specifically for the linker.

I'm currently trying some OS development just for fun and am writing a simple
protected mode 32 bit kernel; I link it together from object files created by
NASM and DMC, using the linker's binary output format.

The bootloader I have written loads the kernel at a fixed absolute address of
0x1000, so I want offsets in the binary image to start at that address. My
first try was to use /BASE:1000, but that doesn't seem to do anything with
binary output. The next obvious choice was to try /BINARY:0x1000; this does
something at least, but instead of just adding an offset of 0x1000 to all
addresses, it seems to cut the first 0x1000 bytes off the binary image! It
also outputs the warning message "Warning 47: Below 100H Cannot Be
Initialized", which seems more relevant to COM files than binary files.

My current workaround is prepending an extra segment to my first object file
(using NASM) which just contains 0x1000 zero bytes. This works, but it's ugly
and bloats the object file which still has to contain these 0x1000 bytes.

Is there anything I've missed? Is the linker supposed to act that way, because
to me it seems more like a bug?

Mar 04 2007