Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
245 views
in Technique[技术] by (71.8m points)

c - Running gcc's steps manually, compiling, assembling, linking

If you have a simple C program, like

int main(void) {return 0;}

It can be compiled with gcc -o test test.c.

As I understand, gcc performs compiling, assembling then linking. The latter two steps are achieved by it running as and ld.

I can generate the assembly code by using gcc -S test.c.

What would you type into a terminal, to convert the assembly code into an executable?

(the reason for doing so is to learn assembly)

question from:https://stackoverflow.com/questions/8527743/running-gccs-steps-manually-compiling-assembling-linking

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

These are the different stages using gcc

gcc -E  --> Preprocessor, but don't compile
gcc -S  --> Compile but don't assemble
gcc -c  --> Preprocess, compile, and assemble, but don't link
gcc with no switch will link your object files and generate the executable

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...