visual-studiolinkermultiboot

Visual Studio 2015 - control the linking order


I have an older Visual Studio 2010 project. Recently I re-gained interest in it so I converted it to a VS 2015 project. Everything went fine, no problems were reported, it compiles successfully.

Now, the problem with this is that one of the .obj that is created must be the first thing that is linked (the output has to be multi boot compliant, therefore I must ensure that the multiboot header is were it is supposed to be).

For the older versions of VS this was accomplished in a slightly hackish manner: the file that has to be the first has a name that starts with '__' (I was like a kid back then, not always thinking about how to do things right as long as they worked). Naturally, this isn't working anymore.

So, how can one tell the linker that a certain link order is expected? Or, in the context of the question, how does one build multiboot compliant binaries using VS 2015?

EDIT: I already selected a correct answer, but I want to point out that there is also another method if anyone will have the same problem. You can specify a section name for the multiboot header (let's call it .boot) and then merge that with the text section (see https://msdn.microsoft.com/en-us/library/wxz26dz2.aspx). To see how you can specify a section name for the multiboot header read the documentation of your assembler (or what you use to generate the .obj with the header).


Solution

  • Still a bit hackish, but I'd consider using #pragma init_seg(lib).