[LLVMdev] Question about ctors, dtors and sections on Windows
Kai
kai at redstar.de
Mon Sep 10 12:05:58 PDT 2012
Hello all!
I extended the LDC2 with a pragma to register a funcion in the
llvm.global_ctors or llvm.global_dtors list.
On Linux, references to these functions are placed in .ctors and .dtors
sections and everything runs fine.
On Windows, functions from llvm.global_ctors are placed in section
.CRT$XCU, which is automatically called by the MS C Runtime. However,
functions from llvm.global_dtors are placed in section .dtors which is
unknown to the runtime. Therefore only ctors are called. Is this
expected behaviour?
My expectation was that the dtors placed in .CRT$XTU which are the C
terminator functions. Maybe there is a way to customize this?
Another question is how can I control section names and attributes.
Before I found the ctors/dtors variables I tried to implement this
functionality by placing a variable in a section with a special name.
This works because a global variable can have an optional section name.
But:
- How can I control section attributes and alingment? E.g. the .CRT$XU
segment is read-only. How can I specify that?
- How can I place constant data in the .rdata section?
Thanks for any hints!
Regards
Kai
More information about the llvm-dev
mailing list