L8__ioinit
00000000000011a0 l F .text 000000000000004d _Z41__static_initialization_and_destruction_0ii
00000000000011ed l F .text 0000000000000019 _GLOBAL__sub_I_main
0000000000000000 l df *ABS* 0000000000000000 crtstuff.c
00000000000021cc l O .eh_frame 0000000000000000 __FRAME_END__
0000000000000000 l df *ABS* 0000000000000000
0000000000002008 l .eh_frame_hdr 0000000000000000 __GNU_EH_FRAME_HDR
0000000000001000 l F .init 0000000000000000 _init
0000000000003da8 l O .dynamic 0000000000000000 _DYNAMIC
0000000000003da0 l .init_array 0000000000000000 __init_array_end
0000000000003d90 l .init_array 0000000000000000 __init_array_start
0000000000003fa8 l O .got 0000000000000000 _GLOBAL_OFFSET_TABLE_
0000000000004010 g .data 0000000000000000 _edata
0000000000001206 w F .text 0000000000000017 _Z7compareIiEbT_S0_ //此处为compare的函数符号
0000000000004000 w .data 0000000000000000 data_start
0000000000002000 g O .rodata 0000000000000004 _IO_stdin_used
0000000000000000 w F *UND* 0000000000000000 __cxa_finalize@@GLIBC_2.2.5
0000000000001169 g F .text 0000000000000037 main
0000000000004008 g O .data 0000000000000000 .hidden __dso_handle
0000000000001298 g F .fini 0000000000000000 .hidden _fini
0000000000000000 F *UND* 0000000000000000 __cxa_atexit@@GLIBC_2.2.5
0000000000001080 g F .text 000000000000002f _start
0000000000004010 g O .data 0000000000000000 .hidden __TMC_END__
0000000000004000 g .data 0000000000000000 __data_start
0000000000004018 g .bss 0000000000000000 _end
0000000000004010 g .bss 0000000000000000 __bss_start
0000000000000000 F *UND* 0000000000000000 _ZNSt8ios_base4InitC1Ev@@GLIBCXX_3.4
0000000000001220 g F .text 0000000000000065 __libc_csu_init
0000000000000000 w *UND* 0000000000000000 _ITM_deregisterTMCloneTable
0000000000001290 g F .text 0000000000000005 __libc_csu_fini
0000000000000000 F *UND* 0000000000000000 __libc_start_main@@GLIBC_2.2.5
0000000000000000 w *UND* 0000000000000000 __gmon_start__
0000000000000000 w *UND* 0000000000000000 _ITM_registerTMCloneTable
0000000000000000 F *UND* 0000000000000000 _ZNSt8ios_base4InitD1Ev@@GLIBCXX_3.4
示例代码5 实例化2次模板 两次模板的参数类型不一样 并查看编译后.o文件中的 符号表情况
点击查看代码
#include <iostream>
using namespace std;
template<typename T>
bool compare(T x,T y){
return x,y;
}
int main(){
bool b =compare<int>(100,200);
bool b2=compare(400,200);
bool b3=compare<double>(1.0,2.0);
return 1;
}
//编译生成.o文件,查看其中的符号表信息, 在其中找到了两处处compare函数的符号表,一次是int 一次是double
kl@kl-ThinkPad-T580:/data/usershare/code/compile$ g++ TemplateTest1.cpp -o test1.o
kl@kl-ThinkPad-T580:/data/usershare/code/compile$ objdump -t test1.o
test1.o: 文件格式 elf64-x86-64
SYMBOL TABLE:
0000000000000318 l d .interp 0000000000000000 .interp
0000000000000338 l d .note.gnu.property 0000000000000000 .note.gnu.property
0000000000000358 l d .note.gnu.build-id 0000000000000000 .note.gnu.build-id
000000000000037c l d .note.ABI-tag 0000000000000000 .note.ABI-tag
00000000000003a0 l d .gnu.hash 0000000000000000 .gnu.hash
00000000000003c8 l d .dynsym 0000000000000000 .dynsym
00000000000004a0 l d .dynstr 0000000000000000 .dynstr
0000000000000576 l d .gnu.version 0000000000000000 .gnu.version
0000000000000588 l d .gnu.version_r 0000000000000000 .gnu.version_r
00000000000005c8 l d .rela.dy