Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I was wondering what the loaders in Linux and Windows are called, i.e., their command names? Loaders' definitions are

In computing, a loader is the part of an operating system that is responsible for loading programs.

share|improve this question
add comment

5 Answers

up vote 5 down vote accepted

There's at least 3 things that you could call "loaders" in Linux. The "ld" part of a compile, that puts together various object (.o) and archive (.a) files into a single executable is one. "ld" also checks shared object (.so) files to see if the dynamic linker can work correctly.

The dynamic linker (do man ld.so for details) gets run by the Linux kernel as part of starting up an ELF format executable. It reads linking information from the ELF file, and then (at least) maps in shared object files (.so suffix). The details are rather involved, and at least sometimes involve updating the GOT, a section in memory that maps a compiled-in branch destination to the actual, as-loaded address of the library code. See: http://netwinder.osuosl.org/users/p/patb/public_html/elf_relocs.html for a lot of details.

There's also a piece of the Linux kernel that reads in executable files, that's sometimes called a "loader". When you configure a linux kernel, you can choose to include or exclude some of these executable file formats (a.out, mainly) loaders. I had the code of linux 2.6.20.9 lying about, and I found "loaders" for different executable formats in linux-2.6.20.9/fs/: binfmt_aout.c, binfmt_elf.c, binfmt_script.c, and a few others.

I know next to nothing of how Windows does this same process, but it must do most or all of the same things.

share|improve this answer
    
Thanks! So is "program loader" in my questions the same thing mentioned in your third paragraph? Is it also done by "ld" in linux? –  Tim Jul 25 '11 at 15:38
    
Also is ld.so part of the "loader" piece of Linux kernel that reads in executables? Does ld.so run during loading the executables or during running executables –  Tim Jul 25 '11 at 16:57
    
I wasn't entirely sure from how you worded it, but I believe the linux kernel pieces are what you were talking about. "ld.so" is not part of the kernel: it's in a file /lib/ld-linux.so.2 on my 2 x86 linux boxes, and it's called by the kernel part based on the ".interp" ELF section. –  Bruce Ediger Jul 25 '11 at 22:25
    
ld.so is the a.out loader. ld-linux.so is the ELF Linux loader. –  JohnTortugo Jun 21 '13 at 18:04
add comment

The loader is part of the kernel and usually called as part of a system call. It's not a named command you type in on the command line. Instead, the shell (command line or GUI) calls it when you do things like press enter after a command or double-click an icon.

share|improve this answer
1  
I think with loader he meant programs like the ld program for linux e.g., too, the program loader. –  Falcon Jul 25 '11 at 14:09
    
ld isn't really a loader, it's more of a linker (it resolves external symbol references and creates the "load file"). I think the original question was aimed more at the concept of reading an executable from disk and initializing the run-time (although I could be mistaken). –  TMN Jul 25 '11 at 17:43
add comment

As @falcon noted, the Linux loader is called "ld." In Windows, I don't know how much of the details of program loading and execution are actually made public.

share|improve this answer
add comment

The crux of the idea here is that the OS is driving the program loading. There isn't a direct command to load a program in either Linux or Windows, this is all handled by the OS itself. In this process the OS allocates memory, stack/heap space, any registers that are needed, and a program status register - that keeps track of all of this for when processes are suspended/interrupted. This is how "protected/user" mode saves us from blowing up a computer because we constantly triple-fault because we're using commands that shouldn't be being used (most of this is done in ring 0 - ie real mode, much removed from us).

The item that others are pointing you to are .exe's .bin's and the linker/loader for gcc/asm/etc which only set up a file for when the OS calls the loading of the program, these still do not directly affect the loading of the program (because you can call ld to actually toss the program in RAM and set up the registers, although you can call it to tell the program how to compile so that it says I want to load registers x, y, and z and start in memory location 0x0000FFFF....) and diety / os willing it'll put that there.

share|improve this answer
    
Thanks! In "you can call ld to actually toss the program in RAM and set up the registers, although you can call it to tell the program how to compile so that it says I want to load registers x, y, and z and start in memory location 0x0000FFFF....", do you mean "ld" is just a linker for compilation, or also a loader for starting running an executable? –  Tim Jul 25 '11 at 16:12
    
ld tells how the compiler should link the the code in machine code. In this one can specify parameters for how the code should be linked together. One can't directly specify the exact address in RAM that the program will go, but it can specify things like the offset of the code, and should certain parts of the program be section/head/page aligned and how it should treat these sections. The OS has protections against you placing things yourself into RAM and hard disk space, with various interrupts being thrown if you attempt to make manual changes. –  Jeff Langemeier Jul 25 '11 at 16:22
add comment

Strictly answering: Nothing.

Commands to load programs do not exist as commands. For simple reason, that typically, any OS command is actually a program. Then how can you load the program, which is supposed to load other programs, when the program itself needs to be loaded in first place ?

If you drill through sematics of definition... Then the best answer is "shell". Shell is the command to load other programs (which are commands).

In Windows it is: explorer.exe, cmd.exe, debug.exe and may be few more

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.