In a general computing sense, overlaying means "the process of transferring a block of program code or other data into main memory, replacing what is already stored". Overlaying is a programming method that allows programs to be larger than the computer's main memory. An embedded system would normally use overlays because of the limitation of physical memory, which is internal memory for a system-on-chip, and the lack of virtual memory facilities.
Constructing an overlay program involves manually dividing a program into self-contained object code blocks called overlays or links, generally laid out in a tree structure.[b] Sibling segments, those at the same depth level, share the same memory, called overlay region[c] or destination region. An overlay manager, either part of the operating system or part of the overlay program, loads the required overlay from external memory into its destination region when it is needed; this may be automatic or via explicit code. Often linkers provide support for overlays.
The following example shows the control statements that instruct the OS/360 Linkage Editor to link an overlay program containing a single region, indented to show structure (segment names are arbitrary):
INCLUDE SYSLIB(MOD1) INCLUDE SYSLIB(MOD2) OVERLAY A INCLUDE SYSLIB(MOD3) OVERLAY AA INCLUDE SYSLIB(MOD4) INCLUDE SYSLIB(MOD5) OVERLAY AB INCLUDE SYSLIB(MOD6) OVERLAY B INCLUDE SYSLIB(MOD7)
+--------------+ | Root Segment | | MOD1, MOD2 | +--------------+ | +----------+----------+ | | +-------------+ +-------------+ | Overlay A | | Overlay B | | MOD3 | | MOD7 | +-------------+ +-------------+ | +--------+--------+ | | +-------------+ +-------------+ | Overlay AA | | Overlay AB | | MOD4, MOD5 | | MOD6 | +-------------+ +-------------+
These statements define a tree consisting of the permanently resident segment, called the root, and two overlays A and B which will be loaded following the end of MOD2. Overlay A itself consists of two overlay segments, AA, and AB. At execution time overlays A and B will both utilize the same memory locations; AA and AB will both utilize the same locations following the end of MOD3.
All the segments between the root and a given overlay segment are called a path.
As of 2015[update], most business applications are intended to run on platforms with virtual memory. A developer on such a platform can design a program as if the memory constraint does not exist unless the program's working set exceeds the available physical memory. Most importantly, the architect can focus on the problem being solved without the added design difficulty of forcing the processing into steps constrained by the overlay size. Thus, the designer can use higher-level programming languages that do not allow the programmer much control over size (e.g. Java, C++, Smalltalk).
Still, overlays remain useful in embedded systems. Some low-cost processors used in embedded systems do not provide a memory management unit (MMU). In addition many embedded systems are real-time systems and overlays provide more determinate response-time than paging. For example, the Space Shuttle Primary Avionics System Software (PASS) uses programmed overlays.
IBM introduced the concept of a chain job  in FORTRAN II, The program had to explicitly call the CHAIN subroutine to load a new link, and the new link replaced all of the old link's storage except for the Fortran COMMON area.
In OS/360, IBM extended the overlay facility of IBLDR by allowing an overlay program to have independent overlay regions, each with its own overlay tree. OS/360 also had a simpler overlay system for transient SVC routines, using 1024-byte SVC transient areas.
In the home computer era overlays were popular because the operating system and many of the computer systems it ran on lacked virtual memory and had very little RAM by current standards: the original IBM PC had between 16K and 64K, depending on configuration. Overlays were a popular technique in Commodore BASIC to load graphics screens. In order to detect when an overlay was already loaded, a flag variable could be used.
"Several DOS linkers in the 1980s supported [overlays] in a form nearly identical to that used 25 years earlier on mainframe computers." Binary files containing memory overlays had a de facto standard extension, .OVL. This file type was used among others by WordStar, dBase, and the Enable DOS office automation software package from Enable Software, Inc. The GFA BASIC compiler was able to produce .OVL files.
- "Oxford Dictionaries". 2015-11-26.
- Butterfield, Jim (June 1986). "Part 4: Overlaying". Loading And Linking Commodore Programs. Compute!. p. 74.
This lets you run programs which are, in effect, much larger than the amount of memory in your computer.
- "The GNU Linker documentation: Overlay Description". 2008-06-03.
- Levine, John R. (2000). Linkers & Loaders. Morgan Kaufmann Publishers. p. 177. ISBN 1-55860-496-0. 
- "An Assessment of Space Shuttle Flight Software Development Processes". Retrieved 2012-10-29.
- "Chapter 12 The Chain Job" (PDF). IBM 7090/7094 Programming Systems - FORTRAN II Programming (PDF). Systems Reference Library. IBM. August 1963. pp. 34–35. C28-6054-4.
- IBM 7090/7094 Programming Systems - IBJOB Processor - Overlay feature of IBLDR (PDF). Systems Reference Library. IBM. 1963. C28-6331.
- IBM 7090/7094 Programming Systems IBJOB Processor Overlay Feature of IBLDR (PDF). Systems Reference Library (First ed.). IBM Corporation. May 1963. C28-6331. Retrieved 2021-12-26.
- IBM OS Linkage Editor and Loader (PDF). Release 21. IBM Corporation. March 1972 [January 1972]. p. 244. GC28-6538.