Executable: Difference between revisions
imported>InklingF |
imported>DreamRimmer bot II m Standardise list-defined references format (bot) |
||
| Line 1: | Line 1: | ||
{{Short description| | {{Short description|Data that causes a computer to follow indicated instructions}} | ||
{{About|a general type of | {{About|a general type of data|the specific file type used in some operating systems|.exe}} | ||
{{Use dmy dates|date=December 2021|cs1-dates=y}} | {{Use dmy dates|date=December 2021|cs1-dates=y}} | ||
{{Use list-defined references|date=December 2021}} | {{Use list-defined references|date=December 2021}} | ||
| Line 6: | Line 6: | ||
[[File:Binary executable file2.png|thumb|A [[hex dump]] of an executable [[real mode]] loader. The first column consists of [[byte address|address]]es of the first byte in the second column, which comprises bytes of data in [[hexadecimal]] notation ([[Bit numbering#Bit significance and indexing|least significant byte]] first), and the last column consists of the corresponding [[ASCII]] form.<ref name="Celovi_2022"/>]] | [[File:Binary executable file2.png|thumb|A [[hex dump]] of an executable [[real mode]] loader. The first column consists of [[byte address|address]]es of the first byte in the second column, which comprises bytes of data in [[hexadecimal]] notation ([[Bit numbering#Bit significance and indexing|least significant byte]] first), and the last column consists of the corresponding [[ASCII]] form.<ref name="Celovi_2022"/>]] | ||
In [[computer | In [[computing]], an '''executable''' is a [[computer resource|resource]] that a [[computer]] can use to control its behavior. As with all information in computing, it is [[data]], but distinct from data that does not imply a [[control flow|flow of control]].<ref name="Mueller_2007" /> Terms such as '''executable code''', '''executable file''', '''executable program''', and '''executable image''' describe forms in which the information is represented and stored. A '''native executable''' is [[machine code]] and is directly executable at the [[instruction (computer science)|instruction level]] of a [[central processing unit|CPU]].<ref name="MW_2008"/><ref name="GFG_2015"/> A [[Script (computer programming)|script]] is also executable although indirectly via an [[interpreter (computing)|interpreter]]. Intermediate executable code (such as [[bytecode]]) may be interpreted or converted to native code at runtime via [[just-in-time compilation]]. | ||
==Native executable== | |||
Even though it is technically possible to write a native executable directly in machine language, it is generally not done. It is far more convenient to develop software as [[human readable]] [[source code]] and to automate the generation of machine code via a [[software build|build]] [[toolchain]]. Today, most source code is a [[high-level language]] although it is still possible to use [[assembly language]] which is closely associated with machine code instructions. Many toolchains consist of a [[compiler]] that generates native code as a set of [[object file]]s and a [[linker (computing)|linker]] that generates a native executable from the object and other files. For assembly language, typically the translation tool is called an [[Assembler (computing)|assembler]] instead of a compiler. | |||
Object files are typically stored in a [[digital container format]] that supports structure in the machine code {{endash}} such as [[Executable and Linkable Format]] (ELF) or [[Portable Executable]] (PE), depending on the computing context.<ref name="LB_2019"/> The format may support segregating code into sections such as [[.text]] (executable code), [[.data]] (initialized global and static variables), and [[.rodata]] (read-only data, such as constants and strings). | |||
{{ | |||
Executable files | Executable files typically include a [[runtime system]], which implements runtime language features (such as [[task scheduling]], [[exception handling]], calling static constructors and destructors, etc.) and interactions with the operating system, notably passing arguments, environment, and returning an [[exit status]], together with other startup and shutdown features such as releasing resources like [[file handle]]s. For C, this is done by linking in the [[crt0]] object, which contains the actual entry point and does setup and shutdown by calling the [[runtime library]].<ref name="Fisher_2019"/> Executable files thus may contain significant code beyond that directly generated from the source code. In some cases, it is desirable to omit this, for example for embedded systems. In C, this can be done by omitting the usual runtime, and instead explicitly specifying a linker script, which generates the entry point and handles startup and shutdown, such as calling <code>main</code> to start and returning exit status to the kernel at the end.<ref name="McKellar_2010"/> | ||
To be executable, a file must conform to the system's [[application binary interface]] (ABI). In simple interfaces, a file is executed by loading it into memory and jumping to the start of the address space and executing from there.<ref name="Computer_2005"/> In more complicated interfaces, executable files have additional [[metadata]], which may specify [[Relocation (computing)|relocations]] to be performed when the program is loaded, or the [[entry point]] address at which to start execution.<ref name="Rusling_1999"/> | |||
==See also== | ==See also== | ||
* | * {{Annotated link|Comparison of executable file formats}} | ||
* | * {{Annotated link|Executable compression}} | ||
* | * {{Annotated link|Executable text}} | ||
* {{Annotated link|Object file}} | |||
==References== | ==References== | ||
<references> | |||
<ref name="Celovi_2022">{{cite book|url=https://books.google.com/books?id=E4SFkfsOVaoC&pg=PA188|title=Embedded FreeBSD Cookbook|last=Celovi|first=Paul|publisher=[[Elsevier]]|date=2002|access-date=2022-03-06|pages=108, 187–188|isbn=1-5899-5004-6}}</ref> | <ref name="Celovi_2022">{{cite book|url=https://books.google.com/books?id=E4SFkfsOVaoC&pg=PA188|title=Embedded FreeBSD Cookbook|last=Celovi|first=Paul|publisher=[[Elsevier]]|date=2002|access-date=2022-03-06|pages=108, 187–188|isbn=1-5899-5004-6}}</ref> | ||
<ref name="Computer_2005">{{cite journal|title=The Architecture of Virtual Machines|last1=Smith|first1=James E.|author1-link=James E. Smith (engineer)|last2=Nair|first2=Ravi|journal=[[Computer (magazine)|Computer]]|date=2005-05-16|volume=38|issue=5|pages=33–34|doi=10.1109/MC.2005.173|url=http://digital.library.wisc.edu/1793/11154 }}</ref> | <ref name="Computer_2005">{{cite journal|title=The Architecture of Virtual Machines|last1=Smith|first1=James E.|author1-link=James E. Smith (engineer)|last2=Nair|first2=Ravi|journal=[[Computer (magazine)|Computer]]|date=2005-05-16|volume=38|issue=5|pages=33–34|doi=10.1109/MC.2005.173|url=http://digital.library.wisc.edu/1793/11154 }}</ref> | ||
| Line 39: | Line 33: | ||
<ref name="Mueller_2007">{{cite book|url=https://books.google.com/books?id=Ua819DVKQPwC&pg=PA24|title=Windows Administration at the Command Line for Windows Vista, Windows 2003, Windows XP, and Windows 2000|last=Mueller|first=John Paul|publisher=[[John Wiley & Sons]]|date=2007|access-date=2023-03-06|page=24|isbn=978-0-470-04616-6}}</ref> | <ref name="Mueller_2007">{{cite book|url=https://books.google.com/books?id=Ua819DVKQPwC&pg=PA24|title=Windows Administration at the Command Line for Windows Vista, Windows 2003, Windows XP, and Windows 2000|last=Mueller|first=John Paul|publisher=[[John Wiley & Sons]]|date=2007|access-date=2023-03-06|page=24|isbn=978-0-470-04616-6}}</ref> | ||
<ref name="MW_2008">{{cite web |url=http://www.merriam-webster.com/dictionary/executable |title=executable |access-date=2008-07-19 |work=Merriam-Webster's Online Dictionary |publisher=[[Merriam-Webster]]}}</ref> | <ref name="MW_2008">{{cite web |url=http://www.merriam-webster.com/dictionary/executable |title=executable |access-date=2008-07-19 |work=Merriam-Webster's Online Dictionary |publisher=[[Merriam-Webster]]}}</ref> | ||
<ref name="Rusling_1999">{{cite book|chapter-url=https://tldp.org/LDP/tlk/kernel/processes.html|chapter=Chapter 4 – Processes|title=The Linux Kernel|last=Rusling|first=David A.|date=1999|access-date=2023-03-06|at=sec. 4.8.1 – ELF}}</ref> | <ref name="Rusling_1999">{{cite book|chapter-url=https://tldp.org/LDP/tlk/kernel/processes.html|chapter=Chapter 4 – Processes|title=The Linux Kernel|last=Rusling|first=David A.|date=1999|access-date=2023-03-06|at=sec. 4.8.1 – ELF}}</ref> | ||
</references> | |||
==External links== | ==External links== | ||
Latest revision as of 14:34, 18 November 2025
Template:Short description Script error: No such module "about". Template:Use dmy dates Template:Use list-defined references Template:Program execution
In computing, an executable is a resource that a computer can use to control its behavior. As with all information in computing, it is data, but distinct from data that does not imply a flow of control.[2] Terms such as executable code, executable file, executable program, and executable image describe forms in which the information is represented and stored. A native executable is machine code and is directly executable at the instruction level of a CPU.[3][4] A script is also executable although indirectly via an interpreter. Intermediate executable code (such as bytecode) may be interpreted or converted to native code at runtime via just-in-time compilation.
Native executable
Even though it is technically possible to write a native executable directly in machine language, it is generally not done. It is far more convenient to develop software as human readable source code and to automate the generation of machine code via a build toolchain. Today, most source code is a high-level language although it is still possible to use assembly language which is closely associated with machine code instructions. Many toolchains consist of a compiler that generates native code as a set of object files and a linker that generates a native executable from the object and other files. For assembly language, typically the translation tool is called an assembler instead of a compiler.
Object files are typically stored in a digital container format that supports structure in the machine code Template:Endash such as Executable and Linkable Format (ELF) or Portable Executable (PE), depending on the computing context.[5] The format may support segregating code into sections such as .text (executable code), .data (initialized global and static variables), and .rodata (read-only data, such as constants and strings).
Executable files typically include a runtime system, which implements runtime language features (such as task scheduling, exception handling, calling static constructors and destructors, etc.) and interactions with the operating system, notably passing arguments, environment, and returning an exit status, together with other startup and shutdown features such as releasing resources like file handles. For C, this is done by linking in the crt0 object, which contains the actual entry point and does setup and shutdown by calling the runtime library.[6] Executable files thus may contain significant code beyond that directly generated from the source code. In some cases, it is desirable to omit this, for example for embedded systems. In C, this can be done by omitting the usual runtime, and instead explicitly specifying a linker script, which generates the entry point and handles startup and shutdown, such as calling main to start and returning exit status to the kernel at the end.[7]
To be executable, a file must conform to the system's application binary interface (ABI). In simple interfaces, a file is executed by loading it into memory and jumping to the start of the address space and executing from there.[8] In more complicated interfaces, executable files have additional metadata, which may specify relocations to be performed when the program is loaded, or the entry point address at which to start execution.[9]
See also
References
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "Citation/CS1".
- ↑ Script error: No such module "citation/CS1".
External links
- EXE File Format at What Is