我正在使用 mingw32
在gcc中有一个选项
" -nostartfiles Do not use the standard system startup files when linking. The standard system libraries are used normally, unless -nostdlib or -nodefaultlibs is used. "
如果我不在我自己几乎是空的 c 源代码中使用它,我会在我的 exe 中得到 1000 行反汇编的长 stub 代码,其中包含此类函数
00401000 <___mingw_CRTStartup>:
00401110 <__gnu_exception_handler@4>:
00401280 <_mainCRTStartup>:
004012a0 <_WinMainCRTStartup>:
004012c0 <_atexit>:
004012d0 <__onexit>:
004012e0 <___gcc_register_frame>:
0040132c <___gcc_deregister_frame>:
00401334 <_WinMain@16>:
00401340 <___dyn_tls_dtor@12>:
00401390 <___dyn_tls_init@12>:
00401420 <___tlregdtor>:
00401430 <___cpu_features_init>:
00401510 <__fpreset>:
00401520 <___report_error>:
00401580 <___write_memory.part.0>:
00401690 <__pei386_runtime_relocator>:
00401870 <___do_global_dtors>:
004018a0 <___do_global_ctors>:
004018f0 <___main>:
00401910 <___mingwthr_run_key_dtors.part.0>:
00401970 <____w64_mingwthr_add_key_dtor>:
00401a00 <____w64_mingwthr_remove_key_dtor>:
00401a90 <___mingw_TLScallback>:
00401b30 <___getmainargs>:
00401b38 <__setmode>:
00401b40 <___p__fmode>:
00401b48 <___p__environ>:
00401b50 <__cexit>:
00401b58 <_signal>:
00401b60 <_fwrite>:
00401b68 <_vfprintf>:
00401b70 <_abort>:
00401b78 <_memcpy>:
00401b80 <_calloc>:
00401b88 <_free>:
00401b90 <_SetUnhandledExceptionFilter@4>:
00401b98 <_ExitProcess@4>:
00401ba0 <_GetModuleHandleA@4>:
00401ba8 <_GetProcAddress@8>:
00401bb0 <_VirtualQuery@12>:
00401bb8 <_VirtualProtect@16>:
00401bc0 <_GetCommandLineA@0>:
00401bc8 <_GetStartupInfoA@4>:
00401bd0 <_EnterCriticalSection@4>:
00401bd8 <_TlsGetValue@4>:
00401be0 <_GetLastError@0>:
00401be8 <_LeaveCriticalSection@4>:
00401bf0 <_DeleteCriticalSection@4>:
00401bf8 <_InitializeCriticalSection@4>:
00401c00 <_main>:
00401ce0 <_register_frame_ctor>:
00401cfc <__CTOR_LIST__>:
00401d00 <.ctors.65535>:
00401d08 <__DTOR_LIST__>:
也许有人能告诉我在哪里可以找到它的来源吗? (或者至少有一些详细的解释是什么 - 但来源会更好)
最佳答案
我猜你可以下载 GCC sources或 MinGW sources .
由于 sourceforge.net 上的 mingw-w64 项目正在转移到 mingw-w64.org,我建议也检查一下 mingw-w64.org然后运行 grep
或类似的文本搜索实用程序,找到定义了这些函数的特定文件。
另请注意,exit()
、atexit()
、memcpy()
等一些函数来自 C Run- Time Library,它们不会在 GCC 源代码中定义。
关于c++ - gcc/mingw 中 'startup files' 的来源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27460420/