1

It's said, Compile time -- When it is known at compile time where the process will reside, compile time binding is used to generate the absolute code. Here I'm not sure what is the absolute code?

Load time -- When it is not known at compile time where the process will reside in memory, then the compiler generates re-locatable code. What's re-locatable code?

Execution time -- If the process can be moved during its execution from one memory segment to another, then binding must be delayed to be done at run time.

If I have a simple C program, like Hello World.c

What mechanism Linux usually use from three choices above to allocate the process to run the hello world program?

3

I think those concepts are better described in this reference, titled: Ceng 328 Operating Systems Lecture Notes - Addressing.

excerpt

  • Addresses may be represented in different ways during these steps.
    • Addresses in the source program are generally symbolic (such as $count$).
    • A compiler will typically bind these symbolic addresses to relocatable addresses (such as "14 bytes from the beginning of this module").
    • The linkage editor or loader will in turn bind the relocatable addresses to absolute addresses (such as 74014).
    • Each binding is a mapping from one address space to another.
    • Classically, the binding of instructions and data to memory addresses can be done at any step along the way:
      • Compile time. The compiler translates symbolic addresses to absolute addresses. If you know at compile time where the process will reside in memory, then absolute code can be generated (Static).
      • Load time. The compiler translates symbolic addresses to relative (relocatable) addresses. The loader translates these to absolute addresses. If it is not known at compile time where the process will reside in memory, then the compiler must generate relocatable code (Static).
      • Execution time. If the process can be moved during its execution from one memory segment to another, then binding must be delayed until run time. The absolute addresses are generated by hardware. Most general-purpose OSs use this method (Dynamic).
  • Static-new locations are determined before execution. Dynamic-new locations are determined during execution.

Further readings

If you're interested in this topic I'd encourage you to read the following Wikipedia pages.

A good example of the differences between early and late binding times is covered here: Binding times, as well as here in this article titled: Early vs Late Binding.

  • Thanks for this. What exactly is binding and how it happens? – mkc Feb 5 '14 at 4:28
  • @Ketan - it's a bit of a complex topic to try and explain here. Basically the compiler (gcc) goes through your code and puts place holders in locations where a function is being called. These are symbols. These symbols can either be done in such a way so that they're later replaced with actual code (static compile) or can point in a relative manner to a library that has the code that backs this particular function (dynamic compile). I don't want to elaborate b/c this entire topic is borderline off-topic for this site. – slm Feb 5 '14 at 4:35
  • This explains the dynamic dispatch mechanisms: en.wikipedia.org/wiki/Virtual_method_table. The name bindings are explained further here: en.wikipedia.org/wiki/Name_binding – slm Feb 5 '14 at 4:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.