0000000000601078 B __bss_start 0000000000601078 b completed.6355 0000000000601040 D __data_start 0000000000601040 W data_start 0000000000400580 t deregister_tm_clones 00000000004005f0 t __do_global_dtors_aux 0000000000600e08 t __do_global_dtors_aux_fini_array_entry 0000000000400738 R __dso_handle 0000000000600e18 d _DYNAMIC 0000000000601078 D _edata 0000000000601080 B _end 0000000000400724 T _fini 0000000000400610 t frame_dummy 0000000000600e00 t __frame_dummy_init_array_entry 00000000004008a0 r __FRAME_END__ 0000000000601074 D gData /home/yu.tian/studyCode/main.c:10 0000000000601000 d _GLOBAL_OFFSET_TABLE_ 0000000000601050 D globalPStr /home/yu.tian/studyCode/main.c:8 0000000000601060 D globalStr /home/yu.tian/studyCode/main.c:9 w __gmon_start__ 000000000060107c B gNoData /home/yu.tian/studyCode/main.c:11 000000000040077c r __GNU_EH_FRAME_HDR 00000000004004e0 T _init 0000000000600e08 t __init_array_end 0000000000600e00 t __init_array_start 0000000000400730 R _IO_stdin_used 0000000000600e10 d __JCR_END__ 0000000000600e10 d __JCR_LIST__ 0000000000400720 T __libc_csu_fini 00000000004006b0 T __libc_csu_init U __libc_start_main@@GLIBC_2.2.5 000000000040063d T main /home/yu.tian/studyCode/main.c:14 U printf@@GLIBC_2.2.5 00000000004005b0 t register_tm_clones 0000000000400550 T _start 0000000000601078 D __TMC_END__
[root@VM_0_4_centos studyCode]# nm main -n U add w __gmon_start__ U __libc_start_main@@GLIBC_2.2.5 U printf@@GLIBC_2.2.5 00000000004004e0 T _init 0000000000400550 T _start 0000000000400580 t deregister_tm_clones 00000000004005b0 t register_tm_clones 00000000004005f0 t __do_global_dtors_aux 0000000000400610 t frame_dummy 000000000040063d T main 00000000004006b0 T __libc_csu_init 0000000000400720 T __libc_csu_fini 0000000000400724 T _fini 0000000000400730 R _IO_stdin_used 0000000000400738 R __dso_handle 000000000040077c r __GNU_EH_FRAME_HDR 00000000004008a0 r __FRAME_END__ 0000000000600e00 t __frame_dummy_init_array_entry 0000000000600e00 t __init_array_start 0000000000600e08 t __do_global_dtors_aux_fini_array_entry 0000000000600e08 t __init_array_end 0000000000600e10 d __JCR_END__ 0000000000600e10 d __JCR_LIST__ 0000000000600e18 d _DYNAMIC 0000000000601000 d _GLOBAL_OFFSET_TABLE_ 0000000000601040 D __data_start 0000000000601040 W data_start 0000000000601050 D globalPStr 0000000000601060 D globalStr 0000000000601074 D gData 0000000000601078 B __bss_start 0000000000601078 b completed.6355 0000000000601078 D _edata 0000000000601078 D __TMC_END__ 000000000060107c B gNoData 0000000000601080 B _end
[root@VM_0_4_centos studyCode]# nm libadd.so 0000000000201028 B __bss_start 0000000000201028 b completed.6355 w __cxa_finalize@@GLIBC_2.2.5 0000000000000580 t deregister_tm_clones 00000000000005f0 t __do_global_dtors_aux 0000000000200e00 t __do_global_dtors_aux_fini_array_entry 0000000000200e10 d __dso_handle 0000000000200e18 d _DYNAMIC 0000000000201028 D _edata 0000000000201030 B _end 000000000000067c T _fini 0000000000000630 t frame_dummy 0000000000200df8 t __frame_dummy_init_array_entry 0000000000000708 r __FRAME_END__ 0000000000201000 d _GLOBAL_OFFSET_TABLE_ w __gmon_start__ 0000000000000688 r __GNU_EH_FRAME_HDR 0000000000000528 T _init w _ITM_deregisterTMCloneTable w _ITM_registerTMCloneTable 0000000000200e08 d __JCR_END__ 0000000000200e08 d __JCR_LIST__ w _Jv_RegisterClasses 00000000000005b0 t register_tm_clones 0000000000201028 d __TMC_END__ 0000000000000665 T _Z3addii
0000000000201028 B __bss_start 0000000000201028 b completed.6355 w __cxa_finalize@@GLIBC_2.2.5 0000000000000580 t deregister_tm_clones 00000000000005f0 t __do_global_dtors_aux 0000000000200e00 t __do_global_dtors_aux_fini_array_entry 0000000000200e10 d __dso_handle 0000000000200e18 d _DYNAMIC 0000000000201028 D _edata 0000000000201030 B _end 000000000000067c T _fini 0000000000000630 t frame_dummy 0000000000200df8 t __frame_dummy_init_array_entry 0000000000000708 r __FRAME_END__ 0000000000201000 d _GLOBAL_OFFSET_TABLE_ w __gmon_start__ 0000000000000688 r __GNU_EH_FRAME_HDR 0000000000000528 T _init w _ITM_deregisterTMCloneTable w _ITM_registerTMCloneTable 0000000000200e08 d __JCR_END__ 0000000000200e08 d __JCR_LIST__ w _Jv_RegisterClasses 00000000000005b0 t register_tm_clones 0000000000201028 d __TMC_END__ 0000000000000665 T add(int, int)
可以发现add这个函数,由于c++加入的一些前缀,变成了参数
-u和-D参数的对比
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
[root@VM_0_4_centos studyCode]# nm main -u U add w __gmon_start__ U __libc_start_main@@GLIBC_2.2.5 U printf@@GLIBC_2.2.5 [root@VM_0_4_centos studyCode]# nm main -D U add 0000000000601078 B __bss_start 0000000000601078 D _edata 0000000000601080 B _end 0000000000400724 T _fini w __gmon_start__ 00000000004004e0 T _init U __libc_start_main U printf