.crt section? What does this warning mean?

Viewed 10754

I've got this warning recently (VC++ 2010)

warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators

I'm assuming this is the Critical Section. It's been a while since my Operating Systems course, so I can't really figure out what this means. If I remember right, the Critical Section works with shared resources. So how is this warning related and what does it mean exactly?

6 Answers

LIBCMT.LIB to initialize the CRT related stuffs.... Use mainCRTStartup for entry function, then call _CRT_INIT explicity.

link hello_world.obj Kernel32.lib UCRT.LIB legacy_stdio_definitions.lib LIBCMT.LIB /subsystem:console  /out:hello_world_basic.exe 
bits 64
default rel

segment .data
    msg db "Hello world!", 0xd, 0xa, 0

segment .text
global mainCRTStartup
extern ExitProcess
extern _CRT_INIT

extern printf

mainCRTStartup:
    push    rbp
    mov     rbp, rsp
    sub     rsp, 32

    call    _CRT_INIT

    lea     rcx, [msg]
    call    printf

    xor     rax, rax
    call    ExitProcess
    ret

If you don't call _CRT_INIT, the linker will show the warnings about "warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators".

Related