Linker: Linker is a program that takes one or more objects generated by a compiler and combines them into a single executable program.
Linker is a program that takes one or more objects generated by a compiler and combines them into a single executable program.
Once a linker has scanned all of the input files to determine segment sizes, symbol definitions and symbol references, figured out which library modules to include, and decided where in the output address space all of the segments will go, the next stage the heart of the linking process, relocation is. We use relocation to refer both to the process of adjusting program addresses to account for non-zero segment origins, and the process of resolving references to external symbols, since the two are frequently handled together. The linker's first pass lays out the positions of the various segments and collects the segment-relative values of all global symbols in the program. Once the linker determines the position of each segment, it potentially needs to fix up all storage addresses to reflect the new locations of the segments. On most architecture, addresses in data are absolute, while those embedded in instructions may be absolute or relative. The linker needs to fix up accordingly, as we'll discuss later
Loaders: Loader is the part of an operating system that is responsible for loading programs from executable (i.e., executable files) into memory, preparing them for execution and then executing them.
Loader is the part of an operating system that is responsible for loading programs from executable (i.e., executable files) into memory, preparing them for execution and then executing them. In computing, a loader is the part of an operating system that is responsible for loading programs. 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 a program involves reading the contents of executable file, the file containing the program text, into memory, and then carrying out other required preparatory tasks to prepare the executable for running. Once loading is complete, the operating system starts the program by passing control to the loaded program code.
Assuming you understand that, here's what each stage does in brief:
Linking : The compiler generates object files from the source files. Generally each source file results in one object file. Now, these object files contain information (symbols, to be precise) referred to/defined only in that file. So, for example, you have files A.c and B.c. B.c calls a function defined in A.c. Then B's object file would an undefined symbol - a symbol used but not defined in the same file.
To resolve these symbols, the compiler has to link these files, so that the compiler can resolve the undefined symbol in B and point it to the definition in A.
The linker thus links these files together, resolving the references in the process and generating an executable or a library for future use.
You also have static linking and dynamic linking. Read up on the wikipedia article for more details - Linker.
Loader : A loader is actually a part of the operating system and not the compiler. As its name implies, it is responsible for copying the executable file generated by linking into memory and performing any preparatory tasks. The OS then executes the loaded program depending on when it is scheduled for execution.
(See also : Loader)
Locator : As far as I can recall, a locator is used in embedded systems to determine which addresses are free in the system, generate a map of the linked file to be placed at an address and places it at that address. In an embedded system, using a loader to track free space can be expensive, and you generally do not load a program at different addresses on each run. The locator thus fixes the address for a program and glues it at that address. It thus takes the place of the loader in an embedded system.
(This is what I can remember for a locator, but I may be wrong. Would be helpful if someone can verify this)