Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1113009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:47:34+00:00 2026-05-17T02:47:34+00:00

I have a set of *.C files (embedded related). What are the steps/processes (internal

  • 0

I have a set of *.C files (embedded related).

What are the steps/processes (internal information) involved while compiling followed by linking to create the final executable? (Information/steps regarding what a preprocessor/compiler generally performs to a C src code.)

What is the general structure of the final executable (eg: headers followed by symbol tables etc.)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T02:47:34+00:00Added an answer on May 17, 2026 at 2:47 am

    With gcc for example I think the option to use is -save-temps.

    Roughly the steps are to make a pass on the file to pull all the includes in and create essentially a single file to be parsed. A lot of tools these days use a parser that runs on a set of rules (bison, yacc, flex, etc) the goal being to parse the ascii turning your program into a sort of very wide assembly language for lack of a better term.

    a = a + 1;
    

    could turn into

    Load variable named a, size of blah, type unsigned foo
    load immediate 1, size blah, unsigned
    add
    store result a
    

    Then there are optimizations that can occur, the compilers intermediate language may have an increment function and determine that increment is better than the load of a 1 and an add. Eventually those optimizations are complete, and this intermediate code goes through a backend to the target instruction set. This is typically output as assembly and that is fed into an assembler which turns it into an object file, and target specific optimizations can occur. Then object files are fed into the linker which, well, links them together. One function in one program may be calling a function not in that object file named bob, the object file does not have an address or offset to reach bob it leaves a hole there for the address to be inserted and the linkers job is to connect all of these, decide where in the binary the function bob will live (assign it an address) then go find all the places that call bob and when those are placed in memory insert the instruction or address needed to allow bob to be called, so that the end result is an executable binary.

    llvm which is already a competitor to gcc, provides good visibility into this process. you can have the C code compiled to an intermediate. Start with our bob function

    unsigned int bob ( unsigned int a )
    {
        return(a+1);
    }
    

    compile to bitcode

    clang -c -o bob.bc -emit-llvm bob.c
    

    disassemble the bitcode to human readable form

    llvm-dis bob.bc
    

    Which results in bob.ll

    define i32 @bob(i32 %a) nounwind {
    entry:
      %a.addr = alloca i32, align 4
      store i32 %a, i32* %a.addr, align 4
      %tmp = load i32* %a.addr, align 4
      %add = add i32 %tmp, 1
      ret i32 %add
    }
    

    Unoptimize code likes to be stored and fetched from memory often, and when passed into a function stored and fetched from the stack often.

    In addition to easily letting you see behind the curtain, llvm is nice because you can optimize at any level, combine objects and optimize at the whole program level where gcc is going to limit you to file or function level only. So we can optimize this bitcode.

    opt -std-compile-opts bob.bc -o bob_opt.bc
    llvm-dis bob_opt.bc
    

    And those extra stores and loads are gone and the meat of the function remains.

    define i32 @bob(i32 %a) nounwind readnone {
    entry:
      %add = add i32 %a, 1
      ret i32 %add
    }
    

    Then llc is used to turn that into assembler for the desired target

    llc -march=arm bob.bc
    cat bob.s
    ...
    bob:                                    @ @bob
    @ BB#0:                                 @ %entry
        str r0, [sp, #-4]!
        add r0, r0, #1
        add sp, sp, #4
        bx  lr
    ...
    llc -march=arm bob_opt.bc
    cat bob_opt.s
    ...
    bob:                                    @ @bob
    @ BB#0:                                 @ %entry
        add r0, r0, #1
        bx  lr
    ...
    

    Yes, there are many many books out there. And many many compilers, etc. In addition to llvm, Fabrice Bellard (yes the qemu person), has a super simple, barely a compiler that produces an intermediate file that you can examine http://bellard.org/fbcc/ which is buried such that it is hardly known, fun to look at though if you are just getting into the guts of compilers. In addition there is one more well, known ,tcc http://bellard.org/tcc/ this one specifically does not have a backend that goes through an assembler, opcodes are generated directly both for speed and for real time (re)compiliation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have set of flat files (114 files) each file is named with database
I have a set of files in a single directory named: OneThing-x.extension OneThing-y.extension OneThing-z.extension
I have a set of zip files which contains several ieee-be encoded binary and
I have a set of html files that I want to modify by replacing
I have a set of WMV files that I need to convert to H.264.
I have a set of .php files in a folder, I want to add
I have a set of 10000 files. In all of them, the second line,
I have a set of .csv files that I want to process. It would
I have a massive set of files (4000+) that are in an old Apple
I have a set of Java 5 source files with old-style Doclet tags, comments

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.