Similar to GCC, you need to insure that all sections within the final binary are existent. If these sections are messing (Like .code, .data,. rodata, et al...) then the language may not work correctly.
VC++ is the same here. MSVC++ uses the .CRT section of the final binary image to store all global initializers (Such as an objects ctor, static, or global objects that need to be initialized.) This is primarily only needed if you plan support for classes and objects.
The naming convention is in alphabetical order:
Code: Select all
.CRT$XCA
.CRT$XCU
.CRT$XCZ
We use these names in the beginning CRT file to create the sections, like so...
Code: Select all
// all data and variables defined above here is in .data section
#pragma data_seg(".CRT$XCA")
// Now, a new section is created - .CRT. All globals and varables defined
// here are placed inside of the .CRT section instead of .data.
Think of it as an "address" that represents the segment. The LAST character in the name determines WHERE this address is within the segment.
Lets look at the segment names again:
Code: Select all
.CRT$XCA
.CRT$XCU
.CRT$XCZ
The last character / part determines how it is to be arranged.
.CRT$XCA - ends with character "A" (First character in alphabet), so it points to the starting address of the segment.
.CRT$XCU - ends with character "U". If this was the last name, then this would have pointed to the end of the section. But wait!.....
.CRT$XCZ - "Z" is greater then "U", so now U points to the middle of the .CRT section, and .CRT$XCZ now points to the end
Back to the code...
Code: Select all
// Standard C++ Runtime (STD CRT) __xc_a points to
// beginning of initializer table
#pragma data_seg(".CRT$XCA")
_PVFV __xc_a[] = { NULL };
So... __xc_a[] is at the beginning of the .CRT section for MSVC++ to use.
The basic idea here is that we can split the name into two parts seperated by the dollar sign (surprise):
.CRT$XCA << .CRT is the section name
.CRT$XCA << XCA refers to where it is located in that secton
I hope this clarifies things a bit