This question is in continuation of How does compiler lay out code in memory, which is posted at stack-overflow.
I have few questions with respect to ld
(GNU) utility available in Linux.
Whenever a program is run in the shell, say ./a.out
, the shell uses ld
to load the program represented by a.out
.
How does the shell know it has to use
ld
to loada.out
. Does it scan thea.out
to check if it is in the ELF format and if so, usesld
? It certainly can't use the file name extension, since there is no rule to name executable's in a certain format.Can
ld
utility load programs represented in any other executable formats other than ELF?Suppose I come up with my own executable format, say "xyz" and I write my own loader
abc
which handles such executables. Then, is there any shell command to configure: "use loaderabc
to load program compiled in a particular executable format "xyz"?