www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript
electronics



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

Hello,

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?

Thanks,
Clemens
Mar 04 2007