What is Relocating Loader in System Programming?

What is Relocating Loader in System Programming?

Sure. To fully understand the concept of a relocating loader, you need to have some familiarity with operating systems, program loading, and memory management. Let's break it down:

What is a Loader?

In computer systems, a loader is the part of an operating system that is responsible for loading programs and libraries. It is one of the essential stages in the process of starting a program, as it places programs into memory and prepares them for execution.

Loading involves reading the contents of the executable file containing the program instructions into memory, and then carrying out other necessary preparatory tasks to prepare the executable for running.

What is a Relocating Loader?

A relocating loader is a type of loader that can load the program into different regions of memory at different times during execution. This process allows better utilization of the system's memory.

The term "relocating" refers to the ability of the loader to adjust, or "relocate", the absolute addresses in a program so that it can be loaded at an address different from the one originally specified for it.

It achieves this by modifying the object code of a program based on the offset address, which is the starting address where the program is loaded in main memory.

For instance, if a program has an instruction that refers to a memory location, the address of that memory location is determined when the program is assembled or compiled.

If the program is later loaded into a different part of memory, the addresses referred to by those instructions will be incorrect. The relocating loader adjusts these addresses based on the new location of the program in memory.

Absolute Loader Vs Dynamic Loader

1. Absolute Loader: An absolute loader assumes that a program can be loaded at a specific memory address. Once loaded, the program must remain at that address throughout its execution. If that specific address is not available, or if the program has to be moved during its execution, the absolute loader cannot handle this. In contrast, a relocating loader adjusts the program so it can be loaded at different addresses.

2. Dynamic Loader: A dynamic loader, as used in modern operating systems, is even more flexible. It not only allows programs to be loaded at different memory addresses, but it also allows parts of the program to be loaded and unloaded as needed during the program's execution, which can save memory.

However, this requires the programs to be written in a way that supports dynamic loading, and it requires support from the operating system. A relocating loader does not provide this level of flexibility.

Overall, the concept of a relocating loader is an important part of the history of memory management in computer systems, and forms the basis for more advanced techniques used in modern systems.

Example of a Relocating Loader:

The best examples of relocating loaders are found in early operating systems. Here's a simple hypothetical scenario to illustrate how a relocating loader would work:

Imagine an operating system that starts each program at memory address 0. A programmer writes a program that uses memory addresses 0 through 999, and compiles it. The compiled program includes instructions that refer to these memory addresses.

However, when the program is loaded into memory, another program is already using memory addresses 0 through 999. So, the operating system decides to load the new program starting at memory address 1000.

An absolute loader would not be able to handle this situation, because the new program's instructions refer to addresses 0 through 999, not 1000 through 1999.

But a relocating loader can adjust these addresses as it loads the program. The loader would add 1000 to each memory address in the program's instructions, so they refer to the correct memory locations.

Relocating Loader vs Direct Linking Loader:

A Direct Linking Loader (DLL) is a type of loader that combines several program modules (each compiled separately) into a single program that can be executed in memory.

In other words, a direct linking loader resolves all the symbolic references among different object programs while loading them into memory.

The main difference between a relocating loader and a direct linking loader involves the ability to handle multiple program modules:

  1. Relocating Loader: A relocating loader primarily concerns itself with adjusting memory addresses to allow a single program module to be loaded at a different location in memory than it was originally designed for.

  2. Direct Linking Loader: A direct linking loader goes a step further, allowing multiple program modules to be combined and loaded into memory, with the appropriate adjustments made for memory addresses. It is capable of resolving references between these modules, allowing for more complex programs that are composed of multiple modules that have been separately compiled.

It's important to note that these capabilities aren't mutually exclusive. Many modern loaders, like those in Unix-based or Windows operating systems, combine these capabilities: they can load programs at different memory locations (like a relocating loader) and combine multiple program modules into a single program (like a direct linking loader).

These modern loaders also support dynamic loading and linking, providing even greater flexibility.

Replies

  • sushant005
    sushant005
    It is a type of loader which load the program anywhere in the program.
    Initially the programmers write their main program is so that it would transfer to the location assigned to the square root subroutine(SQRT).
    the problem associated with this was that if the length of the program increased that may overlay the SQRT subroutine so to avoid this problem programmer used the subroutine that referred to each other symbolically rather then with the address part of the program.So the Relocating loader placed the subroutine in arbitrary core location.
  • vishnu priya
    vishnu priya
    The relocating loader will load the program anywhere in memory, altering the various addresses as required to ensure correct referencing. The decision as to where in memory the program is placed is done by the Operating System, not the programs header file. This is obviously more efficient, but introduces a slight overhead in terms of a small delay whilst all the relative offsets are calculated. The relocating loader can only relocate code that has been produced by a linker capable of producing relative code.
  • sushant005
    sushant005
    @ Kangyuataii,
    What you have written is totally making no sense to what is being asked in this thread.
    please don't copy paste and read the question again it is about what is relocating loader?
  • Ankita Katdare
    Ankita Katdare
    #-Link-Snipped-# That's a really informative reply! Thank you.
  • pratik bembalkar
    pratik bembalkar

    what is direct linking loader?

You are reading an archived discussion.

Related Posts

If we try to define it, it is something like : A reprogrammable, multifunctional manipulator designed to move material, parts, tools, or specialized devices through various programmed motions for the...
I am a beginner in Windows API. I want to add a button to a window. Please share some light on Buttons in Windows API. 😀
What ideas would you recommend for fixing the world's worst ever oil spill - BP Oil Spill? Waiting for ideas. Few of the ideas BP is considering (as far as...
hi every one,i m in urgent need of this one, please if anyone can help me, i will be grateful to you all people,.i need c compiler for 64 bit...
If you have strong determination no one can stop you to achieve what you want? chennai: There were many hurdles on Patricia Narayan's way to become an entrepreneur. She has...