Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Loader (computing)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Part of an operating system}} {{for|applications that speed up loading from a tape or disk drive|fast loader}} {{Refimprove|date=June 2008}} In [[computing|computer systems]] a '''loader''' is the part of an [[operating system]] that is responsible for loading [[computer program|programs]] and [[Library (computing)|libraries]]. It is one of the essential stages in the process of starting a program, as it places programs into memory and prepares them for execution. Loading a program involves either [[memory-mapped file|memory-mapping]] or copying the contents of the [[executable|executable file]] containing the program instructions into memory, and then carrying out other required preparatory tasks to prepare the executable for running. Once loading is complete, the operating system starts the program by passing control to the loaded program code. All operating systems that support program loading have loaders, apart from highly specialized computer systems that only have a fixed set of specialized programs. [[Embedded system]]s typically do not have loaders, and instead, the code executes directly from ROM or similar. In order to load the operating system itself, as part of [[booting]], a specialized [[boot loader]] is used. In many operating systems, the loader resides permanently in memory, though some operating systems that support [[virtual memory]] may allow the loader to be located in a region of memory that is [[paging|pageable]]. In the case of operating systems that support virtual memory, the loader may not actually copy the contents of executable files into memory, but rather may simply declare to the virtual memory subsystem that there is a mapping between a region of memory allocated to contain the running program's code and the contents of the associated executable file. (See [[memory-mapped file]].) The virtual memory subsystem is then made aware that pages with that region of memory need to be filled on demand if and when program execution actually hits those areas of unfilled memory. This may mean parts of a program's code are not actually copied into memory until they are actually used, and unused code may never be loaded into memory at all. ==Responsibilities== In [[Unix]], the loader is the [[callback (computer science)|handler]] for the [[system call]] <code>execve()</code>.<ref>{{cite web |url=http://www.opengroup.org/onlinepubs/000095399/functions/exec.html |title=exec |publisher=The Open Group |work=The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition |access-date=2008-06-23}}</ref> The Unix loader's tasks include: # validation (permissions, memory requirements etc.); # [[memory-mapped file|memory-mapping]] the executable object from the disk into [[main memory]]; # copying the [[command-line argument]]s into virtual memory; # initializing [[Processor register|registers]] (e.g., the stack pointer); # jumping to the program entry point (<code>_start</code>). In [[Microsoft Windows]] 7 and above, the loader is the <code>LdrInitializeThunk</code> function contained in [[ntdll.dll]], which does the following: # initialisation of structures in the DLL itself (i.e. [[critical section]]s, module lists); # validation of executable to load; # creation of a [[dynamic memory allocation|heap]] (via the function <code>RtlCreateHeap</code>); # allocation of environment variable block and PATH block; # addition of executable and NTDLL to the module list (a [[doubly-linked list]]); # loading of [[KERNEL32.DLL]] to obtain several important functions, for instance <code>BaseThreadInitThunk</code>; # loading of executable's imports (i.e. [[dynamic-link library|dynamic-link libraries]]) recursively (check the imports' imports, their imports and so on); # in debug mode, raising of system breakpoint; # initialisation of DLLs; # garbage collection; # calling <code>NtContinue</code> on the context parameter given to the loader function (i.e. jumping to <code>RtlUserThreadStart</code>, that will start the executable) ==Relocating loaders== Some operating systems need [[relocating loader]]s, which adjust addresses (pointers) in the executable to compensate for variations in the address at which loading starts. The operating systems that need relocating loaders are those in which a program is not always loaded into the same location in the (virtual) address space and in which pointers are absolute addresses rather than offsets from the program's [[base address]]. Some well-known examples are IBM's [[OS/360]] for their [[System/360]] mainframes, and its descendants, including [[z/OS]] for the [[z/Architecture]] mainframes. ===OS/360 and derivatives=== In OS/360 and descendant systems, the (privileged) operating system facility is called IEWFETCH,<ref>{{cite book|last=IBM Corporation|title=IBM OS MVT Supervisor|year=1972|url=http://bitsavers.informatik.uni-stuttgart.de/pdf/ibm/360/os/R21.0_Mar72/plm/GY28-6659-6_MVT_Supervisor_PLM_Release_21_Mar72.pdf}}</ref> and is an internal component of the OS Supervisor, whereas the (non-privileged) LOADER application can perform many of the same functions, plus those of the Linkage Editor, and is entirely external to the OS Supervisor (although it certainly uses many Supervisor services). IEWFETCH utilizes highly specialized [[Channel_I/O#Channel_command_words|channel programs]], and it is theoretically possible to load and to relocate an entire executable within one revolution of the DASD media (about 16.6 ms maximum, 8.3 ms average, on "legacy" 3,600 rpm drives). For load modules which exceed a track in size, it is also possible to load and to relocate the entire module without losing a revolution of the media. IEWFETCH also incorporates facilities for so-called overlay structures, and which facilitates running potentially very large executables in a minimum memory model (as small as 44 KB on some versions of the OS, but 88 KB and 128 KB are more common). The OS's [[Kernel (operating system)|nucleus]] (the always resident portion of the Supervisor) itself is formatted in a way that is compatible with a stripped-down version of IEWFETCH. Unlike normal executables, the OS's nucleus is "scatter loaded": parts of the nucleus are loaded into different portions of memory; in particular, certain system tables are required to reside below the initial 64 KB, while other tables and code may reside elsewhere. The system's [[Linker (computing)#Linkage editor|Linkage Editor]] application is named IEWL.<ref>{{cite book|last=IBM Corporation|title=IBM OS Linkage Editor and Loader|year=1972|url=http://bitsavers.informatik.uni-stuttgart.de/pdf/ibm/360/os/R21.0_Mar72/GC28-6538-9_OS_Linkage_Editor_and_Loader_Release_21_Jan72.pdf}}</ref> IEWL's main function is to associate load modules (executable programs) and object modules (the output from, say, assemblers and compilers), including "automatic calls" to libraries (high-level language "built-in functions"), into a format which may be most efficiently loaded by IEWFETCH. There are a large number of editing options, but for a conventional application only a few of these are commonly employed. The load module format includes an initial "text record", followed immediately by the "relocation and/or control record" for that text record, followed by more instances of text record and relocation and/or control record pairs, until the end of the module. The text records are usually very large; the relocation and/or control records are small as IEWFETCH's three relocation and/or control record buffers are fixed at 260 bytes (smaller relocation and/or control records are certainly possible, but 260 bytes is the maximum possible, and IEWL ensures that this limitation is complied with, by inserting additional relocation records, as required, before the next text record, if necessary; in this special case, the sequence of records may be: ..., text record, relocation record, ..., control record, text record, ...). A special byte within the relocation and/or control record buffer is used as a "disabled bit spin" communication area, and is initialized to a unique value. The Read CCW for that relocation and/or control record has the Program Controlled Interrupt bit set. The processor is thereby notified when that CCW has been accessed by the channel via a special [[Input/Output Supervisor|IOS]] exit. At this point the processor enters the "disabled bit spin" loop (sometimes called "the shortest loop in the world"). Once that byte changes from its initialized value, the CPU exits the bit spin, and relocation occurs, during the "gap" within the media between the relocation and/or control record and the next text record. If relocation is finished before the next record, the NOP CCW following the Read will be changed to a TIC, and loading and relocating will proceed using the next buffer; if not, then the channel will stop at the NOP CCW, until it is restarted by IEWFETCH via another special IOS exit. The three buffers are in a continuous circular queue, each pointing to its next, and the last pointing to the first, and three buffers are constantly reused as loading and relocating proceeds. IEWFETCH can, thereby, load and relocate a load module of any practical size, and in the minimum possible time. ==Dynamic linkers== [[Dynamic linker|Dynamic linking loaders]] are another type of loader that load and link [[shared libraries]] (like [[Executable and Linkable Format|.so files]], [[dynamic link library|.dll files]] or .dylib files) to already loaded running programs. Where such shared libraries can be shared by multiple processes, with only one single copy of the shared code possibly appearing at a different (virtual) address in each process's address space, the code in the shared library is required to be relocatable, ie the library must only use self-relative or code segment base-relative internal addresses throughout. Some processor have instructions that can use self-relative code-references in order to facilitate this. ==See also== {{Portal|Computer programming}} {{Div col|colwidth=20em}} * [[Compile and go system]] * [[DLL hell]] * [[Direct binding]] * [[Dynamic binding (computing)]] * [[Dynamic dead code elimination]] * [[Dynamic dispatch]] * [[Dynamic library]] * [[Dynamic linker]] * [[Dynamic loading]] * [[Dynamic-link library]] * [[GNU linker]] * [[Library (computing)]] * [[Linker (computing)]] * [[Name decoration]] * [[Prebinding]] * [[Prelinking]] * [[Relocation (computer science)]] * [[Relocation table]] * [[Shebang (Unix)]] * [[Static library]] * [[gold (linker)]] * [[prelink]] * [[Bug compatibility]] {{div col end}} ==References== {{reflist}} {{Application binary interface}} {{Authority control}} {{DEFAULTSORT:Loader (Computing)}} [[Category:Operating system kernels]] [[Category:Computer libraries]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Application binary interface
(
edit
)
Template:Authority control
(
edit
)
Template:Cite book
(
edit
)
Template:Cite web
(
edit
)
Template:Div col
(
edit
)
Template:Div col end
(
edit
)
Template:For
(
edit
)
Template:Portal
(
edit
)
Template:Refimprove
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)