nebulaf91
nebulaf91

Reputation: 1

Where's the header files information in the compiled file (assemble file)?

I used the GCC -E command, and I can see the #include files are pasted in after preprocessing. But when I use the GCC -S command, in the generated assemble file(.s), I can't find information about my header files.(More specifically, whether I comment the #include instruction, I get the same .s file). Next step I can use gcc -o *.s to assemble and link my .s file. But where did GCC get the header file information?

Upvotes: 0

Views: 186

Answers (1)

Jean-François Fabre
Jean-François Fabre

Reputation: 140168

The #include statements in the preprocessed outputs are there to link to the header file in case the compiler finds an error and wants to notify the user about the specific location of the error ("included in xxx.h")

But all code/declarations contained in the #include (provided they match the proper #ifdef/#if conditions) are expanded in the preprocessed output. Only this code/declaration stuff is used by the compiler to produce the assembly / binary object file, no more need for the headers at that point.

So your assembly code has already integrated the information of the header files (structure offsets, constants, type sizes...) and it's no longer C anymore, it's assembly.

Upvotes: 1

Related Questions