Lenix直接使用PE格式作为可执行文件的格式了,有侵犯那啥产权的嫌疑啊,不过嘛,现在没有商用,应该不算那啥,如果有机会商用,那时在想办法了,毕竟开发一个编译器比较困难,链接器就相对容易一点,毕竟我就写过,能用的,LENIX最初的版本就是用自己写的链接器制作的映像。
用VS2019来编译Lenix程序,可以在IDE里编译和链接,也可以用命令行的方式进行编译和链接。实质其实就是设置ml.exe和link.exe的参数,让编译器不要干太多额外的事情。
至于使用IDE来调试,那就不用想,LENIX是操作系统,经常使用要运行在RING0特权级的指令,在windows的调试器里直接就挂了。
LENIX是操作系统,在windows看来,就是个大病毒,如果打开杀毒程序,刚编译出来的文件就会被干掉。所以,最好是别开杀毒软件。
就是设置ML.EXE的参数
要包含头文件的目录和标准库的文件目录 include; include\c
这里我是使用了完整路径,具体的位置就看开发资源放哪里了。
在同一个设置窗口中,还有一个SDL检查,这个选项要关闭,否则VC会插入一些函数的调用,这个就属于我不想要的功能了,其实吧,是我不知道如何提供它需要的函数功能,所以,只能禁用。
其实这个不是必须的,但最好这么做,因为标准包含路径通常是开发正常的windows程序需要使用的,如果不忽略标准包含路径,有可能会包含进同名文件,比如标准C的头文件,会造成很多奇怪的问题。
如果忽略标准包含路径,就可以实现开发正常的windows程序和开发lenix互不影响。
安全检查是VC提供的一项额外功能,我也不知道该如何实现,干脆就禁用了,安全就由自己负责吧。
至于增强指令集,就是SSE、SSE2、AVX等等之类的,暂时还是不要用了,因为现在我还没办法在非法指令异常中实现指令模拟,真要碰上指令异常,就只能退出进程了。所以干脆别用,等升级版在完善吧。
设置LINE.EXE参数
就是需要用到的目标文件(obj)和库文件(lib),
文件名 | 说明 |
---|---|
lenix.lib | 这是系统文件的输出库,提供了进程、内存、文件系统、设备管理、虚拟计算机模型、动态扩展模块管理等等功能的输出函数 |
lnxc.lib | 标准C库,和一些lenix扩展。不过嘛,现在对于标准C库的支持还不足,只是完成大部分的文件功能 |
libc.lib | 这个实际上是VC6时代的文件了,我从VC6里面找出来的。用这个主要是VC在编译64位的整数乘除时,用到里面一些函数,这些函数我还不会,也是在没时间取研究了,只能直接用现成的了 |
msvcrt.lib | 这个和libc.lib一样的情况 |
至于忽略所有默认库,这是为了避免莫名其妙的使用了windows的库,防止库文件命名与windows的文件冲突
这个选项可以让Windows将程序装载到内存的任意位置。但是对于exe来说,一般都是固定基址(通常是0x00400000,也就是线性地址4M的位置),这样可以提高装载性能。
Lenix并没有使用MMU,因此也就没有为每个进程提供一个独立的地址空间,也就不能使用固定基址了。禁用了固定基址后,链接的时候,就会生成重定位节,LENIX就可以使用这个重定位节来装载程序了。
这个选项也会让VC生成我不知道该如何提供对应功能的代码,只能禁用了。
就一段简单的代码
/* 2020-02-19 */
#include
int main(int argc, char ** argv)
{
printf("hello, lenix\n");
return 0;
}
test
.
Timestamp is 5e4d4890 (Wed Feb 19 22:39:12 2020)
.
Preferred load address is 00400000
.
Start Length Name Class
0001:00000000 00000cecH .text$mn CODE
0002:00000000 000000c4H .idata$5 DATA
0002:000000c4 00000004H .00cfg DATA
0002:000000c8 00000004H .CRT$XCA DATA
0002:000000cc 00000004H .CRT$XCAA DATA
0002:000000d0 00000004H .CRT$XCZ DATA
0002:000000d4 00000004H .CRT$XIA DATA
0002:000000d8 00000004H .CRT$XIAA DATA
0002:000000dc 00000004H .CRT$XIAC DATA
0002:000000e0 00000004H .CRT$XIZ DATA
0002:000000e4 00000004H .CRT$XPA DATA
0002:000000e8 00000004H .CRT$XPZ DATA
0002:000000ec 00000004H .CRT$XTA DATA
0002:000000f0 00000010H .CRT$XTZ DATA
0002:000000f4 00000000H .gfids$y DATA
0002:00000100 00000140H .rdata DATA
0002:00000240 00000004H .rdata$sxdata DATA
0002:00000244 000002b4H .rdata$zzzdbg DATA
0002:000004f8 00000004H .rtc$IAA DATA
0002:000004fc 00000004H .rtc$IZZ DATA
0002:00000500 00000004H .rtc$TAA DATA
0002:00000504 00000004H .rtc$TZZ DATA
0002:00000508 0000003cH .xdata$x DATA
0002:00000544 00000000H .edata DATA
0002:00000544 0000008cH .idata$2 DATA
0002:000005d0 00000014H .idata$3 DATA
0002:000005e4 000000c4H .idata$4 DATA
0002:000006a8 00000426H .idata$6 DATA
0003:00000000 00000018H .data DATA
0003:00000018 00000370H .bss DATA
0004:00000000 00000060H .rsrc$01 DATA
0004:00000060 00000180H .rsrc$02 DATA
.
Address Publics by Value Rva+Base Lib:Object
.
0000:00000000 ___guard_fids_count 00000000 <absolute>
0000:00000000 ___hybrid_code_map 00000000 <absolute>
0000:00000000 ___guard_longjmp_count 00000000 <absolute>
0000:00000000 ___hybrid_auxiliary_iat 00000000 <absolute>
0000:00000000 ___dynamic_value_reloc_table 00000000 <absolute>
0000:00000000 ___guard_iat_table 00000000 <absolute>
0000:00000000 ___hybrid_code_map_count 00000000 <absolute>
0000:00000000 ___guard_longjmp_table 00000000 <absolute>
0000:00000000 ___volatile_metadata 00000000 <absolute>
0000:00000000 ___enclave_config 00000000 <absolute>
0000:00000000 ___AbsoluteZero 00000000 <absolute>
0000:00000000 ___guard_iat_count 00000000 <absolute>
0000:00000000 ___guard_fids_table 00000000 <absolute>
0000:00000001 ___safe_se_handler_count 00000001 <absolute>
0000:00000100 ___guard_flags 00000100 <absolute>
0000:00000000 ___ImageBase 00400000 <linker-defined>
0001:00000000 ___local_stdio_printf_options 00401000 f i lnxdbg.obj
0001:00000010 _printf 00401010 f i lnxdbg.obj
0001:00000040 _main 00401040 f lnxdbg.obj
0001:00000050 @__security_check_cookie@4 00401050 f MSVCRT:secchk.obj
0001:000002a8 _mainCRTStartup 004012a8 f MSVCRT:exe_main.obj
0001:000002b2 ___raise_securityfailure 004012b2 f MSVCRT:gs_report.obj
0001:000002da ___report_gsfailure 004012da f MSVCRT:gs_report.obj
0001:00000417 ___scrt_acquire_startup_lock 00401417 f MSVCRT:utility.obj
0001:00000449 ___scrt_initialize_crt 00401449 f MSVCRT:utility.obj
0001:00000482 ___scrt_initialize_onexit_tables 00401482 f MSVCRT:utility.obj
0001:00000509 ___scrt_is_nonwritable_in_current_image 00401509 f MSVCRT:utility.obj
0001:0000059d ___scrt_release_startup_lock 0040159d f MSVCRT:utility.obj
0001:000005ba ___scrt_uninitialize_crt 004015ba f MSVCRT:utility.obj
0001:000005e2 __onexit 004015e2 f MSVCRT:utility.obj
0001:0000060f _atexit 0040160f f MSVCRT:utility.obj
0001:00000671 ___security_init_cookie 00401671 f MSVCRT:gs_support.obj
0001:000006bc ___scrt_exe_initialize_mta 004016bc f MSVCRT:utility_desktop.obj
0001:000006bc __get_startup_commit_mode 004016bc f MSVCRT:commit_mode.obj
0001:000006bc __get_startup_new_mode 004016bc f MSVCRT:new_mode.obj
0001:000006bc __matherr 004016bc f MSVCRT:matherr.obj
0001:000006bc ___scrt_stub_for_initialize_mta 004016bc f MSVCRT:utility_desktop.obj
0001:000006bc __get_startup_thread_locale_mode 004016bc f MSVCRT:thread_locale.obj
0001:000006bc ___scrt_initialize_winrt 004016bc f MSVCRT:utility_desktop.obj
0001:000006bf __get_startup_argv_mode 004016bf f MSVCRT:argv_mode.obj
0001:000006c3 __get_startup_file_mode 004016c3 f MSVCRT:file_mode.obj
0001:000006c9 ?__scrt_initialize_type_info@@YAXXZ 004016c9 f MSVCRT:tncleanup.obj
0001:000006d5 ___acrt_initialize 004016d5 f MSVCRT:ucrt_stubs.obj
0001:000006d5 ___acrt_uninitialize 004016d5 f MSVCRT:ucrt_stubs.obj
0001:000006d5 ___vcrt_initialize 004016d5 f MSVCRT:ucrt_stubs.obj
0001:000006d5 __should_initialize_environment 004016d5 f MSVCRT:env_mode.obj
0001:000006d5 ___scrt_stub_for_acrt_uninitialize 004016d5 f MSVCRT:ucrt_stubs.obj
0001:000006d5 ___vcrt_uninitialize 004016d5 f MSVCRT:ucrt_stubs.obj
0001:000006d5 ___scrt_stub_for_acrt_initialize 004016d5 f MSVCRT:ucrt_stubs.obj
0001:000006d8 __initialize_default_precision 004016d8 f MSVCRT:default_precision.obj
0001:000006f9 __initialize_invalid_parameter_handler 004016f9 f MSVCRT:invalid_parameter_handler.obj
0001:000006f9 @_guard_check_icall_nop@4 004016f9 f MSVCRT:guard_support.obj
0001:000006f9 __initialize_denormal_control 004016f9 f MSVCRT:denormal_control.obj
0001:000006fa ___local_stdio_scanf_options 004016fa f i MSVCRT:default_local_stdio_options.obj
0001:00000700 ___scrt_initialize_default_local_stdio_options 00401700 f MSVCRT:default_local_stdio_options.obj
0001:0000071d ___scrt_is_user_matherr_present 0040171d f MSVCRT:matherr_detection.obj
0001:00000729 ___scrt_get_dyn_tls_init_callback 00401729 f MSVCRT:dyn_tls_init.obj
0001:0000072f ___scrt_get_dyn_tls_dtor_callback 0040172f f MSVCRT:dyn_tls_dtor.obj
0001:00000735 ___scrt_fastfail 00401735 f MSVCRT:utility_desktop.obj
0001:0000084f ___scrt_initialize_mta 0040184f f MSVCRT:utility_desktop.obj
0001:00000854 ___scrt_is_managed_app 00401854 f MSVCRT:utility_desktop.obj
0001:00000897 ___scrt_set_unhandled_exception_filter 00401897 f MSVCRT:utility_desktop.obj
0001:000008a3 ___scrt_unhandled_exception_filter@4 004018a3 f MSVCRT:utility_desktop.obj
0001:000008f9 __crt_debugger_hook 004018f9 f MSVCRT:utility_desktop.obj
0001:00000901 __RTC_Initialize 00401901 f MSVCRT:initsect.obj
0001:0000092d __RTC_Terminate 0040192d f MSVCRT:initsect.obj
0001:00000960 __SEH_prolog4 00401960 f MSVCRT:sehprolg4.obj
0001:000009a6 __SEH_epilog4 004019a6 f MSVCRT:sehprolg4.obj
0001:000009bb __except_handler4 004019bb f MSVCRT:chandler4gs.obj
0001:000009ea ___isa_available_init 004019ea f MSVCRT:cpu_disp.obj
0001:00000bba ___scrt_is_ucrt_dll_in_use 00401bba f MSVCRT:ucrt_detection.obj
0001:00000bc6 ___current_exception 00401bc6 f vcruntime:VCRUNTIME140.dll
0001:00000bcc ___current_exception_context 00401bcc f vcruntime:VCRUNTIME140.dll
0001:00000bd2 _memset 00401bd2 f vcruntime:VCRUNTIME140.dll
0001:00000bd8 __except_handler4_common 00401bd8 f vcruntime:VCRUNTIME140.dll
0001:00000bde __seh_filter_exe 00401bde f ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0001:00000be4 __set_app_type 00401be4 f ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0001:00000bea ___setusermatherr 00401bea f ucrt:api-ms-win-crt-math-l1-1-0.dll
0001:00000bf0 __configure_narrow_argv 00401bf0 f ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0001:00000bf6 __initialize_narrow_environment 00401bf6 f ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0001:00000bfc __get_initial_narrow_environment 00401bfc f ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0001:00000c02 __initterm 00401c02 f ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0001:00000c08 __initterm_e 00401c08 f ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0001:00000c0e _exit 00401c0e f ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0001:00000c14 __exit 00401c14 f ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0001:00000c1a __set_fmode 00401c1a f ucrt:api-ms-win-crt-stdio-l1-1-0.dll
0001:00000c20 ___p___argc 00401c20 f ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0001:00000c26 ___p___argv 00401c26 f ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0001:00000c2c __cexit 00401c2c f ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0001:00000c32 __c_exit 00401c32 f ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0001:00000c38 __register_thread_local_exe_atexit_callback 00401c38 f ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0001:00000c3e __configthreadlocale 00401c3e f ucrt:api-ms-win-crt-locale-l1-1-0.dll
0001:00000c44 __set_new_mode 00401c44 f ucrt:api-ms-win-crt-heap-l1-1-0.dll
0001:00000c4a ___p__commode 00401c4a f ucrt:api-ms-win-crt-stdio-l1-1-0.dll
0001:00000c50 __initialize_onexit_table 00401c50 f ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0001:00000c56 __register_onexit_function 00401c56 f ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0001:00000c5c __crt_atexit 00401c5c f ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0001:00000c62 __controlfp_s 00401c62 f ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0001:00000c68 _terminate 00401c68 f ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0001:00000c6e _IsProcessorFeaturePresent@4 00401c6e f kernel32:KERNEL32.dll
0001:00000c74 __filter_x86_sse2_floating_point_exception 00401c74 f MSVCRT:x86_exception_filter.obj
0001:00000c74 __filter_x86_sse2_floating_point_exception_default 00401c74 f MSVCRT:x86_exception_filter.obj
0002:00000000 __imp__GetSystemTimeAsFileTime@4 00402000 kernel32:KERNEL32.dll
0002:00000004 __imp__SetUnhandledExceptionFilter@4 00402004 kernel32:KERNEL32.dll
0002:00000008 __imp__GetCurrentProcess@0 00402008 kernel32:KERNEL32.dll
0002:0000000c __imp__TerminateProcess@8 0040200c kernel32:KERNEL32.dll
0002:00000010 __imp__IsProcessorFeaturePresent@4 00402010 kernel32:KERNEL32.dll
0002:00000014 __imp__GetModuleHandleW@4 00402014 kernel32:KERNEL32.dll
0002:00000018 __imp__IsDebuggerPresent@0 00402018 kernel32:KERNEL32.dll
0002:0000001c __imp__InitializeSListHead@4 0040201c kernel32:KERNEL32.dll
0002:00000020 __imp__UnhandledExceptionFilter@4 00402020 kernel32:KERNEL32.dll
0002:00000024 __imp__GetCurrentThreadId@0 00402024 kernel32:KERNEL32.dll
0002:00000028 __imp__GetCurrentProcessId@0 00402028 kernel32:KERNEL32.dll
0002:0000002c __imp__QueryPerformanceCounter@4 0040202c kernel32:KERNEL32.dll
0002:00000030 \177KERNEL32_NULL_THUNK_DATA 00402030 kernel32:KERNEL32.dll
0002:00000034 __imp____current_exception_context 00402034 vcruntime:VCRUNTIME140.dll
0002:00000038 __imp____current_exception 00402038 vcruntime:VCRUNTIME140.dll
0002:0000003c __imp__memset 0040203c vcruntime:VCRUNTIME140.dll
0002:00000040 __imp___except_handler4_common 00402040 vcruntime:VCRUNTIME140.dll
0002:00000044 \177VCRUNTIME140_NULL_THUNK_DATA 00402044 vcruntime:VCRUNTIME140.dll
0002:00000048 __imp___set_new_mode 00402048 ucrt:api-ms-win-crt-heap-l1-1-0.dll
0002:0000004c \177api-ms-win-crt-heap-l1-1-0_NULL_THUNK_DATA 0040204c ucrt:api-ms-win-crt-heap-l1-1-0.dll
0002:00000050 __imp___configthreadlocale 00402050 ucrt:api-ms-win-crt-locale-l1-1-0.dll
0002:00000054 \177api-ms-win-crt-locale-l1-1-0_NULL_THUNK_DATA 00402054 ucrt:api-ms-win-crt-locale-l1-1-0.dll
0002:00000058 __imp____setusermatherr 00402058 ucrt:api-ms-win-crt-math-l1-1-0.dll
0002:0000005c \177api-ms-win-crt-math-l1-1-0_NULL_THUNK_DATA 0040205c ucrt:api-ms-win-crt-math-l1-1-0.dll
0002:00000060 __imp___c_exit 00402060 ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0002:00000064 __imp___seh_filter_exe 00402064 ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0002:00000068 __imp___initialize_onexit_table 00402068 ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0002:0000006c __imp___cexit 0040206c ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0002:00000070 __imp___crt_atexit 00402070 ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0002:00000074 __imp___controlfp_s 00402074 ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0002:00000078 __imp__terminate 00402078 ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0002:0000007c __imp___set_app_type 0040207c ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0002:00000080 __imp___register_thread_local_exe_atexit_callback 00402080 ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0002:00000084 __imp____p___argv 00402084 ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0002:00000088 __imp___register_onexit_function 00402088 ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0002:0000008c __imp___exit 0040208c ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0002:00000090 __imp__exit 00402090 ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0002:00000094 __imp___initterm_e 00402094 ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0002:00000098 __imp___initterm 00402098 ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0002:0000009c __imp___get_initial_narrow_environment 0040209c ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0002:000000a0 __imp___initialize_narrow_environment 004020a0 ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0002:000000a4 __imp___configure_narrow_argv 004020a4 ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0002:000000a8 __imp____p___argc 004020a8 ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0002:000000ac \177api-ms-win-crt-runtime-l1-1-0_NULL_THUNK_DATA 004020ac ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0002:000000b0 __imp____stdio_common_vfprintf 004020b0 ucrt:api-ms-win-crt-stdio-l1-1-0.dll
0002:000000b4 __imp____acrt_iob_func 004020b4 ucrt:api-ms-win-crt-stdio-l1-1-0.dll
0002:000000b8 __imp____p__commode 004020b8 ucrt:api-ms-win-crt-stdio-l1-1-0.dll
0002:000000bc __imp___set_fmode 004020bc ucrt:api-ms-win-crt-stdio-l1-1-0.dll
0002:000000c0 \177api-ms-win-crt-stdio-l1-1-0_NULL_THUNK_DATA 004020c0 ucrt:api-ms-win-crt-stdio-l1-1-0.dll
0002:000000c4 ___guard_check_icall_fptr 004020c4 MSVCRT:guard_support.obj
0002:000000c8 ___xc_a 004020c8 MSVCRT:initializers.obj
0002:000000d0 ___xc_z 004020d0 MSVCRT:initializers.obj
0002:000000d4 ___xi_a 004020d4 MSVCRT:initializers.obj
0002:000000e0 ___xi_z 004020e0 MSVCRT:initializers.obj
0002:000000e4 ___xp_a 004020e4 MSVCRT:initializers.obj
0002:000000e8 ___xp_z 004020e8 MSVCRT:initializers.obj
0002:000000ec ___xt_a 004020ec MSVCRT:initializers.obj
0002:000000f0 ___xt_z 004020f0 MSVCRT:initializers.obj
0002:00000108 ??_C@_0O@JMNLAPLP@hello?0?5lenix?6@ 00402108 lnxdbg.obj
0002:00000190 __load_config_used 00402190 MSVCRT:loadcfg.obj
0002:00000240 ___safe_se_handler_table 00402240 <linker-defined>
0002:000004f8 ___rtc_iaa 004024f8 MSVCRT:initsect.obj
0002:000004fc ___rtc_izz 004024fc MSVCRT:initsect.obj
0002:00000500 ___rtc_taa 00402500 MSVCRT:initsect.obj
0002:00000504 ___rtc_tzz 00402504 MSVCRT:initsect.obj
0002:00000544 __IMPORT_DESCRIPTOR_VCRUNTIME140 00402544 vcruntime:VCRUNTIME140.dll
0002:00000558 __IMPORT_DESCRIPTOR_api-ms-win-crt-stdio-l1-1-0 00402558 ucrt:api-ms-win-crt-stdio-l1-1-0.dll
0002:0000056c __IMPORT_DESCRIPTOR_api-ms-win-crt-runtime-l1-1-0 0040256c ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0002:00000580 __IMPORT_DESCRIPTOR_api-ms-win-crt-math-l1-1-0 00402580 ucrt:api-ms-win-crt-math-l1-1-0.dll
0002:00000594 __IMPORT_DESCRIPTOR_api-ms-win-crt-locale-l1-1-0 00402594 ucrt:api-ms-win-crt-locale-l1-1-0.dll
0002:000005a8 __IMPORT_DESCRIPTOR_api-ms-win-crt-heap-l1-1-0 004025a8 ucrt:api-ms-win-crt-heap-l1-1-0.dll
0002:000005bc __IMPORT_DESCRIPTOR_KERNEL32 004025bc kernel32:KERNEL32.dll
0002:000005d0 __NULL_IMPORT_DESCRIPTOR 004025d0 vcruntime:VCRUNTIME140.dll
0003:00000000 ___security_cookie_complement 00403000 MSVCRT:gs_cookie.obj
0003:00000004 ___security_cookie 00403004 MSVCRT:gs_cookie.obj
0003:00000008 ___scrt_native_dllmain_reason 00403008 MSVCRT:utility.obj
0003:0000000c ___scrt_default_matherr 0040300c MSVCRT:matherr.obj
0003:00000010 ___isa_enabled 00403010 MSVCRT:cpu_disp.obj
0003:00000014 ___scrt_ucrt_dll_is_in_use 00403014 MSVCRT:ucrt_stubs.obj
0003:00000334 ___scrt_current_native_startup_state 00403334 MSVCRT:utility.obj
0003:00000338 ___scrt_native_startup_lock 00403338 MSVCRT:utility.obj
0003:00000358 ?__type_info_root_node@@3U__type_info_node@@A 00403358 MSVCRT:tncleanup.obj
0003:00000360 ?_OptionsStorage@?1??__local_stdio_scanf_options@@9@4_KA 00403360 MSVCRT:default_local_stdio_options.obj
0003:00000368 ___scrt_debugger_hook_flag 00403368 MSVCRT:utility_desktop.obj
0003:0000036c ___isa_available 0040336c MSVCRT:cpu_disp.obj
0003:00000370 ___favor 00403370 MSVCRT:cpu_disp.obj
0003:00000374 ___dyn_tls_dtor_callback 00403374 <common>
0003:00000378 ___dyn_tls_init_callback 00403378 <common>
0003:00000380 ?_OptionsStorage@?1??__local_stdio_printf_options@@9@9 00403380 <common>
.
entry point at 0001:000002a8
.
Static symbols
.
0000:ffffa000 .debug$S 00400000 vcruntime:VCRUNTIME140.dll
0000:ffffa000 .debug$S 00400000 vcruntime:VCRUNTIME140.dll
0000:ffffa000 .debug$S 00400000 vcruntime:VCRUNTIME140.dll
0000:ffffa000 .debug$S 00400000 vcruntime:VCRUNTIME140.dll
0000:ffffa000 .debug$S 00400000 vcruntime:VCRUNTIME140.dll
0000:ffffa000 .debug$S 00400000 ucrt:api-ms-win-crt-heap-l1-1-0.dll
0000:ffffa000 .debug$S 00400000 ucrt:api-ms-win-crt-locale-l1-1-0.dll
0000:ffffa000 .debug$S 00400000 ucrt:api-ms-win-crt-math-l1-1-0.dll
0000:ffffa000 .debug$S 00400000 ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0000:ffffa000 .debug$S 00400000 ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0000:ffffa000 .debug$S 00400000 ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0000:ffffa000 .debug$S 00400000 ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0000:ffffa000 .debug$S 00400000 ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0000:ffffa000 .debug$S 00400000 ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0000:ffffa000 .debug$S 00400000 ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0000:ffffa000 .debug$S 00400000 ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0000:ffffa000 .debug$S 00400000 ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0000:ffffa000 .debug$S 00400000 ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0000:ffffa000 .debug$S 00400000 ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0000:ffffa000 .debug$S 00400000 ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0000:ffffa000 .debug$S 00400000 ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0000:ffffa000 .debug$S 00400000 ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0000:ffffa000 .debug$S 00400000 ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0000:ffffa000 .debug$S 00400000 ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0000:ffffa000 .debug$S 00400000 ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0000:ffffa000 .debug$S 00400000 ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0000:ffffa000 .debug$S 00400000 ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0000:ffffa000 .debug$S 00400000 ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0000:ffffa000 .debug$S 00400000 ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0000:ffffa000 .debug$S 00400000 ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0000:ffffa000 .debug$S 00400000 ucrt:api-ms-win-crt-stdio-l1-1-0.dll
0000:ffffa000 .debug$S 00400000 ucrt:api-ms-win-crt-stdio-l1-1-0.dll
0000:ffffa000 .debug$S 00400000 ucrt:api-ms-win-crt-stdio-l1-1-0.dll
0000:ffffa000 .debug$S 00400000 ucrt:api-ms-win-crt-stdio-l1-1-0.dll
0000:ffffa000 .debug$S 00400000 kernel32:KERNEL32.dll
0000:ffffa000 .debug$S 00400000 kernel32:KERNEL32.dll
0000:ffffa000 .debug$S 00400000 kernel32:KERNEL32.dll
0000:ffffa000 .debug$S 00400000 kernel32:KERNEL32.dll
0000:ffffa000 .debug$S 00400000 kernel32:KERNEL32.dll
0000:ffffa000 .debug$S 00400000 kernel32:KERNEL32.dll
0000:ffffa000 .debug$S 00400000 kernel32:KERNEL32.dll
0000:ffffa000 .debug$S 00400000 kernel32:KERNEL32.dll
0000:ffffa000 .debug$S 00400000 kernel32:KERNEL32.dll
0000:ffffa000 .debug$S 00400000 kernel32:KERNEL32.dll
0000:ffffa000 .debug$S 00400000 kernel32:KERNEL32.dll
0000:ffffa000 .debug$S 00400000 kernel32:KERNEL32.dll
0000:ffffa000 .debug$S 00400000 kernel32:KERNEL32.dll
0001:00000061 ?pre_c_initialization@@YAHXZ 00401061 f MSVCRT:exe_main.obj
0001:0000010c ?post_pgo_initialization@@YAHXZ 0040110c f MSVCRT:exe_main.obj
0001:00000114 ?pre_cpp_initialization@@YAXXZ 00401114 f MSVCRT:exe_main.obj
0001:00000126 ?__scrt_common_main_seh@@YAHXZ 00401126 f MSVCRT:exe_main.obj
0001:000003d3 ?find_pe_section@@YAPAU_IMAGE_SECTION_HEADER@@QAEI@Z 004013d3 f MSVCRT:utility.obj
0001:00000624 ___get_entropy 00401624 f MSVCRT:gs_support.obj
0001:00000960 $$000000 00401960 MSVCRT:sehprolg4.obj
0002:000000cc ?pre_cpp_initializer@@3P6AXXZA 004020cc MSVCRT:exe_main.obj
0002:000000d8 ?pre_c_initializer@@3P6AHXZA 004020d8 MSVCRT:exe_main.obj
0002:000000dc ?post_pgo_initializer@@3P6AHXZA 004020dc MSVCRT:exe_main.obj
0002:00000100 _GS_ExceptionPointers 00402100 MSVCRT:gs_report.obj
0002:00000508 __sehtable$?__scrt_common_main_seh@@YAHXZ 00402508 MSVCRT:exe_main.obj
0002:00000528 __sehtable$___scrt_is_nonwritable_in_current_image 00402528 MSVCRT:utility.obj
0002:00000700 .idata$6 00402700 vcruntime:VCRUNTIME140.dll
0002:00000900 .idata$6 00402900 ucrt:api-ms-win-crt-stdio-l1-1-0.dll
0002:00000920 .idata$6 00402920 ucrt:api-ms-win-crt-runtime-l1-1-0.dll
0002:00000942 .idata$6 00402942 ucrt:api-ms-win-crt-math-l1-1-0.dll
0002:00000962 .idata$6 00402962 ucrt:api-ms-win-crt-locale-l1-1-0.dll
0002:00000984 .idata$6 00402984 ucrt:api-ms-win-crt-heap-l1-1-0.dll
0002:00000ac0 .idata$6 00402ac0 kernel32:KERNEL32.dll
0003:00000018 _GS_ExceptionRecord 00403018 MSVCRT:gs_report.obj
0003:00000068 _GS_ContextRecord 00403068 MSVCRT:gs_report.obj
0003:0000033c ?is_initialized_as_dll@@3_NA 0040333c MSVCRT:utility.obj
0003:0000033d ?module_local_atexit_table_initialized@@3_NA 0040333d MSVCRT:utility.obj
0003:00000340 ?module_local_atexit_table@@3U_onexit_table_t@@A 00403340 MSVCRT:utility.obj
0003:0000034c ?module_local_at_quick_exit_table@@3U_onexit_table_t@@A 0040334c MSVCRT:utility.obj
0004:00000060 $R000000 00404060 * linker generated manifest res *
lnxdbg
.
Timestamp is 5e4d47b4 (Wed Feb 19 22:35:32 2020)
.
Preferred load address is 00400000
.
Start Length Name Class
0001:00000000 000002d0H .text CODE
0001:000002d0 00001442H .text$mn CODE
0002:00000000 00000030H .idata$5 DATA
0002:00000030 000000b0H .rdata DATA
0002:000000e0 00000000H .edata DATA
0002:000000e0 00000160H .rdata$zzzdbg DATA
0002:00000240 00000014H .idata$2 DATA
0002:00000254 00000014H .idata$3 DATA
0002:00000268 00000024H .idata$4 DATA
0002:0000028c 000000b2H .idata$6 DATA
0003:00000000 00000000H .data DATA
0003:00000000 000014c0H .bss DATA
0004:00000000 00000060H .rsrc$01 DATA
0004:00000060 00000180H .rsrc$02 DATA
.
Address Publics by Value Rva+Base Lib:Object
.
0000:00000000 ___hybrid_code_map 00000000 <absolute>
0000:00000000 ___hybrid_code_map_count 00000000 <absolute>
0000:00000000 ___guard_longjmp_table 00000000 <absolute>
0000:00000000 ___guard_fids_count 00000000 <absolute>
0000:00000000 ___guard_fids_table 00000000 <absolute>
0000:00000000 ___guard_iat_count 00000000 <absolute>
0000:00000000 ___dynamic_value_reloc_table 00000000 <absolute>
0000:00000000 ___enclave_config 00000000 <absolute>
0000:00000000 ___guard_iat_table 00000000 <absolute>
0000:00000000 ___guard_flags 00000000 <absolute>
0000:00000000 ___guard_longjmp_count 00000000 <absolute>
0000:00000000 ___AbsoluteZero 00000000 <absolute>
0000:00000000 ___volatile_metadata 00000000 <absolute>
0000:00000000 ___hybrid_auxiliary_iat 00000000 <absolute>
0001:00000000 __aullrem 00401000 f libc:ullrem.obj
0001:00000080 _memcpy 00401080 f libc:memcpy.obj
0001:000001d0 _memset 004011d0 f libc:memset.obj
0001:00000230 __aulldvrm 00401230 f msvcrt:ulldvrm.obj
0001:000002d0 _main 004012d0 f lnxdbg.obj
0001:000002e0 _printf 004012e0 f lnxc:printf.obj
0001:00000300 _mainCRTStartup 00401300 f lnxc:mainCRTStartup.obj
0001:000003d0 _vsnprintf 004013d0 f lnxc:vsnprintf.obj
0001:00001400 __refresh_stream_buf 00402400 f lnxc:file.obj
0001:000014e0 _fwrite 004024e0 f lnxc:fwrite.obj
0002:00000000 __imp__LNX_GetCommandLine@8 00403000 lenix:LENIX.SYS
0002:00000004 __imp__LNX_Exit@4 00403004 lenix:LENIX.SYS
0002:00000008 __imp__LNX_WriteFile@16 00403008 lenix:LENIX.SYS
0002:0000000c __imp__LNX_ReadFile@16 0040300c lenix:LENIX.SYS
0002:00000010 __imp__LNX_OpenTTY@8 00403010 lenix:LENIX.SYS
0002:00000014 __imp__LNX_GetFileSize@4 00403014 lenix:LENIX.SYS
0002:00000018 __imp__LNX_SetFilePointer@16 00403018 lenix:LENIX.SYS
0002:0000001c __imp__LNX_GetFilePointer@4 0040301c lenix:LENIX.SYS
0002:00000020 \177LENIX_NULL_THUNK_DATA 00403020 lenix:LENIX.SYS
0002:00000030 ??_C@_0O@JMNLAPLP@hello?0?5lenix?6@ 00403030 lnxdbg.obj
0002:00000040 _alphabet_A 00403040 lnxc:vsnprintf.obj
0002:00000054 _alphabet_a 00403054 lnxc:vsnprintf.obj
0002:00000240 __IMPORT_DESCRIPTOR_LENIX 00403240 lenix:LENIX.SYS
0002:00000254 __NULL_IMPORT_DESCRIPTOR 00403254 lenix:LENIX.SYS
0003:000000c0 _cmdline 004040c0 <common>
0003:000010c0 _argv 004050c0 <common>
.
entry point at 0001:00000300
.
Static symbols
.
0000:ffff8000 .debug$S 00400000 lenix:LENIX.SYS
0000:ffff8000 .debug$S 00400000 lenix:LENIX.SYS
0000:ffff8000 .debug$S 00400000 lenix:LENIX.SYS
0000:ffff8000 .debug$S 00400000 lenix:LENIX.SYS
0000:ffff8000 .debug$S 00400000 lenix:LENIX.SYS
0000:ffff8000 .debug$S 00400000 lenix:LENIX.SYS
0000:ffff8000 .debug$S 00400000 lenix:LENIX.SYS
0000:ffff8000 .debug$S 00400000 lenix:LENIX.SYS
0001:000000b8 TrailingVecs 004010b8 libc:memcpy.obj
0001:000000c8 Trail3 004010c8 libc:memcpy.obj
0001:000000dc Trail2 004010dc libc:memcpy.obj
0001:000000ec Trail1 004010ec libc:memcpy.obj
0001:000000f0 Trail0 004010f0 libc:memcpy.obj
0001:00000150 TrailingVecs_copydown 00401150 libc:memcpy.obj
0001:00000160 Trail3_copydown 00401160 libc:memcpy.obj
0001:00000178 Trail2_copydown 00401178 libc:memcpy.obj
0001:00000188 Trail1_copydown 00401188 libc:memcpy.obj
0001:0000018e Trail0_copydown 0040118e libc:memcpy.obj
0001:00000230 $$000000 00401230 msvcrt:ulldvrm.obj
0001:0000138c $LN807 0040238c lnxc:vsnprintf.obj
0001:000013a0 $LN806 004023a0 lnxc:vsnprintf.obj
0001:000013b4 $LN809 004023b4 lnxc:vsnprintf.obj
0001:000013dc $LN808 004023dc lnxc:vsnprintf.obj
0002:00000334 .idata$6 00403334 lenix:LENIX.SYS
0003:00000000 _stdiostream 00404000 lnxc:file.obj
0004:00000060 $R000000 00406060 * linker generated manifest res *
其实吧,你以为就一个简单的程序?后边的支撑吓到你没有?
这里就可以看VC给出的命令行了, 先看编译的参数,长长的一段,
/X /permissive- /GS- /GL /analyze- /W3 /Gy /Zc:wchar_t /I"D:\OrderSourceStudio\Lenix\Lenix\include"
/I"D:\OrderSourceStudio\Lenix\Lenix\include\c" /Zi /Gm- /O2 /sdl- /Fd"Release\vc142.pdb"
/Zc:inline /fp:precise /D "NDEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE"
/errorReport:prompt /WX- /Zc:forScope /arch:IA32 /Gd /Oy- /Oi /MD /FC /Fa"Release\" /EHsc
/nologo /Fo"Release\" /Fp"Release\lnxdbg.pch" /diagnostics:column
这链接参数,怎么样,这么长一段,看着都烦躁
/OUT:"D:\OrderSourceStudio\Project\lnxdbg\Release\lnxdbg.exe" /MANIFEST /LTCG:incremental
/NXCOMPAT /PDB:"D:\OrderSourceStudio\Project\lnxdbg\Release\lnxdbg.pdb" /DYNAMICBASE
"lenix.lib" "lnxc.lib" "libc.lib" "msvcrt.lib" /FIXED:NO /DEBUG /MACHINE:X86 /OPT:REF
/SAFESEH:NO /INCREMENTAL:NO /PGD:"D:\OrderSourceStudio\Project\lnxdbg\Release\lnxdbg.pgd"
/SUBSYSTEM:CONSOLE /MANIFESTUAC:"level='asInvoker' uiAccess='false'"
/ManifestFile:"Release\lnxdbg.exe.intermediate.manifest" /MAP /OPT:ICF /ERRORREPORT:PROMPT
/NOLOGO /LIBPATH:"D:\OrderSourceStudio\Project\LENIX\Release"
/LIBPATH:"D:\OrderSourceStudio\Lenix\Lenix\lib\c"
/LIBPATH:"D:\OrderSourceStudio\Lenix\Lenix\lib\vc" /NODEFAULTLIB /TLBID:1
其实VC也提供了make程序,只是它的名称是nmake。因此VC也可以用makefile来编译,挺好用的,不过嘛,在windows下编程,估计很少人会用到这个东西。