c语言的详细编译过程

gcc编译c语言的整个编译过程可分为预编译->编译->汇编->链接

我们先编辑一个name.c文件

1 # include<stdio.h>
2 int main(int argc, const char *argv[])
3 {
4     printf("Hello World
");
5     return 0;
6 }

预编译:处理#号开头的所有程序行gcc -E name.c -o name.i

name.i文件如下

  1 # 1 "name.c"
  2 # 1 "<built-in>"
  3 # 1 "<command-line>"
  4 # 1 "name.c"
  5 # 1 "/usr/include/stdio.h" 1 3 4
  6 # 28 "/usr/include/stdio.h" 3 4
  7 # 1 "/usr/include/features.h" 1 3 4
  8 # 324 "/usr/include/features.h" 3 4
  9 # 1 "/usr/include/i386-linux-gnu/bits/predefs.h" 1 3 4
 10 # 325 "/usr/include/features.h" 2 3 4
 11 # 357 "/usr/include/features.h" 3 4
 12 # 1 "/usr/include/i386-linux-gnu/sys/cdefs.h" 1 3 4
 13 # 378 "/usr/include/i386-linux-gnu/sys/cdefs.h" 3 4
 14 # 1 "/usr/include/i386-linux-gnu/bits/wordsize.h" 1 3 4
 15 # 379 "/usr/include/i386-linux-gnu/sys/cdefs.h" 2 3 4
 16 # 358 "/usr/include/features.h" 2 3 4
 17 # 389 "/usr/include/features.h" 3 4
 18 # 1 "/usr/include/i386-linux-gnu/gnu/stubs.h" 1 3 4
 19 
 20 # 1 "/usr/include/i386-linux-gnu/gnu/stubs-32.h" 1 3 4
 21 # 8 "/usr/include/i386-linux-gnu/gnu/stubs.h" 2 3 4
 22 # 390 "/usr/include/features.h" 2 3 4
 23 # 29 "/usr/include/stdio.h" 2 3 4
 24 
 25 
 26 
 27 
 28 
 29 # 1 "/usr/lib/gcc/i686-linux-gnu/4.6/include/stddef.h" 1 3 4
 30 # 212 "/usr/lib/gcc/i686-linux-gnu/4.6/include/stddef.h" 3 4
 31 typedef unsigned int size_t;
 32 # 35 "/usr/include/stdio.h" 2 3 4
 33 
 34 # 1 "/usr/include/i386-linux-gnu/bits/types.h" 1 3 4
 35 # 28 "/usr/include/i386-linux-gnu/bits/types.h" 3 4
 36 # 1 "/usr/include/i386-linux-gnu/bits/wordsize.h" 1 3 4
 37 # 29 "/usr/include/i386-linux-gnu/bits/types.h" 2 3 4
 38 
 39 
 40 typedef unsigned char __u_char;
 41 typedef unsigned short int __u_short;
 42 typedef unsigned int __u_int;
 43 typedef unsigned long int __u_long;
 44 
 45 
 46 typedef signed char __int8_t;
 47 typedef unsigned char __uint8_t;
 48 typedef signed short int __int16_t;
 49 typedef unsigned short int __uint16_t;
 50 typedef signed int __int32_t;
 51 typedef unsigned int __uint32_t;
 52 
 53 
 54 
 55 
 56 __extension__ typedef signed long long int __int64_t;
 57 __extension__ typedef unsigned long long int __uint64_t;
 58 
 59 
 60 
 61 
 62 
 63 
 64 __extension__ typedef long long int __quad_t;
 65 __extension__ typedef unsigned long long int __u_quad_t;
 66 # 131 "/usr/include/i386-linux-gnu/bits/types.h" 3 4
 67 # 1 "/usr/include/i386-linux-gnu/bits/typesizes.h" 1 3 4
 68 # 132 "/usr/include/i386-linux-gnu/bits/types.h" 2 3 4
 69 
 70 
 71 __extension__ typedef __u_quad_t __dev_t;
 72 __extension__ typedef unsigned int __uid_t;
 73 __extension__ typedef unsigned int __gid_t;
 74 __extension__ typedef unsigned long int __ino_t;
 75 __extension__ typedef __u_quad_t __ino64_t;
 76 __extension__ typedef unsigned int __mode_t;
 77 __extension__ typedef unsigned int __nlink_t;
 78 __extension__ typedef long int __off_t;
 79 __extension__ typedef __quad_t __off64_t;
 80 __extension__ typedef int __pid_t;
 81 __extension__ typedef struct { int __val[2]; } __fsid_t;
 82 __extension__ typedef long int __clock_t;
 83 __extension__ typedef unsigned long int __rlim_t;
 84 __extension__ typedef __u_quad_t __rlim64_t;
 85 __extension__ typedef unsigned int __id_t;
 86 __extension__ typedef long int __time_t;
 87 __extension__ typedef unsigned int __useconds_t;
 88 __extension__ typedef long int __suseconds_t;
 89 
 90 __extension__ typedef int __daddr_t;
 91 __extension__ typedef long int __swblk_t;
 92 __extension__ typedef int __key_t;
 93 
 94 
 95 __extension__ typedef int __clockid_t;
 96 
 97 
 98 __extension__ typedef void * __timer_t;
 99 
100 
101 __extension__ typedef long int __blksize_t;
102 
103 
104 
105 
106 __extension__ typedef long int __blkcnt_t;
107 __extension__ typedef __quad_t __blkcnt64_t;
108 
109 __extension__ typedef unsigned long int __fsblkcnt_t;
110 __extension__ typedef __u_quad_t __fsblkcnt64_t;
111 
112 
113 __extension__ typedef unsigned long int __fsfilcnt_t;
114 __extension__ typedef __u_quad_t __fsfilcnt64_t;
115 
116 __extension__ typedef int __ssize_t;
117 
118 
119 
120 typedef __off64_t __loff_t;
121 typedef __quad_t *__qaddr_t;
122 typedef char *__caddr_t;
123 
124 
125 __extension__ typedef int __intptr_t;
126 
127 
128 __extension__ typedef unsigned int __socklen_t;
129 # 37 "/usr/include/stdio.h" 2 3 4
130 # 45 "/usr/include/stdio.h" 3 4
131 struct _IO_FILE;
132 
133 
134 
135 typedef struct _IO_FILE FILE;
136 
137 
138 
139 
140 
141 # 65 "/usr/include/stdio.h" 3 4
142 typedef struct _IO_FILE __FILE;
143 # 75 "/usr/include/stdio.h" 3 4
144 # 1 "/usr/include/libio.h" 1 3 4
145 # 32 "/usr/include/libio.h" 3 4
146 # 1 "/usr/include/_G_config.h" 1 3 4
147 # 15 "/usr/include/_G_config.h" 3 4
148 # 1 "/usr/lib/gcc/i686-linux-gnu/4.6/include/stddef.h" 1 3 4
149 # 16 "/usr/include/_G_config.h" 2 3 4
150 
151 
152 
153 
154 # 1 "/usr/include/wchar.h" 1 3 4
155 # 83 "/usr/include/wchar.h" 3 4
156 typedef struct
157 {
158   int __count;
159   union
160   {
161 
162     unsigned int __wch;
163 
164 
165 
166     char __wchb[4];
167   } __value;
168 } __mbstate_t;
169 # 21 "/usr/include/_G_config.h" 2 3 4
170 
171 typedef struct
172 {
173   __off_t __pos;
174   __mbstate_t __state;
175 } _G_fpos_t;
176 typedef struct
177 {
178   __off64_t __pos;
179   __mbstate_t __state;
180 } _G_fpos64_t;
181 # 53 "/usr/include/_G_config.h" 3 4
182 typedef int _G_int16_t __attribute__ ((__mode__ (__HI__)));
183 typedef int _G_int32_t __attribute__ ((__mode__ (__SI__)));
184 typedef unsigned int _G_uint16_t __attribute__ ((__mode__ (__HI__)));
185 typedef unsigned int _G_uint32_t __attribute__ ((__mode__ (__SI__)));
186 # 33 "/usr/include/libio.h" 2 3 4
187 # 53 "/usr/include/libio.h" 3 4
188 # 1 "/usr/lib/gcc/i686-linux-gnu/4.6/include/stdarg.h" 1 3 4
189 # 40 "/usr/lib/gcc/i686-linux-gnu/4.6/include/stdarg.h" 3 4
190 typedef __builtin_va_list __gnuc_va_list;
191 # 54 "/usr/include/libio.h" 2 3 4
192 # 172 "/usr/include/libio.h" 3 4
193 struct _IO_jump_t; struct _IO_FILE;
194 # 182 "/usr/include/libio.h" 3 4
195 typedef void _IO_lock_t;
196 
197 
198 
199 
200 
201 struct _IO_marker {
202   struct _IO_marker *_next;
203   struct _IO_FILE *_sbuf;
204 
205 
206 
207   int _pos;
208 # 205 "/usr/include/libio.h" 3 4
209 };
210 
211 
212 enum __codecvt_result
213 {
214   __codecvt_ok,
215   __codecvt_partial,
216   __codecvt_error,
217   __codecvt_noconv
218 };
219 # 273 "/usr/include/libio.h" 3 4
220 struct _IO_FILE {
221   int _flags;
222 
223 :
224 
225 
226 
227   char* _IO_read_ptr;
228   char* _IO_read_end;
229   char* _IO_read_base;
230   char* _IO_write_base;
231   char* _IO_write_ptr;
232   char* _IO_write_end;
233   char* _IO_buf_base;
234   char* _IO_buf_end;
235 
236   char *_IO_save_base;
237   char *_IO_backup_base;
238   char *_IO_save_end;
239 
240   struct _IO_marker *_markers;
241 
242   struct _IO_FILE *_chain;
243 
244   int _fileno;
245 
246 
247 :
248 
249   int _flags2;
250 
251   __off_t _old_offset;
252 
253 
254 
255   unsigned short _cur_column;
256   signed char _vtable_offset;
257   char _shortbuf[1];
258 
259 
260 
261   _IO_lock_t *_lock;
262 # 321 "/usr/include/libio.h" 3 4
263   __off64_t _offset;
264 # 330 "/usr/include/libio.h" 3 4
265   void *__pad1;
266   void *__pad2;
267   void *__pad3;
268   void *__pad4;
269   size_t __pad5;
270 
271   int _mode;
272 
273   char _unused2[15 * sizeof (int) - 4 * sizeof (void *) - sizeof (size_t)];
274 
275 };
276 
277 
278 typedef struct _IO_FILE _IO_FILE;
279 
280 
281 struct _IO_FILE_plus;
282 
283 extern struct _IO_FILE_plus _IO_2_1_stdin_;
284 extern struct _IO_FILE_plus _IO_2_1_stdout_;
285 extern struct _IO_FILE_plus _IO_2_1_stderr_;
286 # 366 "/usr/include/libio.h" 3 4
287 typedef __ssize_t __io_read_fn (void *__cookie, char *__buf, size_t __nbytes);
288 
289 
290 
291 
292 
293 
294 :
295 
296 typedef __ssize_t __io_write_fn (void *__cookie, __const char *__buf,
297      size_t __n);
298 
299 
300 
301 
302 
303 
304 
305 typedef int __io_seek_fn (void *__cookie, __off64_t *__pos, int __w);
306 
307 
308 typedef int __io_close_fn (void *__cookie);
309 # 418 "/usr/include/libio.h" 3 4
310 extern int __underflow (_IO_FILE *);
311 extern int __uflow (_IO_FILE *);
312 extern int __overflow (_IO_FILE *, int);
313 # 462 "/usr/include/libio.h" 3 4
314 extern int _IO_getc (_IO_FILE *__fp);
315 extern int _IO_putc (int __c, _IO_FILE *__fp);
316 extern int _IO_feof (_IO_FILE *__fp) __attribute__ ((__nothrow__ , __leaf__));
317 extern int _IO_ferror (_IO_FILE *__fp) __attribute__ ((__nothrow__ , __leaf__));
318 :
319 extern int _IO_peekc_locked (_IO_FILE *__fp);
320 
321 
322 
323 
324 
325 extern void _IO_flockfile (_IO_FILE *) __attribute__ ((__nothrow__ , __leaf__));
326 extern void _IO_funlockfile (_IO_FILE *) __attribute__ ((__nothrow__ , __leaf__));
327 extern int _IO_ftrylockfile (_IO_FILE *) __attribute__ ((__nothrow__ , __leaf__));
328 # 492 "/usr/include/libio.h" 3 4
329 extern int _IO_vfscanf (_IO_FILE * __restrict, const char * __restrict,
330    __gnuc_va_list, int *__restrict);
331 extern int _IO_vfprintf (_IO_FILE *__restrict, const char *__restrict,
332     __gnuc_va_list);
333 extern __ssize_t _IO_padn (_IO_FILE *, int, __ssize_t);
334 extern size_t _IO_sgetn (_IO_FILE *, void *, size_t);
335 
336 extern __off64_t _IO_seekoff (_IO_FILE *, __off64_t, int, int);
337 extern __off64_t _IO_seekpos (_IO_FILE *, __off64_t, int);
338 
339 :
340 extern void _IO_free_backup_area (_IO_FILE *) __attribute__ ((__nothrow__ , __leaf__));
341 # 76 "/usr/include/stdio.h" 2 3 4
342 
343 
344 
345 
346 typedef __gnuc_va_list va_list;
347 # 91 "/usr/include/stdio.h" 3 4
348 typedef __off_t off_t;
349 # 103 "/usr/include/stdio.h" 3 4
350 typedef __ssize_t ssize_t;
351 
352 
353 
354 
355 
356 
357 
358 typedef _G_fpos_t fpos_t;
359 
360 
361 
362 :
363 
364 # 165 "/usr/include/stdio.h" 3 4
365 # 1 "/usr/include/i386-linux-gnu/bits/stdio_lim.h" 1 3 4
366 # 166 "/usr/include/stdio.h" 2 3 4
367 
368 
369 
370 extern struct _IO_FILE *stdin;
371 extern struct _IO_FILE *stdout;
372 extern struct _IO_FILE *stderr;
373 
374 
375 
376 
377 
378 
379 
380 extern int remove (__const char *__filename) __attribute__ ((__nothrow__ , __leaf__));
381 
382 extern int rename (__const char *__old, __const char *__new) __attribute__ ((__nothrow__ , __leaf__));
383 
384 
385 
386 
387 extern int renameat (int __oldfd, __const char *__old, int __newfd,
388        __const char *__new) __attribute__ ((__nothrow__ , __leaf__));
389 
390 
391 
392 
393 
394 
395 
396 
397 extern FILE *tmpfile (void) ;
398 # 210 "/usr/include/stdio.h" 3 4
399 extern char *tmpnam (char *__s) __attribute__ ((__nothrow__ , __leaf__)) ;
400 
401 
402 
403 
404 
405 extern char *tmpnam_r (char *__s) __attribute__ ((__nothrow__ , __leaf__)) ;
406 # 228 "/usr/include/stdio.h" 3 4
407 extern char *tempnam (__const char *__dir, __const char *__pfx)
408      __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) ;
409 
410 
411 
412 
413 
414 
415 
416 
417 extern int fclose (FILE *__stream);
418 
419 
420 
421 
422 extern int fflush (FILE *__stream);
423 
424 # 253 "/usr/include/stdio.h" 3 4
425 extern int fflush_unlocked (FILE *__stream);
426 # 267 "/usr/include/stdio.h" 3 4
427 
428 
429 
430 
431 
432 
433 extern FILE *fopen (__const char *__restrict __filename,
434       __const char *__restrict __modes) ;
435 
436 
437 
438 
439 extern FILE *freopen (__const char *__restrict __filename,
440         __const char *__restrict __modes,
441         FILE *__restrict __stream) ;
442 # 296 "/usr/include/stdio.h" 3 4
443 
444 # 307 "/usr/include/stdio.h" 3 4
445 extern FILE *fdopen (int __fd, __const char *__modes) __attribute__ ((__nothrow__ , __leaf__)) ;
446 # 320 "/usr/include/stdio.h" 3 4
447 extern FILE *fmemopen (void *__s, size_t __len, __const char *__modes)
448   __attribute__ ((__nothrow__ , __leaf__)) ;
449 
450 
451 
452 
453 extern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) __attribute__ ((__nothrow__ , __leaf__)) ;
454 
455 
456 
457 
458 
459 
460 extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) __attribute__ ((__nothrow__ , __leaf__));
461 
462 
463 
464 extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf,
465       int __modes, size_t __n) __attribute__ ((__nothrow__ , __leaf__));
466 
467 
468 
469 
470 
471 extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf,
472          size_t __size) __attribute__ ((__nothrow__ , __leaf__));
473 
474 
475 extern void setlinebuf (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));
476 
477 
478 
479 
480 
481 
482 
483 
484 extern int fprintf (FILE *__restrict __stream,
485       __const char *__restrict __format, ...);
486 
487 
488 
489 
490 extern int printf (__const char *__restrict __format, ...);
491 
492 extern int sprintf (char *__restrict __s,
493       __const char *__restrict __format, ...) __attribute__ ((__nothrow__));
494 
495 
496 
497 
498 
499 extern int vfprintf (FILE *__restrict __s, __const char *__restrict __format,
500        __gnuc_va_list __arg);
501 
502 
503 
504 
505 extern int vprintf (__const char *__restrict __format, __gnuc_va_list __arg);
506 
507 extern int vsprintf (char *__restrict __s, __const char *__restrict __format,
508        __gnuc_va_list __arg) __attribute__ ((__nothrow__));
509 
510 
511 
512 
513 
514 extern int snprintf (char *__restrict __s, size_t __maxlen,
515        __const char *__restrict __format, ...)
516      __attribute__ ((__nothrow__)) __attribute__ ((__format__ (__printf__, 3, 4)));
517 
518 extern int vsnprintf (char *__restrict __s, size_t __maxlen,
519         __const char *__restrict __format, __gnuc_va_list __arg)
520      __attribute__ ((__nothrow__)) __attribute__ ((__format__ (__printf__, 3, 0)));
521 
522 # 418 "/usr/include/stdio.h" 3 4
523 extern int vdprintf (int __fd, __const char *__restrict __fmt,
524        __gnuc_va_list __arg)
525      __attribute__ ((__format__ (__printf__, 2, 0)));
526 extern int dprintf (int __fd, __const char *__restrict __fmt, ...)
527      __attribute__ ((__format__ (__printf__, 2, 3)));
528 
529 
530 
531 
532 
533 
534 
535 
536 extern int fscanf (FILE *__restrict __stream,
537      __const char *__restrict __format, ...) ;
538 
539 
540 
541 
542 extern int scanf (__const char *__restrict __format, ...) ;
543 
544 extern int sscanf (__const char *__restrict __s,
545      __const char *__restrict __format, ...) __attribute__ ((__nothrow__ , __leaf__));
546 # 449 "/usr/include/stdio.h" 3 4
547 extern int fscanf (FILE *__restrict __stream, __const char *__restrict __format, ...) __asm__ ("" "__isoc99_fscanf")
548 
549                                ;
550 extern int scanf (__const char *__restrict __format, ...) __asm__ ("" "__isoc99_scanf")
551                               ;
552 extern int sscanf (__const char *__restrict __s, __const char *__restrict __format, ...) __asm__ ("" "__isoc99_sscanf") __attribute__ ((__nothrow__ , __leaf__))
553 
554                       ;
555 # 469 "/usr/include/stdio.h" 3 4
556 
557 
558 
559 
560 
561 
562 
563 
564 extern int vfscanf (FILE *__restrict __s, __const char *__restrict __format,
565       __gnuc_va_list __arg)
566      __attribute__ ((__format__ (__scanf__, 2, 0))) ;
567 
568 
569 
570 
571 
572 extern int vscanf (__const char *__restrict __format, __gnuc_va_list __arg)
573      __attribute__ ((__format__ (__scanf__, 1, 0))) ;
574 
575 
576 extern int vsscanf (__const char *__restrict __s,
577       __const char *__restrict __format, __gnuc_va_list __arg)
578      __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__format__ (__scanf__, 2, 0)));
579 # 500 "/usr/include/stdio.h" 3 4
580 extern int vfscanf (FILE *__restrict __s, __const char *__restrict __format, __gnuc_va_list __arg) __asm__ ("" "__isoc99_vfscanf")
581 
582 
583 
584      __attribute__ ((__format__ (__scanf__, 2, 0))) ;
585 extern int vscanf (__const char *__restrict __format, __gnuc_va_list __arg) __asm__ ("" "__isoc99_vscanf")
586 
587      __attribute__ ((__format__ (__scanf__, 1, 0))) ;
588 extern int vsscanf (__const char *__restrict __s, __const char *__restrict __format, __gnuc_va_list __arg) __asm__ ("" "__isoc99_vsscanf") __attribute__ ((__nothrow__ , __leaf__))
589 
590 
591 
592      __attribute__ ((__format__ (__scanf__, 2, 0)));
593 # 528 "/usr/include/stdio.h" 3 4
594 
595 
596 
597 
598 
599 
600 
601 
602 
603 extern int fgetc (FILE *__stream);
604 extern int getc (FILE *__stream);
605 
606 
607 
608 
609 
610 extern int getchar (void);
611 
612 # 556 "/usr/include/stdio.h" 3 4
613 extern int getc_unlocked (FILE *__stream);
614 extern int getchar_unlocked (void);
615 # 567 "/usr/include/stdio.h" 3 4
616 extern int fgetc_unlocked (FILE *__stream);
617 
618 
619 
620 
621 
622 
623 
624 
625 
626 
627 
628 extern int fputc (int __c, FILE *__stream);
629 extern int putc (int __c, FILE *__stream);
630 
631 
632 
633 
634 
635 extern int putchar (int __c);
636 
637 # 600 "/usr/include/stdio.h" 3 4
638 extern int fputc_unlocked (int __c, FILE *__stream);
639 
640 
641 
642 
643 
644 
645 
646 extern int putc_unlocked (int __c, FILE *__stream);
647 extern int putchar_unlocked (int __c);
648 
649 
650 
651 
652 
653 
654 extern int getw (FILE *__stream);
655 
656 
657 extern int putw (int __w, FILE *__stream);
658 
659 
660 
661 
662 
663 
664 
665 
666 extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
667      ;
668 
669 
670 
671 
672 
673 
674 extern char *gets (char *__s) ;
675 
676 # 662 "/usr/include/stdio.h" 3 4
677 extern __ssize_t __getdelim (char **__restrict __lineptr,
678           size_t *__restrict __n, int __delimiter,
679           FILE *__restrict __stream) ;
680 extern __ssize_t getdelim (char **__restrict __lineptr,
681         size_t *__restrict __n, int __delimiter,
682         FILE *__restrict __stream) ;
683 
684 
685 
686 
687 
688 
689 
690 extern __ssize_t getline (char **__restrict __lineptr,
691        size_t *__restrict __n,
692        FILE *__restrict __stream) ;
693 
694 
695 
696 
697 
698 
699 
700 
701 extern int fputs (__const char *__restrict __s, FILE *__restrict __stream);
702 
703 
704 
705 
706 
707 extern int puts (__const char *__s);
708 
709 
710 
711 
712 
713 
714 extern int ungetc (int __c, FILE *__stream);
715 
716 
717 
718 
719 
720 
721 extern size_t fread (void *__restrict __ptr, size_t __size,
722        size_t __n, FILE *__restrict __stream) ;
723 
724 
725 
726 
727 extern size_t fwrite (__const void *__restrict __ptr, size_t __size,
728         size_t __n, FILE *__restrict __s);
729 
730 # 734 "/usr/include/stdio.h" 3 4
731 extern size_t fread_unlocked (void *__restrict __ptr, size_t __size,
732          size_t __n, FILE *__restrict __stream) ;
733 extern size_t fwrite_unlocked (__const void *__restrict __ptr, size_t __size,
734           size_t __n, FILE *__restrict __stream);
735 
736 
737 
738 
739 
740 
741 
742 
743 extern int fseek (FILE *__stream, long int __off, int __whence);
744 
745 
746 
747 
748 extern long int ftell (FILE *__stream) ;
749 
750 
751 
752 
753 extern void rewind (FILE *__stream);
754 
755 # 770 "/usr/include/stdio.h" 3 4
756 extern int fseeko (FILE *__stream, __off_t __off, int __whence);
757 
758 
759 
760 
761 extern __off_t ftello (FILE *__stream) ;
762 # 789 "/usr/include/stdio.h" 3 4
763 
764 
765 
766 
767 
768 
769 extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos);
770 
771 
772 
773 
774 extern int fsetpos (FILE *__stream, __const fpos_t *__pos);
775 # 812 "/usr/include/stdio.h" 3 4
776 
777 # 821 "/usr/include/stdio.h" 3 4
778 
779 
780 extern void clearerr (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));
781 
782 extern int feof (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ;
783 
784 extern int ferror (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ;
785 
786 
787 
788 
789 extern void clearerr_unlocked (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));
790 extern int feof_unlocked (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ;
791 extern int ferror_unlocked (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ;
792 
793 
794 
795 
796 
797 
798 
799 
800 extern void perror (__const char *__s);
801 
802 
803 
804 
805 
806 
807 # 1 "/usr/include/i386-linux-gnu/bits/sys_errlist.h" 1 3 4
808 # 27 "/usr/include/i386-linux-gnu/bits/sys_errlist.h" 3 4
809 extern int sys_nerr;
810 extern __const char *__const sys_errlist[];
811 # 851 "/usr/include/stdio.h" 2 3 4
812 
813 
814 
815 
816 extern int fileno (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ;
817 
818 
819 
820 
821 extern int fileno_unlocked (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ;
822 # 870 "/usr/include/stdio.h" 3 4
823 extern FILE *popen (__const char *__command, __const char *__modes) ;
824 
825 
826 
827 
828 
829 extern int pclose (FILE *__stream);
830 
831 
832 
833 
834 
835 extern char *ctermid (char *__s) __attribute__ ((__nothrow__ , __leaf__));
836 # 910 "/usr/include/stdio.h" 3 4
837 extern void flockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));
838 
839 
840 
841 extern int ftrylockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ;
842 
843 
844 extern void funlockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));
845 # 940 "/usr/include/stdio.h" 3 4
846 
847 # 2 "name.c" 2
848 int main(int argc, const char *argv[])
849 {
850  printf("Hello World
");
851  return 0;
852 }
View Code


编译:把c语言变成汇编语言gcc -S name.i -o name.s

name.s文件如下

 1     .file    "name.c"
 2     .section    .rodata
 3 .LC0:
 4     .string    "Hello World"
 5     .text
 6     .globl    main
 7     .type    main, @function
 8 main:
 9 .LFB0:
10     .cfi_startproc
11     pushl    %ebp
12     .cfi_def_cfa_offset 8
13     .cfi_offset 5, -8
14     movl    %esp, %ebp
15     .cfi_def_cfa_register 5
16     andl    $-16, %esp
17     subl    $16, %esp
18     movl    $.LC0, (%esp)
19     call    puts
20     movl    $0, %eax
21     leave
22     .cfi_restore 5
23     .cfi_def_cfa 4, 4
24     ret
25     .cfi_endproc
26 .LFE0:
27     .size    main, .-main
28     .ident    "GCC: (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3"
29     .section    .note.GNU-stack,"",@progbits
View Code

汇编:把汇编语言变成机器语言gcc -c name.s -o name.o


链接:把所有有关的库函数和汇编生成的目标文件链接成可执行的文件gcc name.o -o name

然后执行./name就可以了

还可以用内部的编译器自己做

如下:

cpp name.c -o name.i

/usr/lib/gcc/i686-linux-gnu/cc1 name.i -o name.s

as name.s -o name.o

ld --dynamic-linker /lib/ld-linux.so.2 /usr/lib/i386-linux-gnu/crt1.o /usr/lib/i386-linux-gnu/crti.o /usr/lib/gcc/i686-linux-gnu/4.6/crtbegin.o -lc /usr/lib/gcc/i686-linux-gnu/4.6/crtend.o /usr/lib/i386-linux-gnu/crtn.o name.o

原文地址:https://www.cnblogs.com/asif/p/3586384.html