我是这里的初学者。所以我有一个main文件,看起来像这样
#include <iostream>
#include "Helper.hpp"
using namespace std;
int main(int argc, char* argv[])
{
cout<<argc<<endl;
return 0;
}
,我把它链接到另外两个。cpp我只是想知道为什么可执行文件这么大(330kb)当main函数甚至不调用任何函数时。我的其他2 .cpp中的所有方法和变量都包装在可执行文件中吗我实际上没有调用任何函数?我只声明了1个extern int。无静态函数
这是我用来编译
的makefile调用CXX=g++
CXXFLAGS =-Wall -pedantic -g -O0 -std=c++11
test: Helper.cpp Helper.hpp HCTree.cpp HCTree.hpp
$(CXX) $(CXXFLAGS) -o test test.cpp Helper.cpp HCTree.cpp
和我调用"make test">
原因是您的二进制文件将包括部分标准库和符号映射,即使您像下面这样编译极端琐碎的情况:
main.cpp
using namespace std;
int main(int argc, char* argv[])
{
return 0;
}
~# g++ -Wall -pedantic -g -O0 -std=c++11 -o test main.cpp
~# ls -ltr
-rwxrwxr-x 1 jordan jordan 10264 Mar 1 08:14 test
编译后,我的二进制文件大约是10k。如果您正在为linux编译它,您可以通过调用readelf -a
或使用nm
检查文件中的符号来查看二进制文件中的内容。
~# readelf -a test
ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: DYN (Shared object file)
Machine: AArch64
Version: 0x1
Entry point address: 0x610
Start of program headers: 64 (bytes into file)
Start of section headers: 8152 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 9
Size of section headers: 64 (bytes)
Number of section headers: 33
Section header string table index: 32
Section Headers:
[Nr] Name Type Address Offset
Size EntSize Flags Link Info Align
[ 0] NULL 0000000000000000 00000000
0000000000000000 0000000000000000 0 0 0
[ 1] .interp PROGBITS 0000000000000238 00000238
000000000000001b 0000000000000000 A 0 0 1
[ 2] .note.gnu.build-i NOTE 0000000000000254 00000254
0000000000000024 0000000000000000 A 0 0 4
[ 3] .note.ABI-tag NOTE 0000000000000278 00000278
0000000000000020 0000000000000000 A 0 0 4
[ 4] .gnu.hash GNU_HASH 0000000000000298 00000298
000000000000001c 0000000000000000 A 5 0 8
[ 5] .dynsym DYNSYM 00000000000002b8 000002b8
00000000000000d8 0000000000000018 A 6 3 8
[ 6] .dynstr STRTAB 0000000000000390 00000390
0000000000000082 0000000000000000 A 0 0 1
[ 7] .gnu.version VERSYM 0000000000000412 00000412
0000000000000012 0000000000000002 A 5 0 2
[ 8] .gnu.version_r VERNEED 0000000000000428 00000428
0000000000000020 0000000000000000 A 6 1 8
[ 9] .rela.dyn RELA 0000000000000448 00000448
00000000000000f0 0000000000000018 A 5 0 8
[10] .rela.plt RELA 0000000000000538 00000538
0000000000000060 0000000000000018 AI 5 21 8
[11] .init PROGBITS 0000000000000598 00000598
0000000000000014 0000000000000000 AX 0 0 4
[12] .plt PROGBITS 00000000000005b0 000005b0
0000000000000060 0000000000000010 AX 0 0 16
[13] .text PROGBITS 0000000000000610 00000610
00000000000001ac 0000000000000000 AX 0 0 8
[14] .fini PROGBITS 00000000000007bc 000007bc
0000000000000010 0000000000000000 AX 0 0 4
[15] .rodata PROGBITS 00000000000007cc 000007cc
0000000000000004 0000000000000004 AM 0 0 4
[16] .eh_frame_hdr PROGBITS 00000000000007d0 000007d0
0000000000000044 0000000000000000 A 0 0 4
[17] .eh_frame PROGBITS 0000000000000818 00000818
00000000000000dc 0000000000000000 A 0 0 8
[18] .init_array INIT_ARRAY 0000000000010d88 00000d88
0000000000000008 0000000000000008 WA 0 0 8
[19] .fini_array FINI_ARRAY 0000000000010d90 00000d90
0000000000000008 0000000000000008 WA 0 0 8
[20] .dynamic DYNAMIC 0000000000010d98 00000d98
00000000000001f0 0000000000000010 WA 6 0 8
[21] .got PROGBITS 0000000000010f88 00000f88
0000000000000078 0000000000000008 WA 0 0 8
[22] .data PROGBITS 0000000000011000 00001000
0000000000000010 0000000000000000 WA 0 0 8
[23] .bss NOBITS 0000000000011010 00001010
0000000000000008 0000000000000000 WA 0 0 1
[24] .comment PROGBITS 0000000000000000 00001010
000000000000002a 0000000000000001 MS 0 0 1
[25] .debug_aranges PROGBITS 0000000000000000 0000103a
0000000000000030 0000000000000000 0 0 1
[26] .debug_info PROGBITS 0000000000000000 0000106a
0000000000000098 0000000000000000 0 0 1
[27] .debug_abbrev PROGBITS 0000000000000000 00001102
0000000000000078 0000000000000000 0 0 1
[28] .debug_line PROGBITS 0000000000000000 0000117a
0000000000000050 0000000000000000 0 0 1
[29] .debug_str PROGBITS 0000000000000000 000011ca
00000000000000bf 0000000000000001 MS 0 0 1
[30] .symtab SYMTAB 0000000000000000 00001290
0000000000000900 0000000000000018 31 73 8
[31] .strtab STRTAB 0000000000000000 00001b90
000000000000030d 0000000000000000 0 0 1
[32] .shstrtab STRTAB 0000000000000000 00001e9d
000000000000013a 0000000000000000 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
L (link order), O (extra OS processing required), G (group), T (TLS),
C (compressed), x (unknown), o (OS specific), E (exclude),
p (processor specific)
There are no section groups in this file.
Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
PHDR 0x0000000000000040 0x0000000000000040 0x0000000000000040
0x00000000000001f8 0x00000000000001f8 R 0x8
INTERP 0x0000000000000238 0x0000000000000238 0x0000000000000238
0x000000000000001b 0x000000000000001b R 0x1
[Requesting program interpreter: /lib/ld-linux-aarch64.so.1]
LOAD 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x00000000000008f4 0x00000000000008f4 R E 0x10000
LOAD 0x0000000000000d88 0x0000000000010d88 0x0000000000010d88
0x0000000000000288 0x0000000000000290 RW 0x10000
DYNAMIC 0x0000000000000d98 0x0000000000010d98 0x0000000000010d98
0x00000000000001f0 0x00000000000001f0 RW 0x8
NOTE 0x0000000000000254 0x0000000000000254 0x0000000000000254
0x0000000000000044 0x0000000000000044 R 0x4
GNU_EH_FRAME 0x00000000000007d0 0x00000000000007d0 0x00000000000007d0
0x0000000000000044 0x0000000000000044 R 0x4
GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 RW 0x10
GNU_RELRO 0x0000000000000d88 0x0000000000010d88 0x0000000000010d88
0x0000000000000278 0x0000000000000278 R 0x1
Section to Segment mapping:
Segment Sections...
00
01 .interp
02 .interp .note.gnu.build-id .note.ABI-tag .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rela.dyn .rela.plt .init .plt .text .fini .rodata .eh_frame_hdr .eh_frame
03 .init_array .fini_array .dynamic .got .data .bss
04 .dynamic
05 .note.gnu.build-id .note.ABI-tag
06 .eh_frame_hdr
07
08 .init_array .fini_array .dynamic .got
Dynamic section at offset 0xd98 contains 27 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x000000000000000c (INIT) 0x598
0x000000000000000d (FINI) 0x7bc
0x0000000000000019 (INIT_ARRAY) 0x10d88
0x000000000000001b (INIT_ARRAYSZ) 8 (bytes)
0x000000000000001a (FINI_ARRAY) 0x10d90
0x000000000000001c (FINI_ARRAYSZ) 8 (bytes)
0x000000006ffffef5 (GNU_HASH) 0x298
0x0000000000000005 (STRTAB) 0x390
0x0000000000000006 (SYMTAB) 0x2b8
0x000000000000000a (STRSZ) 130 (bytes)
0x000000000000000b (SYMENT) 24 (bytes)
0x0000000000000015 (DEBUG) 0x0
0x0000000000000003 (PLTGOT) 0x10f88
0x0000000000000002 (PLTRELSZ) 96 (bytes)
0x0000000000000014 (PLTREL) RELA
0x0000000000000017 (JMPREL) 0x538
0x0000000000000007 (RELA) 0x448
0x0000000000000008 (RELASZ) 240 (bytes)
0x0000000000000009 (RELAENT) 24 (bytes)
0x000000000000001e (FLAGS) BIND_NOW
0x000000006ffffffb (FLAGS_1) Flags: NOW PIE
0x000000006ffffffe (VERNEED) 0x428
0x000000006fffffff (VERNEEDNUM) 1
0x000000006ffffff0 (VERSYM) 0x412
0x000000006ffffff9 (RELACOUNT) 6
0x0000000000000000 (NULL) 0x0
Relocation section '.rela.dyn' at offset 0x448 contains 10 entries:
Offset Info Type Sym. Value Sym. Name + Addend
000000010d88 000000000403 R_AARCH64_RELATIV 718
000000010d90 000000000403 R_AARCH64_RELATIV 6d0
000000010fc8 000000000403 R_AARCH64_RELATIV 7b8
000000010fe8 000000000403 R_AARCH64_RELATIV 738
000000010ff0 000000000403 R_AARCH64_RELATIV 71c
000000011008 000000000403 R_AARCH64_RELATIV 11008
000000010fd0 000300000401 R_AARCH64_GLOB_DA 0000000000000000 _ITM_deregisterTMClone + 0
000000010fd8 000400000401 R_AARCH64_GLOB_DA 0000000000000000 __cxa_finalize@GLIBC_2.17 + 0
000000010fe0 000600000401 R_AARCH64_GLOB_DA 0000000000000000 __gmon_start__ + 0
000000010ff8 000800000401 R_AARCH64_GLOB_DA 0000000000000000 _ITM_registerTMCloneTa + 0
Relocation section '.rela.plt' at offset 0x538 contains 4 entries:
Offset Info Type Sym. Value Sym. Name + Addend
000000010fa0 000400000402 R_AARCH64_JUMP_SL 0000000000000000 __cxa_finalize@GLIBC_2.17 + 0
000000010fa8 000500000402 R_AARCH64_JUMP_SL 0000000000000000 __libc_start_main@GLIBC_2.17 + 0
000000010fb0 000600000402 R_AARCH64_JUMP_SL 0000000000000000 __gmon_start__ + 0
000000010fb8 000700000402 R_AARCH64_JUMP_SL 0000000000000000 abort@GLIBC_2.17 + 0
The decoding of unwind sections for machine type AArch64 is not currently supported.
Symbol table '.dynsym' contains 9 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
1: 0000000000000598 0 SECTION LOCAL DEFAULT 11
2: 0000000000011000 0 SECTION LOCAL DEFAULT 22
3: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _ITM_deregisterTMCloneTab
4: 0000000000000000 0 FUNC WEAK DEFAULT UND __cxa_finalize@GLIBC_2.17 (2)
5: 0000000000000000 0 FUNC GLOBAL DEFAULT UND __libc_start_main@GLIBC_2.17 (2)
6: 0000000000000000 0 NOTYPE WEAK DEFAULT UND __gmon_start__
7: 0000000000000000 0 FUNC GLOBAL DEFAULT UND abort@GLIBC_2.17 (2)
8: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _ITM_registerTMCloneTable
Symbol table '.symtab' contains 96 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
1: 0000000000000238 0 SECTION LOCAL DEFAULT 1
2: 0000000000000254 0 SECTION LOCAL DEFAULT 2
3: 0000000000000278 0 SECTION LOCAL DEFAULT 3
4: 0000000000000298 0 SECTION LOCAL DEFAULT 4
5: 00000000000002b8 0 SECTION LOCAL DEFAULT 5
6: 0000000000000390 0 SECTION LOCAL DEFAULT 6
7: 0000000000000412 0 SECTION LOCAL DEFAULT 7
8: 0000000000000428 0 SECTION LOCAL DEFAULT 8
9: 0000000000000448 0 SECTION LOCAL DEFAULT 9
10: 0000000000000538 0 SECTION LOCAL DEFAULT 10
11: 0000000000000598 0 SECTION LOCAL DEFAULT 11
12: 00000000000005b0 0 SECTION LOCAL DEFAULT 12
13: 0000000000000610 0 SECTION LOCAL DEFAULT 13
14: 00000000000007bc 0 SECTION LOCAL DEFAULT 14
15: 00000000000007cc 0 SECTION LOCAL DEFAULT 15
16: 00000000000007d0 0 SECTION LOCAL DEFAULT 16
17: 0000000000000818 0 SECTION LOCAL DEFAULT 17
18: 0000000000010d88 0 SECTION LOCAL DEFAULT 18
19: 0000000000010d90 0 SECTION LOCAL DEFAULT 19
20: 0000000000010d98 0 SECTION LOCAL DEFAULT 20
21: 0000000000010f88 0 SECTION LOCAL DEFAULT 21
22: 0000000000011000 0 SECTION LOCAL DEFAULT 22
23: 0000000000011010 0 SECTION LOCAL DEFAULT 23
24: 0000000000000000 0 SECTION LOCAL DEFAULT 24
25: 0000000000000000 0 SECTION LOCAL DEFAULT 25
26: 0000000000000000 0 SECTION LOCAL DEFAULT 26
27: 0000000000000000 0 SECTION LOCAL DEFAULT 27
28: 0000000000000000 0 SECTION LOCAL DEFAULT 28
29: 0000000000000000 0 SECTION LOCAL DEFAULT 29
30: 0000000000000000 0 FILE LOCAL DEFAULT ABS /usr/lib/gcc/aarch64-linu
31: 0000000000000278 0 NOTYPE LOCAL DEFAULT 3 $d
32: 0000000000000610 0 NOTYPE LOCAL DEFAULT 13 $x
33: 00000000000007cc 0 NOTYPE LOCAL DEFAULT 15 $d
34: 0000000000000000 0 FILE LOCAL DEFAULT ABS /usr/lib/gcc/aarch64-linu
35: 0000000000000648 0 NOTYPE LOCAL DEFAULT 13 $x
36: 0000000000000648 20 FUNC LOCAL DEFAULT 13 call_weak_fn
37: 0000000000000598 0 NOTYPE LOCAL DEFAULT 11 $x
38: 00000000000007bc 0 NOTYPE LOCAL DEFAULT 14 $x
39: 0000000000000000 0 FILE LOCAL DEFAULT ABS /usr/lib/gcc/aarch64-linu
40: 00000000000005a4 0 NOTYPE LOCAL DEFAULT 11 $x
41: 00000000000007c4 0 NOTYPE LOCAL DEFAULT 14 $x
42: 0000000000000000 0 FILE LOCAL DEFAULT ABS crtstuff.c
43: 0000000000000660 0 NOTYPE LOCAL DEFAULT 13 $x
44: 0000000000000660 0 FUNC LOCAL DEFAULT 13 deregister_tm_clones
45: 0000000000000690 0 FUNC LOCAL DEFAULT 13 register_tm_clones
46: 0000000000011008 0 NOTYPE LOCAL DEFAULT 22 $d
47: 00000000000006d0 0 FUNC LOCAL DEFAULT 13 __do_global_dtors_aux
48: 0000000000011010 1 OBJECT LOCAL DEFAULT 23 completed.9126
49: 0000000000010d90 0 NOTYPE LOCAL DEFAULT 19 $d
50: 0000000000010d90 0 OBJECT LOCAL DEFAULT 19 __do_global_dtors_aux_fin
51: 0000000000000718 0 FUNC LOCAL DEFAULT 13 frame_dummy
52: 0000000000010d88 0 NOTYPE LOCAL DEFAULT 18 $d
53: 0000000000010d88 0 OBJECT LOCAL DEFAULT 18 __frame_dummy_init_array_
54: 000000000000082c 0 NOTYPE LOCAL DEFAULT 17 $d
55: 0000000000011010 0 NOTYPE LOCAL DEFAULT 23 $d
56: 0000000000000000 0 FILE LOCAL DEFAULT ABS main.cpp
57: 000000000000071c 0 NOTYPE LOCAL DEFAULT 13 $x
58: 0000000000000890 0 NOTYPE LOCAL DEFAULT 17 $d
59: 0000000000000000 0 FILE LOCAL DEFAULT ABS elf-init.oS
60: 0000000000000738 0 NOTYPE LOCAL DEFAULT 13 $x
61: 00000000000008a8 0 NOTYPE LOCAL DEFAULT 17 $d
62: 0000000000000000 0 FILE LOCAL DEFAULT ABS crtstuff.c
63: 00000000000008f0 0 NOTYPE LOCAL DEFAULT 17 $d
64: 00000000000008f0 0 OBJECT LOCAL DEFAULT 17 __FRAME_END__
65: 0000000000000000 0 FILE LOCAL DEFAULT ABS
66: 0000000000010d90 0 NOTYPE LOCAL DEFAULT 18 __init_array_end
67: 0000000000010d98 0 OBJECT LOCAL DEFAULT ABS _DYNAMIC
68: 0000000000010d88 0 NOTYPE LOCAL DEFAULT 18 __init_array_start
69: 00000000000007d0 0 NOTYPE LOCAL DEFAULT 16 __GNU_EH_FRAME_HDR
70: 0000000000010fc0 0 OBJECT LOCAL DEFAULT ABS _GLOBAL_OFFSET_TABLE_
71: 0000000000000598 0 FUNC LOCAL DEFAULT 11 _init
72: 00000000000005b0 0 NOTYPE LOCAL DEFAULT 12 $x
73: 00000000000007b8 4 FUNC GLOBAL DEFAULT 13 __libc_csu_fini
74: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _ITM_deregisterTMCloneTab
75: 0000000000011000 0 NOTYPE WEAK DEFAULT 22 data_start
76: 0000000000011010 0 NOTYPE GLOBAL DEFAULT 23 __bss_start__
77: 0000000000000000 0 FUNC WEAK DEFAULT UND __cxa_finalize@@GLIBC_2.1
78: 0000000000011018 0 NOTYPE GLOBAL DEFAULT 23 _bss_end__
79: 0000000000011010 0 NOTYPE GLOBAL DEFAULT 22 _edata
80: 00000000000007bc 0 FUNC GLOBAL HIDDEN 14 _fini
81: 0000000000011018 0 NOTYPE GLOBAL DEFAULT 23 __bss_end__
82: 0000000000000000 0 FUNC GLOBAL DEFAULT UND __libc_start_main@@GLIBC_
83: 0000000000011000 0 NOTYPE GLOBAL DEFAULT 22 __data_start
84: 0000000000000000 0 NOTYPE WEAK DEFAULT UND __gmon_start__
85: 0000000000011008 0 OBJECT GLOBAL HIDDEN 22 __dso_handle
86: 0000000000000000 0 FUNC GLOBAL DEFAULT UND abort@@GLIBC_2.17
87: 00000000000007cc 4 OBJECT GLOBAL DEFAULT 15 _IO_stdin_used
88: 0000000000000738 124 FUNC GLOBAL DEFAULT 13 __libc_csu_init
89: 0000000000011018 0 NOTYPE GLOBAL DEFAULT 23 _end
90: 0000000000000610 0 FUNC GLOBAL DEFAULT 13 _start
91: 0000000000011018 0 NOTYPE GLOBAL DEFAULT 23 __end__
92: 0000000000011010 0 NOTYPE GLOBAL DEFAULT 23 __bss_start
93: 000000000000071c 24 FUNC GLOBAL DEFAULT 13 main
94: 0000000000011010 0 OBJECT GLOBAL HIDDEN 22 __TMC_END__
95: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _ITM_registerTMCloneTable
Version symbols section '.gnu.version' contains 9 entries:
Addr: 0x0000000000000412 Offset: 0x000412 Link: 5 (.dynsym)
000: 0 (*local*) 0 (*local*) 0 (*local*) 0 (*local*)
004: 2 (GLIBC_2.17) 2 (GLIBC_2.17) 0 (*local*) 2 (GLIBC_2.17)
008: 0 (*local*)
Version needs section '.gnu.version_r' contains 1 entry:
Addr: 0x0000000000000428 Offset: 0x000428 Link: 6 (.dynstr)
000000: Version: 1 File: libc.so.6 Cnt: 1
0x0010: Name: GLIBC_2.17 Flags: none Version: 2
Displaying notes found in: .note.gnu.build-id
Owner Data size Description
GNU 0x00000014 NT_GNU_BUILD_ID (unique build ID bitstring)
Build ID: 3e05092df57e4b081d4823e60f0e74fa226ac79f
Displaying notes found in: .note.ABI-tag
Owner Data size Description
GNU 0x00000010 NT_GNU_ABI_TAG (ABI version tag)
OS: Linux, ABI: 3.7.0
~# nm -a test
nm -a test
0000000000000000 a
U abort@@GLIBC_2.17
0000000000011010 b .bss
0000000000011018 B __bss_end__
0000000000011018 B _bss_end__
0000000000011010 B __bss_start
0000000000011010 B __bss_start__
0000000000000648 t call_weak_fn
0000000000000000 n .comment
0000000000011010 b completed.9126
0000000000000000 a crtstuff.c
0000000000000000 a crtstuff.c
w __cxa_finalize@@GLIBC_2.17
0000000000011000 d .data
0000000000011000 D __data_start
0000000000011000 W data_start
0000000000000000 N .debug_abbrev
0000000000000000 N .debug_aranges
0000000000000000 N .debug_info
0000000000000000 N .debug_line
0000000000000000 N .debug_str
0000000000000660 t deregister_tm_clones
00000000000006d0 t __do_global_dtors_aux
0000000000010d90 d __do_global_dtors_aux_fini_array_entry
0000000000011008 D __dso_handle
0000000000010d98 d .dynamic
0000000000010d98 a _DYNAMIC
0000000000000390 r .dynstr
00000000000002b8 r .dynsym
0000000000011010 D _edata
0000000000000818 r .eh_frame
00000000000007d0 r .eh_frame_hdr
0000000000000000 a elf-init.oS
0000000000011018 B __end__
0000000000011018 B _end
00000000000007bc t .fini
00000000000007bc T _fini
0000000000010d90 d .fini_array
0000000000000718 t frame_dummy
0000000000010d88 d __frame_dummy_init_array_entry
00000000000008f0 r __FRAME_END__
0000000000010fc0 a _GLOBAL_OFFSET_TABLE_
w __gmon_start__
00000000000007d0 r __GNU_EH_FRAME_HDR
0000000000000298 r .gnu.hash
0000000000000412 r .gnu.version
0000000000000428 r .gnu.version_r
0000000000010f88 d .got
0000000000000598 t .init
0000000000000598 t _init
0000000000010d88 d .init_array
0000000000010d90 d __init_array_end
0000000000010d88 d __init_array_start
0000000000000238 r .interp
00000000000007cc R _IO_stdin_used
w _ITM_deregisterTMCloneTable
w _ITM_registerTMCloneTable
00000000000007b8 T __libc_csu_fini
0000000000000738 T __libc_csu_init
U __libc_start_main@@GLIBC_2.17
000000000000071c T main
0000000000000000 a main.cpp
0000000000000278 r .note.ABI-tag
0000000000000254 r .note.gnu.build-id
00000000000005b0 t .plt
0000000000000690 t register_tm_clones
0000000000000448 r .rela.dyn
0000000000000538 r .rela.plt
00000000000007cc r .rodata
0000000000000610 T _start
0000000000000610 t .text
0000000000011010 D __TMC_END__
0000000000000000 a /usr/lib/gcc/aarch64-linux-gnu/9/../../../aarch64-linux-gnu/crti.o
0000000000000000 a /usr/lib/gcc/aarch64-linux-gnu/9/../../../aarch64-linux-gnu/crtn.o
0000000000000000 a /usr/lib/gcc/aarch64-linux-gnu/9/../../../aarch64-linux-gnu/Scrt1.o
您可以通过剥离符号来降低大小,如下所示:
~# strip test
~# ls -ltr
-rwxrwxr-x 1 jordan jordan 6056 Mar 1 08:21 test
所以文件从10k变成了6k。