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

Anton Korobeynikov anton at korobeynikov.info
Mon Sep 10 12:53:46 PDT 2012


> 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.

> 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.

> - 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

> - 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.

With best regards, Anton Korobeynikov
Faculty of Mathematics and Mechanics, Saint Petersburg State University

More information about the llvm-dev mailing list