What is compiler, linker, loader?

后端 未结 14 991
离开以前
离开以前 2020-12-07 06:48

I wanted to know in depth meaning and working of compiler, linker and loader. With reference to any language preferably c++.

14条回答
  •  我在风中等你
    2020-12-07 07:18

    Hope this helps you a little more.

    First, go through this diagram:

                             (img source->internet)
    

    source->internet

    You make a piece of code and save the file (Source code), then

    Preprocessing :- As the name suggests, it's not part of compilation. They instruct the compiler to do required pre-processing before the actual compilation. You can call this phase Text Substitution or interpreting special preprocessor directives denoted by #.

    Compilation :- Compilation is a process in which a program written in one language get translated into another targeted language. If there is some errors, the compiler will detect them and report it.

    Assemble :- Assemble code gets translated into machine code. You can call assembler a special type of complier.

    Linking:- If these piece of code needs some other source file to be linked, linker link them to make it a executable file.

    There are many process that happens after it. Yes, you guessed it right here comes the role of the loader:

    Loader:- It loads the executable code into memory; program and data stack are created, register gets initialized.

    Little Extra info :- http://www.geeksforgeeks.org/memory-layout-of-c-program/ , you can see the memory layout over there.

提交回复
热议问题