汇编:列出应用程序的所有符号

时间:2017-08-14 17:22:12

标签: assembly symbols

我编写了一个非常简单的代码:

// ConsoleApplication1.cpp
//
#include <iostream>
#include "stdafx.h"

void abc() {
    printf("ABCDEF");
}

int main()
{
    printf("Hello");
    printf("2ndString Here");
    return 0;
}

这是Windbg的结果:

0:000> x ConsoleApplication1!*
00007ff6`dc5335b0 ConsoleApplication1!__scrt_current_native_startup_state = initialized (0n2)
00007ff6`dc533008 ConsoleApplication1!__security_cookie_complement = 0xffff6a36`95faba8f
00007ff6`dc531e90 ConsoleApplication1!_guard_dispatch_icall_nop = 0xff ''
00007ff6`dc5321d0 ConsoleApplication1!__xp_a = <function> *[1]
00007ff6`dc532650 ConsoleApplication1!__rtc_taa = <function> *[1]
00007ff6`dc532190 ConsoleApplication1!__guard_dispatch_icall_fptr = 0x00007ff6`dc531e90
00007ff6`dc532640 ConsoleApplication1!__rtc_iaa = <function> *[1]
00007ff6`dc5335d8 ConsoleApplication1!module_local_at_quick_exit_table = struct _onexit_table_t
00007ff6`dc532198 ConsoleApplication1!__xc_a = <function> *[1]
00007ff6`dc532198 ConsoleApplication1!__xc_a = <function> *[]
00007ff6`dc533030 ConsoleApplication1!__scrt_ucrt_dll_is_in_use = 0n1
00007ff6`dc533030 ConsoleApplication1!__scrt_ucrt_dll_is_in_use = 0n1
00007ff6`dc5321b8 ConsoleApplication1!pre_c_initializer = 0x00007ff6`dc531154
00007ff6`dc533020 ConsoleApplication1!__memcpy_nt_iters = 0n-1
00007ff6`dc5321a0 ConsoleApplication1!pre_cpp_initializer = 0x00007ff6`dc531220
00007ff6`dc533630 ConsoleApplication1!__dyn_tls_init_callback = 0x00000000`00000000
00007ff6`dc5321c8 ConsoleApplication1!__xi_z = <function> *[1]
00007ff6`dc5321c8 ConsoleApplication1!__xi_z = <function> *[]
00007ff6`dc5335c0 ConsoleApplication1!module_local_atexit_table = struct _onexit_table_t
00007ff6`dc5330e0 ConsoleApplication1!GS_ContextRecord = struct _CONTEXT
00007ff6`dc5321e0 ConsoleApplication1!__xt_a = <function> *[1]
00007ff6`dc533618 ConsoleApplication1!__scrt_debugger_hook_flag = 0n0
00007ff6`dc5335f0 ConsoleApplication1!is_initialized_as_dll = false
00007ff6`dc53301c ConsoleApplication1!__isa_enabled = 0n46
00007ff6`dc5335b8 ConsoleApplication1!__scrt_native_startup_lock = 0x00000000`00000000
00007ff6`dc5321c0 ConsoleApplication1!post_pgo_initializer = 0x00007ff6`dc531210
00007ff6`dc532188 ConsoleApplication1!__guard_check_icall_fptr = 0x00007ff6`dc531d58
00007ff6`dc532188 ConsoleApplication1!__guard_check_icall_fptr = 0x00007ff6`dc531d58
00007ff6`dc532188 ConsoleApplication1!__guard_check_icall_fptr = 0x00007ff6`dc531d58
00007ff6`dc532680 ConsoleApplication1!$xdatasym = 0x01 ''
00007ff6`dc532740 ConsoleApplication1!$xdatasym = 0x01 ''
00007ff6`dc5321b0 ConsoleApplication1!__xi_a = <function> *[1]
00007ff6`dc5321b0 ConsoleApplication1!__xi_a = <function> *[]
00007ff6`dc5321f0 ConsoleApplication1!GS_ExceptionPointers = struct _EXCEPTION_POINTERS
00007ff6`dc532648 ConsoleApplication1!__rtc_izz = <function> *[1]
00007ff6`dc5321a8 ConsoleApplication1!__xc_z = <function> *[1]
00007ff6`dc5321a8 ConsoleApplication1!__xc_z = <function> *[]
00007ff6`dc533014 ConsoleApplication1!__scrt_default_matherr = 0n1
00007ff6`dc533014 ConsoleApplication1!__scrt_default_matherr = 0n1
00007ff6`dc5321d8 ConsoleApplication1!__xp_z = <function> *[1]
00007ff6`dc532658 ConsoleApplication1!__rtc_tzz = <function> *[1]
00007ff6`dc533040 ConsoleApplication1!GS_ExceptionRecord = struct _EXCEPTION_RECORD
00007ff6`dc532290 ConsoleApplication1!_load_config_used = struct _IMAGE_LOAD_CONFIG_DIRECTORY64
00007ff6`dc533010 ConsoleApplication1!__scrt_native_dllmain_reason = 0xffffffff
00007ff6`dc533000 ConsoleApplication1!__security_cookie = 0x000095c9`6a054570
00007ff6`dc533018 ConsoleApplication1!__isa_available = 0n5
00007ff6`dc53361c ConsoleApplication1!__favor = 0n6
00007ff6`dc5321e8 ConsoleApplication1!__xt_z = <function> *[1]
00007ff6`dc533600 ConsoleApplication1!__type_info_root_node = struct __type_info_node
00007ff6`dc533628 ConsoleApplication1!__dyn_tls_dtor_callback = 0x00000000`00000000
00007ff6`dc5313c8 ConsoleApplication1!__raise_securityfailure (struct _EXCEPTION_POINTERS *)
00007ff6`dc5318a0 ConsoleApplication1!_get_startup_commit_mode (void)
00007ff6`dc5318f8 ConsoleApplication1!__scrt_get_dyn_tls_dtor_callback (void)
00007ff6`dc531e90 ConsoleApplication1!_guard_dispatch_icall_nop (void)
00007ff6`dc531010 ConsoleApplication1!_vfprintf_l (struct _iobuf *, char *, struct __crt_locale_pointers *, char *)
00007ff6`dc531ae4 ConsoleApplication1!_RTC_Initialize (void)
00007ff6`dc5318a0 ConsoleApplication1!_get_startup_thread_locale_mode (void)
00007ff6`dc531d4c ConsoleApplication1!__scrt_is_ucrt_dll_in_use (void)
00007ff6`dc5310e0 ConsoleApplication1!main (void)
00007ff6`dc531758 ConsoleApplication1!__scrt_uninitialize_crt (bool, bool)
00007ff6`dc531e1c ConsoleApplication1!__GSHandlerCheckCommon (void *, struct _DISPATCHER_CONTEXT *, struct _GS_HANDLER_DATA *)
00007ff6`dc531698 ConsoleApplication1!__scrt_is_nonwritable_in_current_image (void *)
00007ff6`dc531580 ConsoleApplication1!__scrt_initialize_crt (__scrt_module_type)
00007ff6`dc531a9c ConsoleApplication1!__scrt_set_unhandled_exception_filter (void)
00007ff6`dc531d58 ConsoleApplication1!_initialize_denormal_control (void)
00007ff6`dc5317d4 ConsoleApplication1!atexit (<function> *)
00007ff6`dc5318bc ConsoleApplication1!__scrt_stub_for_acrt_initialize (void)
00007ff6`dc531b30 ConsoleApplication1!_RTC_Terminate (void)
00007ff6`dc531dfc ConsoleApplication1!__GSHandlerCheck (struct _EXCEPTION_RECORD *, void *, struct _CONTEXT *, struct _DISPATCHER_CONTEXT *)
00007ff6`dc5318a4 ConsoleApplication1!_get_startup_file_mode (void)
00007ff6`dc5313b4 ConsoleApplication1!mainCRTStartup (void)
00007ff6`dc531060 ConsoleApplication1!printf (char *)
00007ff6`dc5318c8 ConsoleApplication1!__scrt_initialize_default_local_stdio_options (void)
00007ff6`dc5315cc ConsoleApplication1!__scrt_initialize_onexit_tables (__scrt_module_type)
00007ff6`dc531eb0 ConsoleApplication1!__scrt_is_nonwritable_in_current_image$filt$0 (void)
00007ff6`dc5318bc ConsoleApplication1!_should_initialize_environment (void)
00007ff6`dc531154 ConsoleApplication1!pre_c_initialization (void)
00007ff6`dc5318a0 ConsoleApplication1!_matherr (struct _exception *)
00007ff6`dc531544 ConsoleApplication1!__scrt_acquire_startup_lock (void)
00007ff6`dc5318a0 ConsoleApplication1!_get_startup_new_mode (void)
00007ff6`dc531a48 ConsoleApplication1!__scrt_is_managed_app (void)
00007ff6`dc531aac ConsoleApplication1!__scrt_unhandled_exception_filter (struct _EXCEPTION_POINTERS *)
00007ff6`dc531d58 ConsoleApplication1!_initialize_invalid_parameter_handler (void)
00007ff6`dc531b84 ConsoleApplication1!__isa_available_init (void)
00007ff6`dc5318e4 ConsoleApplication1!__scrt_is_user_matherr_present (void)
00007ff6`dc531898 ConsoleApplication1!_get_startup_argv_mode (void)
00007ff6`dc531130 ConsoleApplication1!__security_check_cookie (void)
00007ff6`dc5314d0 ConsoleApplication1!capture_previous_context (struct _CONTEXT *)
00007ff6`dc531220 ConsoleApplication1!pre_cpp_initialization (void)
00007ff6`dc5318f0 ConsoleApplication1!__scrt_get_dyn_tls_init_callback (void)
00007ff6`dc531d58 ConsoleApplication1!_guard_check_icall_nop (unsigned int64)
00007ff6`dc5318bc ConsoleApplication1!__scrt_stub_for_acrt_uninitialize (bool)
00007ff6`dc53123c ConsoleApplication1!__scrt_common_main_seh (void)
00007ff6`dc5318ac ConsoleApplication1!__scrt_initialize_type_info (void)
00007ff6`dc531734 ConsoleApplication1!__scrt_release_startup_lock (bool)
00007ff6`dc531110 ConsoleApplication1!__vcrt_va_start_verify_argument_type<char const * __ptr64 const> (void)
00007ff6`dc531900 ConsoleApplication1!__scrt_fastfail (unsigned int)
00007ff6`dc531e92 ConsoleApplication1!`__scrt_common_main_seh'::`1'::filt$0 (void)
00007ff6`dc5318c0 ConsoleApplication1!__local_stdio_scanf_options (void)
00007ff6`dc5317ec ConsoleApplication1!__security_init_cookie (void)
00007ff6`dc531b7c ConsoleApplication1!_guard_check_icall (unsigned int64)
00007ff6`dc5313fc ConsoleApplication1!__report_gsfailure (unsigned int64)
00007ff6`dc531000 ConsoleApplication1!__local_stdio_printf_options (void)
00007ff6`dc531784 ConsoleApplication1!_onexit (<function> *)
00007ff6`dc531210 ConsoleApplication1!post_pgo_initialization (void)
00007ff6`dc5318a0 ConsoleApplication1!__scrt_initialize_winrt (void)
00007ff6`dc532138 ConsoleApplication1!_imp__get_initial_narrow_environment = <no type information>
00007ff6`dc532038 ConsoleApplication1!_imp_GetCurrentThreadId = <no type information>
00007ff6`dc531d7e ConsoleApplication1!configure_narrow_argv (<no parameter info>)
00007ff6`dc531dc0 ConsoleApplication1!c_exit (<no parameter info>)
00007ff6`dc531d9c ConsoleApplication1!exit (<no parameter info>)
00007ff6`dc5320e8 ConsoleApplication1!_imp__seh_filter_exe = <no type information>
00007ff6`dc5320f0 ConsoleApplication1!_imp__crt_atexit = <no type information>
00007ff6`dc5320d8 ConsoleApplication1!_imp_terminate = <no type information>
00007ff6`dc532128 ConsoleApplication1!_imp__initterm_e = <no type information>
00007ff6`dc532158 ConsoleApplication1!api-ms-win-crt-runtime-l1-1-0_NULL_THUNK_DATA = <no type information>
00007ff6`dc5320d0 ConsoleApplication1!_imp__initialize_onexit_table = <no type information>
00007ff6`dc5320a0 ConsoleApplication1!api-ms-win-crt-heap-l1-1-0_NULL_THUNK_DATA = <no type information>
00007ff6`dc531d78 ConsoleApplication1!_setusermatherr (<no parameter info>)
00007ff6`dc531df6 ConsoleApplication1!IsProcessorFeaturePresent (<no parameter info>)
00007ff6`dc532180 ConsoleApplication1!api-ms-win-crt-stdio-l1-1-0_NULL_THUNK_DATA = <no type information>
00007ff6`dc532080 ConsoleApplication1!_imp_memset = <no type information>
00007ff6`dc531d90 ConsoleApplication1!initterm (<no parameter info>)
00007ff6`dc531da2 ConsoleApplication1!exit (<no parameter info>)
00007ff6`dc532010 ConsoleApplication1!_imp_UnhandledExceptionFilter = <no type information>
00007ff6`dc531d60 ConsoleApplication1!_C_specific_handler (<no parameter info>)
00007ff6`dc532178 ConsoleApplication1!_imp__set_fmode = <no type information>
00007ff6`dc532100 ConsoleApplication1!_imp___p___argv = <no type information>
00007ff6`dc531dba ConsoleApplication1!cexit (<no parameter info>)
00007ff6`dc531df0 ConsoleApplication1!terminate (<no parameter info>)
00007ff6`dc531dcc ConsoleApplication1!configthreadlocale (<no parameter info>)
00007ff6`dc532788 ConsoleApplication1!_IMPORT_DESCRIPTOR_api-ms-win-crt-math-l1-1-0 = <no type information>
00007ff6`dc532120 ConsoleApplication1!_imp_exit = <no type information>
00007ff6`dc531dc6 ConsoleApplication1!register_thread_local_exe_atexit_callback (<no parameter info>)
00007ff6`dc532060 ConsoleApplication1!_imp_GetCurrentProcess = <no type information>
00007ff6`dc532088 ConsoleApplication1!_imp___C_specific_handler = <no type information>
00007ff6`dc532070 ConsoleApplication1!_imp_RtlCaptureContext = <no type information>
00007ff6`dc532078 ConsoleApplication1!KERNEL32_NULL_THUNK_DATA = <no type information>
00007ff6`dc531d84 ConsoleApplication1!initialize_narrow_environment (<no parameter info>)
00007ff6`dc5320b8 ConsoleApplication1!_imp___setusermatherr = <no type information>
00007ff6`dc532040 ConsoleApplication1!_imp_GetCurrentProcessId = <no type information>
00007ff6`dc53279c ConsoleApplication1!_IMPORT_DESCRIPTOR_api-ms-win-crt-locale-l1-1-0 = <no type information>
00007ff6`dc531dde ConsoleApplication1!initialize_onexit_table (<no parameter info>)
00007ff6`dc532108 ConsoleApplication1!_imp___p___argc = <no type information>
00007ff6`dc532050 ConsoleApplication1!_imp_IsProcessorFeaturePresent = <no type information>
00007ff6`dc5320b0 ConsoleApplication1!api-ms-win-crt-locale-l1-1-0_NULL_THUNK_DATA = <no type information>
00007ff6`dc532130 ConsoleApplication1!_imp__initterm = <no type information>
00007ff6`dc532760 ConsoleApplication1!_IMPORT_DESCRIPTOR_api-ms-win-crt-stdio-l1-1-0 = <no type information>
00007ff6`dc5327b0 ConsoleApplication1!_IMPORT_DESCRIPTOR_api-ms-win-crt-heap-l1-1-0 = <no type information>
00007ff6`dc532118 ConsoleApplication1!_imp__exit = <no type information>
00007ff6`dc532058 ConsoleApplication1!_imp_TerminateProcess = <no type information>
00007ff6`dc531de4 ConsoleApplication1!register_onexit_function (<no parameter info>)
00007ff6`dc532020 ConsoleApplication1!_imp_IsDebuggerPresent = <no type information>
00007ff6`dc531dae ConsoleApplication1!_p___argc (<no parameter info>)
00007ff6`dc532110 ConsoleApplication1!_imp__register_thread_local_exe_atexit_callback = <no type information>
00007ff6`dc532090 ConsoleApplication1!VCRUNTIME140_NULL_THUNK_DATA = <no type information>
00007ff6`dc532168 ConsoleApplication1!_imp___stdio_common_vfprintf = <no type information>
00007ff6`dc532170 ConsoleApplication1!_imp___acrt_iob_func = <no type information>
00007ff6`dc532030 ConsoleApplication1!_imp_GetSystemTimeAsFileTime = <no type information>
00007ff6`dc5320e0 ConsoleApplication1!_imp__set_app_type = <no type information>
00007ff6`dc531dd2 ConsoleApplication1!set_new_mode (<no parameter info>)
00007ff6`dc5320a8 ConsoleApplication1!_imp__configthreadlocale = <no type information>
00007ff6`dc532000 ConsoleApplication1!_imp_RtlLookupFunctionEntry = <no type information>
00007ff6`dc532048 ConsoleApplication1!_imp_QueryPerformanceCounter = <no type information>
00007ff6`dc531dd8 ConsoleApplication1!_p__commode (<no parameter info>)
00007ff6`dc532140 ConsoleApplication1!_imp__initialize_narrow_environment = <no type information>
00007ff6`dc532028 ConsoleApplication1!_imp_InitializeSListHead = <no type information>
00007ff6`dc532008 ConsoleApplication1!_imp_RtlVirtualUnwind = <no type information>
00007ff6`dc533620 ConsoleApplication1!`__local_stdio_printf_options'::`2'::_OptionsStorage = <no type information>
00007ff6`dc532018 ConsoleApplication1!_imp_GetModuleHandleW = <no type information>
00007ff6`dc531d96 ConsoleApplication1!initterm_e (<no parameter info>)
00007ff6`dc5320c0 ConsoleApplication1!api-ms-win-crt-math-l1-1-0_NULL_THUNK_DATA = <no type information>
00007ff6`dc531d6c ConsoleApplication1!seh_filter_exe (<no parameter info>)
00007ff6`dc532098 ConsoleApplication1!_imp__set_new_mode = <no type information>
00007ff6`dc532774 ConsoleApplication1!_IMPORT_DESCRIPTOR_api-ms-win-crt-runtime-l1-1-0 = <no type information>
00007ff6`dc531db4 ConsoleApplication1!_p___argv (<no parameter info>)
00007ff6`dc531d8a ConsoleApplication1!get_initial_narrow_environment (<no parameter info>)
00007ff6`dc532068 ConsoleApplication1!_imp_SetUnhandledExceptionFilter = <no type information>
00007ff6`dc5327c4 ConsoleApplication1!_IMPORT_DESCRIPTOR_KERNEL32 = <no type information>
00007ff6`dc532160 ConsoleApplication1!_imp___p__commode = <no type information>
00007ff6`dc5320f8 ConsoleApplication1!_imp__cexit = <no type information>
00007ff6`dc531da8 ConsoleApplication1!set_fmode (<no parameter info>)
00007ff6`dc532150 ConsoleApplication1!_imp__register_onexit_function = <no type information>
00007ff6`dc531dea ConsoleApplication1!crt_atexit (<no parameter info>)
00007ff6`dc53274c ConsoleApplication1!_IMPORT_DESCRIPTOR_VCRUNTIME140 = <no type information>
00007ff6`dc532148 ConsoleApplication1!_imp__configure_narrow_argv = <no type information>
00007ff6`dc5320c8 ConsoleApplication1!_imp__c_exit = <no type information>
00007ff6`dc531d72 ConsoleApplication1!set_app_type (<no parameter info>)
00007ff6`dc531d66 ConsoleApplication1!memset (<no parameter info>)
00007ff6`dc5327d8 ConsoleApplication1!_NULL_IMPORT_DESCRIPTOR = <no type information>
00007ff6`dc533610 ConsoleApplication1!`__local_stdio_scanf_options'::`2'::_OptionsStorage = <no type information>
00007ff6`dc531337 ConsoleApplication1!invoke_main =  (inline caller) ConsoleApplication1!__scrt_common_main_seh+fb
00007ff6`dc53119e ConsoleApplication1!__scrt_narrow_argv_policy::configure_argv =  (inline caller) ConsoleApplication1!pre_c_initialization+4a
00007ff6`dc5311e7 ConsoleApplication1!initialize_environment =  (inline caller) ConsoleApplication1!pre_c_initialization+93
00007ff6`dc5313b8 ConsoleApplication1!__scrt_common_main =  (inline caller) ConsoleApplication1!mainCRTStartup+4
00007ff6`dc531551 ConsoleApplication1!NtCurrentTeb =  (inline caller) ConsoleApplication1!__scrt_acquire_startup_lock+d
00007ff6`dc531618 ConsoleApplication1!__crt_fast_encode_pointer =  (inline caller) ConsoleApplication1!__scrt_initialize_onexit_tables+4c
00007ff6`dc53161f ConsoleApplication1!__crt_rotate_pointer_value =  (inline caller) ConsoleApplication1!__scrt_initialize_onexit_tables+53
00007ff6`dc53169f ConsoleApplication1!is_potentially_valid_image_base =  (inline caller) ConsoleApplication1!__scrt_is_nonwritable_in_current_image+7
00007ff6`dc5316d5 ConsoleApplication1!find_pe_section =  (inline caller) ConsoleApplication1!__scrt_is_nonwritable_in_current_image+3d
00007ff6`dc53178a ConsoleApplication1!__crt_fast_decode_pointer =  (inline caller) ConsoleApplication1!_onexit+6
00007ff6`dc5317a0 ConsoleApplication1!__crt_rotate_pointer_value =  (inline caller) ConsoleApplication1!_onexit+1c
00007ff6`dc531929 ConsoleApplication1!__crt_debugger_hook =  (inline caller) ConsoleApplication1!__scrt_fastfail+29

符号列表是什么意思?是什么产生了符号?每个方法?类?为什么没有ConsoleApplication1!abc可用?

还有大量其他符号..它们是否可以分离和分类(例如mainCRTStartup和ConsoleApplication1!main属于可执行文件)? 内核编程有区别吗?

(停用代码优化。)

1 个答案:

答案 0 :(得分:0)

  

符号列表是什么意思?

符号列表是&#34;符号列表&#34;在文件中 - 当然。

&#34;符号&#34;目标文件中具有地址的项目(或 - 有时 - 绝对值)。

符号的主要用途是告诉链接器某个项(函数,变量,常量......)位于目标文件中的位置:

当某些机器代码访问变量或调用函数时,代码必须&#34;知道&#34;变量或函数的地址。从源代码创建目标文件时,这些地址尚不清楚;特别是如果函数或变量在另一个目标文件中定义,而不是访问它的代码。

因此,在创建目标文件时使用虚拟地址;链接器后来必须用真实地址替换虚拟地址。

有关哪个变量位于哪个地址的信息存储在&#34;符号&#34;一个目标文件。

.EXE文件的符号通常只是用于创建该文件的所有目标文件的所有符号的总和。

  

什么产生符号?

可以从其他目标文件访问的目标文件中定义的所有代码(函数)和所有数据(变量,常量)肯定会在目标文件中生成符号。

但是,某些链接器会从生成的.EXE文件中删除部分或全部符号,因为在创建.EXE文件后不再需要它们。

大多数编译器还为代码和数据生成符号,这些符号只能在目标文件中访问(例如&#34;静态&#34;变量)。

许多编译器生成包含调试信息的符号。当然,链接器会忽略这些符号 - 它们通常不会在windbg中显示。

内存中没有地址的项目通常没有符号:数据类型(包括类!)没有地址,但具有该数据类型的每个变量都有自己的地址。局部变量也是如此(考虑一个递归调用自身的函数来理解原因)。

  

为什么没有ConsoleApplication1!abc可用?

显然,您使用的链接器可以进行优化:

链接器&#34;看到&#34;没有&#34;虚拟地址&#34; (如上所述)必须由地址ConsoleApplication1!abc替换。因此,链接器&#34;知道&#34;函数abc()未被程序使用,因此它没有将该函数包含在程序中。

请注意,这不适用于所有目标文件格式。