We all know that the GCC-s switch can be used to generate assembly code,
However, sometimes, it is not enough to have a single assembly file. We hope that the source code of the C language program and the assembly language text will be checked together,
This is the listing function. No special FAQ is provided in GCC,
I have checked a lot of information on the Internet to find out how to implement it.
Gcc-C-g-wa,-adlhn ee. c> ee. Anno. s
The resulting ee. Anno. S is the list of C and Assembly hybrid sorting corresponding to ee. C.
Another example is the C program.
/* EE */
# Include <stdio. h>
# Include <stdio. h>
# Include <string. h>
# Include <stdlib. h>
# Include <windows. h>
Int main (INT argc, char ** argv)
{
Char * P = "to stdout ";
Int Ic = (INT) getstdhandle (std_output_handle );
Printf ("% d/N", IC );
Writefile (IC, P, strlen (P), & IC, null );
Return 0;
}
Generate
1
. File
"Ee. c" 4
. Text 5
Ltext0: 4222
. Section. RDATA, "Dr" 4223
Lc0: 4224 0000 544f2053
. ASCII "to stdout/0" 4224 54444f55 4224 5400 4225
LC1: 4226 000a 25640a00
. ASCII "% d/12/0" 4227 000e 0000
. Text 4231
. Globl _ main 4233
_ Main: 1: EE. c *****/* EE */2: EE. c ***** # include <stdio. h> 3: EE. c ***** # include <stdio. h> 4: EE. c ***** # include <string. h> 5: EE. c ***** # include <stdlib. h> 6: EE. c ***** # include <windows. h> 7: EE. c *** int main (INT argc, char *** argv) 8: EE. c *** {4235
Lm1: 4236 0000 55
Pushl
% EBP 4237 0001 89e5
Movl
% ESP, % EBP 4238 0003 83ec28
Subl
$40, % ESP 4239 0006 83e4f0
Andl
$-16, % ESP 4240 0009 b8000000
Movl
$0, % eax 4240 00 4241 000e 83c00f
Addl
$15, % eax 4242 0011 83c00f
Addl
$15, % eax 4243 0014 c1e804
Shrl
$4, % eax 4244 0017 c1e004
Sall
$4, % eax 4245 001a 8945f4
Movl
% Eax,-12 (% EBP) 4246 001d 8b45f4
Movl
-12 (% EBP), % eax 4247 0020 e8000000
Call
_ Alloca 4247 00 4249
Lm2: 4250 0025 e8000000
Call
___ Main 4250 00 9: EE. c ***** char * P = "to stdout"; 4252
Lm3: 4253 002a c745fc00
Movl
$ Lc0,-4 (% EBP) 4253 000000 10: EE. c *** int Ic = (INT) getstdhandle (std_output_handle); 4255
Lm4: 4256 0031 c701_f5
Movl
$-11, (% ESP) 4256 ffffff 4257 0038 e8000000
Call
_ Getstdhandle @ 4 4257 00 4258 003d 83ec04
Subl
$4, % ESP 4259 0040 8945f8
Movl
% Eax,-8 (% EBP) 11: EE. c *** printf ("% d/N", IC); 4261
Lm5: 4262 0043 8b45f8
Movl
-8 (% EBP), % eax 4263 0046 89442404
Movl
% Eax, 4 (% ESP) 4264 004a c704240a
Movl
$ LC1, (% ESP) 4264 000000 4265 0051 e8000000
Call
_ Printf 4265 00 12: EE. c ***** writefile (IC, P, strlen (P), & IC, null); 4267
Lm6: 4268 0056 8b45fc
Movl
-4 (% EBP), % eax 4269 0059 890424
Movl
% Eax, (% ESP) 4270 005c e8000000
Call
_ Strlen 4270 00 4271 0061 89c2
Movl
% Eax, % edX 4272 0063 c7442410
Movl
$0, 16 (% ESP) 4272 00000000 4273 006b 8d45f8
Leal
-8 (% EBP), % eax 4274 006e 8944240c
Movl
% Eax, 12 (% ESP) 4275 0072 89542408
Movl
% EdX, 8 (% ESP) 4276 0076 8b45fc
Movl
-4 (% EBP), % eax 4277 0079 89442404
Movl
% Eax, 4 (% ESP) 4278 007d 8b45f8
Movl
-8 (% EBP), % eax 4279 0080 890424
Movl
% Eax, (% ESP) 4280 0083 e8000000
Call
_ Writefile @ 20 4280 00 4281 0088 83ec14
Subl
$20, % ESP 13: EE. c ***** 14: EE. c ***** return 0; 4283
Lm7: 4284 008b b8000000
Movl
$0, % eax 4284 00 15: EE. c *****} 4286
Lm8: 4287 0090 C9
Leave 4288 0091 C3
RET 4293
Lscope0: 4295
. Text 4297
Letext: