Question

I cam across the following text

The programmer begins by writing the source code in some high-level language—in this case, C.Next, the compiler transforms the foo.c and bar.c source-code files into machine language, creating the object modules foo.o and bar.o. In the code, the programmer has defined variable X in foo.c and variable Y in bar.c; both are located at relative address 100 in their respective object modules. The object modules are placed in secondary storage until requested by the user or another process, at which point the modules must be linked.

What are these relative addresses that are mentioned in the text?

Was it helpful?

Solution

'Economical with truth' version:

Well, you have to link them to make an executable image. The linker supplies a base address for each object module that ensures that offset 100 in each module refers to a different virtual address. It also loads the executable file with header sections that instruct the OS loader how to run it, eg. size of code, data, stack etc sections, relocation data and entry point.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top