Nepedia
Back to Discover
Advanced Reader
💻

Executable

technology Maturity 11-13 Next article →

An executable is a unique resource used to control a computer's behavior. While all computing information is technically data, executables are distinct. They imply a flow of control, meaning they contain instructions for the computer to follow. People use several different terms to describe this information. You might hear it called executable code, an executable file, an executable program, or an executable image.

Binary executable file2
Binary executable file2

There are different ways that executable information is processed. A native executable uses machine code. This is code that a CPU can execute directly at the instruction level. Other types of executables work differently. A script is executable, but it works indirectly through an interpreter. There is also intermediate executable code, often called bytecode. This code can be interpreted or converted into native code during runtime. This conversion process is known as just-in-time compilation.

Most software is not written in machine language. It is possible to write native executables directly in machine code, but it is not common. Instead, developers write human-readable source code. They use a toolchain to automate the creation of machine code. Many toolchains use a compiler to turn source code into object files. A linker then joins these object files into a single native executable. If a programmer uses assembly language, they use an assembler instead of a compiler. Assembly language is a type of language that is closely associated with machine code instructions.

Executable files must follow specific organizational rules. They are often stored in a digital container format. One common format is the Executable and Linkable Format, or ELF. Another is the Portable Executable, or PE, which depends on the computing context. These formats allow the machine code to be organized into specific sections. The .text section contains the actual executable code. The .data section holds initialized global and static variables. There is also a .rodata section for read-only data, such as constants and strings.

Beyond the code itself, executable files often include a runtime system. This system manages important features while the program is running. It handles tasks like task scheduling and exception handling. It also manages the calling of static constructors and destructors. The runtime system allows the program to interact with the operating system. It helps pass arguments and environment details to the program. It also handles the exit status when a program finishes. It even manages the release of resources, such as file handles.

In the C programming language, these startup and shutdown tasks are handled in a specific way. This is done by linking in an object called crt0. This object contains the actual entry point for the program. It uses a runtime library to perform the necessary setup and shutdown. However, some systems do not need this much extra code. For example, embedded systems might want to omit the usual runtime. In C, a developer can do this by using a linker script. This script explicitly creates the entry point and handles the startup and shutdown processes. This allows the program to call main and then return an exit status to the kernel.

For any file to be executable, it must conform to an application binary interface, or ABI. The complexity of the interface determines how the file is run. In simple interfaces, the computer loads the file into memory. It then jumps to the start of the address space to begin execution. More complicated interfaces require additional metadata. This metadata might specify relocations that must be performed when the program is loaded. It can also specify the exact entry point address where execution should start.

596 words

Where will your curiosity go next?

Keep exploring at your chosen reading level.

🖼️ Images & Media (1)
File:Binary executable file2.png
Binary executable file2.png
More to explore

🔬 Go deeper

More advanced topics to explore

🪜 Step back

Simpler topics to build understanding

What is Nepedia?

A free, ad-free encyclopedia for children. Every article is written at five reading levels, so the same page works for a five-year-old and a fifteen-year-old — use the level switcher above to see this one change. No account needed to read.