Can someone explain me what do we exactly mean by relocatable object code ? I know that it is used by linker/loader to create an executable. What is the exact advantage of relocatable object code ?
When code is compiled and linked into a runnable unit, addresses are assigned to the functions and variables. When the unit is loaded into memory to be executed, what happens if these addresses are already allocated? Obviously, they must be moved to the actual address where they actually reside.
In MS-DOS, .COM files were memory images (non relocateable) and constrained to a segment, whereas .EXE files were relocateable and could use any (and possibly many) segments.
Unix shared libraries and Windows DLLs must be relocateable.