Quote:
Originally Posted by
yifangt
Never tried dissection of the executable code from source code. However, this is not what I want to learn.
"What does a compiler and linker do?", and "How do executables work?" are pretty much the same question. An intimate knowledge of assembly language isn't required, though. Do you remember those old choose-your-own-adventure books? "If you say yes, go to page 37, if you say no, go to page 17", etc?
Imagine trying to write one of those. You would
not write "go to page 37" in your draft - you have no idea what page 37 will be, that's your publisher's job. So you write "go to 'grisly death page'".
The publisher sets out all your pages in arbitrary order. They must make sure the beginning goes first, but otherwise the order really doesn't matter since the reader is supposed to jump around anyway. They number each page. And lastly, they change every reference to 'grisly death page' into 'page 37'.
That's
exactly what a linker does, except it numbers by bytes, not pages.
If you want to add compilation to this analogy, just imagine that your publisher is Russian, and makes you send all your writing to a translator first.