[LLVMdev] Question about ctors, dtors and sections on Windows

Kai kai at redstar.de
Tue Sep 11 09:14:35 PDT 2012


On 10.09.2012 21:53, Anton Korobeynikov wrote:
> Hello
>
>> On Windows, functions from llvm.global_ctors are placed in section .CRT$XCU,
>> which is automatically called by the MS C Runtime.
> Only if you link with MS runtime. Mingw follows standard .ctors / .dtors scheme.

Yes, I am targeting the MS runtime

>> My expectation was that the dtors placed in .CRT$XTU which are the C
>> terminator functions. Maybe there is a way to customize this?
> Yes. Target (or,rather subtarget) specifies this. Looks like it was
> somehow missed for dtors.

Thanks for the hint. I found it. I'll prepare a patch if I can fix it.

>> - How can I control section attributes and alingment? E.g. the .CRT$XU
>> segment is read-only. How can I specify that?
> This is job of target, not user code. If you need such granularity -
> write assembler

I am thinking about how to implement #pragma (init_seg) and 
#pragma(data_seg) from MSVC in the LDC compiler. Therefore I would need 
this control.

>> - How can I place constant data in the .rdata section?
> The global should be constant. Everything should happen automagically.
> It might be some stuff which depends on relocations, etc.

Seems to be another problem. I'll investigate this a bit more.

Thanks for your answers.

Kai





More information about the llvm-dev mailing list