Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GCC verbose mode output explanation

Tags:

I'm new to linux. Can anyone explain to me the following verbose mode output for my hello world program? Also, what do the files crt1.o, crti.o, crtend.o, crtbegin.o and crtn.o and lc and lgcc do? Any other explanatory links are also welcome.

$ gcc -v hello.c  Reading specs from /usr/lib/gcc-lib/i686/3.3.1/specs Configured with: ../configure --prefix=/usr Thread model: posix gcc version 3.3.1  /usr/lib/gcc-lib/i686/3.3.1/cc1 -quiet -v -D__GNUC__=3   -D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=1   hello.c -quiet -dumpbase hello.c -auxbase hello -Wall  -version -o /tmp/cceCee26.s GNU C version 3.3.1 (i686-pc-linux-gnu)  compiled by GNU C version 3.3.1 (i686-pc-linux-gnu) GGC heuristics: --param ggc-min-expand=51   --param ggc-min-heapsize=40036 ignoring nonexistent directory "/usr/i686/include" #include "..." search starts here: #include <...> search starts here:  /usr/local/include  /usr/include  /usr/lib/gcc-lib/i686/3.3.1/include  /usr/include End of search list.  as -V -Qy -o /tmp/ccQynbTm.o /tmp/cceCee26.s GNU assembler version 2.12.90.0.1 (i386-linux) using BFD version 2.12.90.0.1 20020307 Debian/GNU Linux /usr/lib/gcc-lib/i686/3.3.1/collect2  --eh-frame-hdr -m elf_i386 -dynamic-linker  /lib/ld-linux.so.2 /usr/lib/crt1.o /usr/lib/crti.o  /usr/lib/gcc-lib/i686/3.3.1/crtbegin.o  -L/usr/lib/gcc-lib/i686/3.3.1  -L/usr/lib/gcc-lib/i686/3.3.1/../../.. /tmp/ccQynbTm.o  -lgcc -lgcc_eh -lc -lgcc -lgcc_eh  /usr/lib/gcc-lib/i686/3.3.1/crtend.o  /usr/lib/crtn.o 
like image 655
Gomathi Avatar asked Nov 18 '12 13:11

Gomathi


People also ask

What is meant by verbose output?

The verbose option specifies that you want to display detailed processing information on your screen. This is the default. When you run the incremental, selective, or archive commands, information is displayed about each file that is backed up. Use the quiet option if you do not want to display this information.

What does verbose mode do?

In computing, Verbose mode is an option available in many computer operating systems and programming languages that provides additional details as to what the computer is doing and what drivers and software it is loading during startup or in programming it would produce detailed output for diagnostic purposes thus ...

Which command is used for verbose output?

Displays verbose output for a specified command. You can use /verbose with any other wdsutil commands that you run. Note that you must specify /verbose and /progress directly after wdsutil.

What does GCC output?

The output is in the form of an assembler code file for each non-assembler input file specified. By default, the assembler file name for a source file is made by replacing the suffix ' .


1 Answers

The first part is the version and configuration data for the compiler driver (that's the gcc binary, which is not actually the compiler itself):

Reading specs from /usr/lib/gcc-lib/i686/3.3.1/specs Configured with: ../configure --prefix=/usr Thread model: posix gcc version 3.3.1 

Then it prints the command it uses to call the real compiler, cc1:

 /usr/lib/gcc-lib/i686/3.3.1/cc1 -quiet -v -D__GNUC__=3   -D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=1   hello.c -quiet -dumpbase hello.c -auxbase hello -Wall  -version -o /tmp/cceCee26.s 

And cc1 prints it's version and config info.

GNU C version 3.3.1 (i686-pc-linux-gnu)  compiled by GNU C version 3.3.1 (i686-pc-linux-gnu) GGC heuristics: --param ggc-min-expand=51   --param ggc-min-heapsize=40036 

Then cc1 tells you what directories it will search for include files.

ignoring nonexistent directory "/usr/i686/include" #include "..." search starts here: #include <...> search starts here:  /usr/local/include  /usr/include  /usr/lib/gcc-lib/i686/3.3.1/include  /usr/include End of search list. 

The compiler is now complete, so gcc tells you the assembler command it will use.

 as -V -Qy -o /tmp/ccQynbTm.o /tmp/cceCee26.s 

And the assembler, as, gives its version info.

GNU assembler version 2.12.90.0.1 (i386-linux) using BFD version 2.12.90.0.1 20020307 Debian/GNU Linux 

The assembler is now done so gcc gives the linker command. It's using collect2 as an intermediary to the real linker ld, but that's not important here.

/usr/lib/gcc-lib/i686/3.3.1/collect2  --eh-frame-hdr -m elf_i386 -dynamic-linker  /lib/ld-linux.so.2 /usr/lib/crt1.o /usr/lib/crti.o  /usr/lib/gcc-lib/i686/3.3.1/crtbegin.o  -L/usr/lib/gcc-lib/i686/3.3.1  -L/usr/lib/gcc-lib/i686/3.3.1/../../.. /tmp/ccQynbTm.o  -lgcc -lgcc_eh -lc -lgcc -lgcc_eh  /usr/lib/gcc-lib/i686/3.3.1/crtend.o  /usr/lib/crtn.o 

The linker gives no verbose output (try -Wl,-v), so that's it.

The "crt" files mean "C RunTime". They are small sections of code inserted at the start of your program, and at the end. They take care of initialising your global variables, heap, and stack. They call atexit functions after you return from main. And some more besides.

Hope that helps.

like image 84
ams Avatar answered Sep 20 '22 14:09

ams