I need to use Visual C++ to build a customized Apache web server. Here is the goal I am trying to achieve: specify some of the functions or data in Apache source code, and put them in separate and 4k-page aligned sections (not .text .data .bss) of output .exe file.
The closet solution I can find online is use /Gy compiler options to compile each functions into different COMDATs, and then use /ORDER linker options to put the COMDATs in a predetermined order. However, it is just reordering inside a section, not changing the section layout in .exe output or creating a new section. Under Linux, I can use compiler attribute "section" and linker script to fulfill my goal. Are there equivalent solution in Visual C++? Thanks very much:-)
#pragma code_seg
lets you specify the segment into which code will be placed. Along with being able to specify a name, the compiler keeps a stack of names so you can push and pop the current state if you want.