Handmade Hero » Forums » Code » "large" executable file
Bits Please
10 posts
#20972 "large" executable file
3 months, 3 weeks ago Edited by Bits Please on April 25, 2019, 9:29 a.m. Reason: Initial post

Greetings fellow programmers!
I've stumbled upon a very peculiar phenomenon. Whenever I'm executing the following piece of code:
1
2
3
4
5
6
7
int main() {
	return 0;
}

int mainCRTStartup() {
	return main();
}


It produces a 2 kb object file and, for some odd reason, an 8 kb executable file.
Upon further inspection, with the help of a very handy tool called dumpbin, I've managed to find out the reason behind the "large" size of my executable.

Check this out:
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
Dump of file main.exe

File Type: EXECUTABLE IMAGE

  0000000140001000: CC                 int         3
  0000000140001001: CC                 int         3
  0000000140001002: CC                 int         3
  0000000140001003: CC                 int         3
  0000000140001004: CC                 int         3
@ILT+0([email protected]@YAHXZ):
  0000000140001005: E9 26 00 00 00     jmp         [email protected]@YAHXZ
@ILT+5(main):
  000000014000100A: E9 11 00 00 00     jmp         main
  000000014000100F: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000101F: CC                                               .
main:
  0000000140001020: 33 C0              xor         eax,eax
  0000000140001022: C3                 ret
  0000000140001023: CC                 int         3
  0000000140001024: CC                 int         3
  0000000140001025: CC                 int         3
  0000000140001026: CC                 int         3
  0000000140001027: CC                 int         3
  0000000140001028: CC                 int         3
  0000000140001029: CC                 int         3
  000000014000102A: CC                 int         3
  000000014000102B: CC                 int         3
  000000014000102C: CC                 int         3
  000000014000102D: CC                 int         3
  000000014000102E: CC                 int         3
  000000014000102F: CC                 int         3
[email protected]@YAHXZ:
  0000000140001030: 48 83 EC 28        sub         rsp,28h
  0000000140001034: E8 D1 FF FF FF     call        @ILT+5(main)
  0000000140001039: 48 83 C4 28        add         rsp,28h
  000000014000103D: C3                 ret
  000000014000103E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000104E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000105E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000106E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000107E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000108E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000109E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400010AE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400010BE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400010CE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400010DE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400010EE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400010FE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000110E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000111E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000112E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000113E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000114E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000115E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000116E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000117E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000118E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000119E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400011AE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400011BE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400011CE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400011DE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400011EE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400011FE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000120E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000121E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000122E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000123E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000124E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000125E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000126E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000127E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000128E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000129E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400012AE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400012BE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400012CE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400012DE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400012EE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400012FE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000130E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000131E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000132E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000133E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000134E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000135E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000136E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000137E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000138E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000139E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400013AE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400013BE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400013CE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400013DE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400013EE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400013FE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000140E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000141E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000142E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000143E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000144E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000145E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000146E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000147E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000148E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000149E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400014AE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400014BE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400014CE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400014DE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400014EE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400014FE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000150E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000151E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000152E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000153E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000154E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000155E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000156E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000157E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000158E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000159E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400015AE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400015BE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400015CE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400015DE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400015EE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400015FE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000160E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000161E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000162E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000163E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000164E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000165E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000166E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000167E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000168E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000169E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400016AE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400016BE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400016CE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400016DE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400016EE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400016FE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000170E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000171E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000172E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000173E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000174E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000175E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000176E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000177E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000178E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000179E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400017AE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400017BE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400017CE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400017DE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400017EE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400017FE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000180E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000181E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000182E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000183E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000184E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000185E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000186E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000187E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000188E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000189E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400018AE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400018BE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400018CE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400018DE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400018EE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400018FE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000190E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000191E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000192E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000193E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000194E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000195E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000196E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000197E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000198E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000199E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400019AE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400019BE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400019CE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400019DE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400019EE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  00000001400019FE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001A0E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001A1E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001A2E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001A3E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001A4E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001A5E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001A6E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001A7E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001A8E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001A9E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001AAE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001ABE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001ACE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001ADE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001AEE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001AFE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001B0E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001B1E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001B2E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001B3E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001B4E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001B5E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001B6E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001B7E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001B8E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001B9E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001BAE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001BBE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001BCE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001BDE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001BEE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001BFE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001C0E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001C1E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001C2E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001C3E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001C4E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001C5E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001C6E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001C7E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001C8E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001C9E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001CAE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001CBE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001CCE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001CDE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001CEE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001CFE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001D0E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001D1E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001D2E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001D3E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001D4E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001D5E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001D6E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001D7E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001D8E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001D9E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001DAE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001DBE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001DCE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001DDE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001DEE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001DFE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001E0E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001E1E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001E2E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001E3E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001E4E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001E5E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001E6E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001E7E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001E8E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001E9E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001EAE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001EBE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001ECE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001EDE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001EEE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001EFE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001F0E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001F1E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001F2E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001F3E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001F4E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001F5E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001F6E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001F7E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001F8E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001F9E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001FAE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001FBE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001FCE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001FDE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001FEE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  0000000140001FFE: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000200E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000201E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000202E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC  ................
  000000014000203E: CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC 00  ................

  Summary

        1000 .pdata
        1000 .rdata
        1000 .reloc
        2000 .text


My questions are, why are there so many empty lines, what's their purpose and how can I get rid of them and produce a clean executable file containing only the things it supposed to contain?
Recyrillic
Pascal Beyer
4 posts
#20973 "large" executable file
3 months, 3 weeks ago

The first 300-400 bytes of the executable contain the PE-header which tells the loader how to start running your program and all that. You can find the spec here: https://docs.microsoft.com/de-de/windows/desktop/Debug/pe-format

Then the sections in the exectuable file are aligned by some value (I think its 4k, but im a bit confused by the docs). Hence all the empty lines.
You can pass stuff to the linker to make your executable smaller, like /DYNAMICBASE:NO to get rid of .reloc. You can also get rid of the alignment by specifying /ALIGN: <some number> but this will give you a non-valid executable. Linker flags are also on msdn.

You can also look at this link, where someone tries to make the smallest executable possible.
mmozeiko
Mārtiņš Možeiko
1963 posts / 1 project
#20975 "large" executable file
3 months, 3 weeks ago Edited by Mārtiņš Možeiko on April 25, 2019, 5:46 p.m.

You can also merge .rdata and .text sections that will reduce size a bit (because of alignment & header) - pass "/MERGE:.rdata=.text" to linker. This will put read only data in code section - but be careful this can introduce security issues in your code if attacker can control input data and you have stack overwrite or similar bug. Because they will be able to reuse bytes from read-only data section as code.