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
Object file
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|File containing relocatable format machine code}} {{use dmy dates|date=November 2023|cs1-dates=y}} {{use list-defined references|date=November 2023}} An '''object file''' is a [[Computer file|file]] that contains [[machine code]] or [[bytecode]], as well as other data and [[metadata]], generated by a [[compiler]] or [[Assembler (computing)|assembler]] from [[source code]] during the compilation or assembly process. The machine code that is generated is known as [[object code]]. The object code is usually [[Relocation (computing)|relocatable]], and not usually directly [[executable]]. There are various formats for object files, and the same machine code can be packaged in different object file formats. An object file may also work like a [[shared library]]. The metadata that object files may include can be used for linking or debugging; it includes information to resolve symbolic cross-references between different modules, [[relocation (computing)|relocation]] information, [[stack unwinding]] information, [[Comment (computer programming)|comments]], program [[symbol (computing)|symbols]], and debugging or [[profiling (computer programming)|profiling]] information. Other metadata may include the date and time of compilation, the compiler name and version, and other identifying information. The term "object program" dates from at least the 1950s: {{quote|A term in automatic programming for the machine language program produced by the machine by translating a source program written by the programmer in a language similar to algebraic notation.<ref name="Wrubel_1959"/>}} A [[linker (computing)|linker]] is used to combine the object code into one executable program or library pulling in precompiled system libraries as needed. == Object file formats == There are many different object file formats; originally each type of computer had its own unique format, but with the advent of [[Unix]] and other [[porting|portable]] [[operating system]]s, some formats, such as [[Executable and Linkable Format|ELF]] and [[COFF]], have been defined and used on different kinds of systems. Some systems make a distinction between formats which are directly executable and formats which require processing by the [[linker (computing)|linker]]. For example, [[OS/360 and successors]] call the first format a ''load module'' and the second an ''object module''. In this case the files have entirely different formats.<ref name="IBM_1973"/> [[DOS]] and [[Windows]] also have different file formats for executable files and object files, such as [[Portable Executable]] for executables and COFF for object files in 32-bit and 64-bit Windows. Unix and [[Unix-like]] systems have used the same format for [[executable]] and object files, starting with the original [[a.out]] format. Some formats can contain machine code for different processors, with the correct one chosen by the operating system when the program is loaded.<ref name="mach-o-fat-binaries" /><ref name="FatELF"/> The design and/or choice of an object file format is a key part of overall system design. It affects the performance of the linker and thus [[programmer]] turnaround while a program is being developed. If the format is used for executables, the design also affects the time programs take to [[Bootstrapping#Software loading and execution|begin running]], and thus the [[responsiveness]] for users. The [[GNU Project]]'s [[Binary File Descriptor library]] (BFD library) provides a common [[API]] for the manipulation of object files in a variety of formats. ===Absolute files=== Many early computers, or small [[Microcomputer|microcomputers]], support only an absolute object format. Programs are not relocatable; they need to be assembled or compiled to execute at specific, predefined addresses. The file contains no relocation or linkage information. These files can be loaded into read/write memory, or stored in [[read-only memory]]. For example, the [[Motorola 6800]] [[MIKBUG]] monitor contains a routine to read an absolute object file ([[SREC (file format)|SREC Format]]) from [[paper tape]].<ref name="Wiles-Felix"/> [[DOS]] [[COM file#DOS binary format|COM files]] are a more recent example of absolute object files.<ref name="Godse-Godse_2008"/> === Segmentation === Most object file formats are structured as separate sections of data, each section containing a certain type of data. These sections are known as "segments" due to the term "[[memory segment]]", which was previously a common form of [[memory management]]. When a program is loaded into memory by a [[loader (computing)|loader]], the loader allocates various regions of memory to the program. Some of these regions correspond to sections of the object file, and thus are usually known by the same names. Others, such as the stack, only exist at run time. In some cases, [[relocation (computing)|relocation]] is done by the loader (or linker) to specify the actual memory addresses. However, for many programs or architectures, relocation is not necessary, due to being handled by the [[memory management unit]] or by [[position-independent code]]. On some systems the segments of the object file can then be copied (paged) into memory and executed, without needing further processing. On these systems, this may be done ''lazily'', that is, only when the segments are referenced during execution, for example via a [[memory-mapped file]] backed by the object file. Types of data supported by typical object file formats:<ref name="Mauerer_2010"/> * Header (descriptive and control information) * [[Code segment]] ("text segment", executable code) * [[Data segment]] (initialized [[static variable]]s) * Read-only data segment (''[[rodata]],'' initialized static [[constant (computer programming)|constants]]) * [[BSS segment]] (uninitialized static data, both variables and constants) * External definitions and references for linking * [[Relocation (computer science)|Relocation]] information * [[Dynamic linking]] information * [[Debugging]] information Segments in different object files may be combined by the linker according to rules specified when the segments are defined. Conventions exist for segments shared between object files; for instance, in [[DOS]] there are [[x86 memory models|different memory models]] that specify the names of special segments and whether or not they may be combined.<ref name="Irvine_1993"/> The [[debugging data format]] of debugging information may either be an integral part of the object file format, as in [[COFF]], or a semi-independent format which may be used with several object formats, such as [[stabs]] or [[DWARF]]. == See also == * [[OS/360 Object File Format]] * [[Intel hexadecimal object file format]] (typically with file extension .HEX, but sometimes also with .OBJ) * [[Object Module Format (ICL)]] (OMF for ICL VME) * [[Object Module Format (Intel)]] (OMF for Intel 8080/8085, OBJ for Intel 8086) <!-- Left here as a reminder that we still need an article about this format - to be sorted out in better details: * [[Object Module Format (Apple)]] (OMF as used by ORCA / [[Apple IIGS]]) --><!-- https://web.archive.org/web/20230531015216/https://groups.google.com/g/comp.sys.apple2.programmer/c/_wUSsAQ_N1E https://web.archive.org/web/20220929213143/http://www.1000bit.it/support/manuali/apple/technotes/iigs/tn.iigs.066.html --> * [[Mach-O]] ==References== {{Reflist|refs= <ref name="Wrubel_1959">{{cite book |author-last=Wrubel |author-first=Marshal H. |title=A primer of programming for digital computers |date=1959 |publisher=[[McGraw-Hill]] |location=New York, USA |page=222 |url=https://catalog.hathitrust.org/Record/000429866 |access-date=2020-07-31}}</ref> <ref name="IBM_1973">{{cite book |publisher=[[IBM Corporation]] |title=IBM OS Linkage Editor and Loader |date=1973 |url=http://www.bitsavers.org/pdf/ibm/360/os/R21.7_Apr73/GC28-6538-10_Linkage_Editor_Rel_21_Apr73.pdf |access-date=2012-08-06 |page=16}}</ref> <ref name="FatELF">{{cite web |title=FatELF: Universal Binaries for Linux |url=http://icculus.org/fatelf/ |access-date=2020-08-02}}</ref> <ref name="Wiles-Felix">{{cite book |author-last1=Wiles |author-first1=Mike |author-last2=Felix |author-first2=Andre |title=MCM6830L7 MIKBUG/MINIBUG ROM |publisher=Motorola Semiconductor Products, Inc. |url=http://bitsavers.org/components/motorola/6800/Engineering_Note_100_MCM6830L7_MIKBUG_MINBUG_ROM_Jul77.pdf |access-date=2020-07-31}}</ref> <ref name="Godse-Godse_2008">{{cite book |title=Microprocessor |author-last1=Godse |author-first1=Deepali A. |author-last2=Godse |author-first2=Atul P. |date=2008 |publisher=Technical Publications |location=Pune, India |isbn=978-81-8431-355-0 |pages=3β15 |edition=1}}</ref> <ref name="Mauerer_2010">{{cite book |author-last=Mauerer |author-first=Wolfgang |title=Professional Linux Kernel Architecture |date=2010 |publisher=[[John Wiley & Sons]] |isbn=978-0-470-34343-2 |page=Appendix E |chapter=Appendix E. The ELF Binary Format |chapter-url=https://books.google.com/books?id=-6zvRFEfQ24C&pg=PT1137 |access-date=2020-08-01}}</ref> <ref name="Irvine_1993">{{cite book |author-last=Irvine |author-first=Kip R. |date=1993 |title=Assembly language for the IBM-PC |edition=2 |publisher=Macmillan |place=New York, USA |isbn=0-02-359651-1 |url-access=registration |url=https://archive.org/details/assemblylanguage0000irvi}}</ref> <ref name="mach-o-fat-binaries">{{cite web |work=OS X ABI Mach-O File Format Reference |title=Universal Binaries and 32-bit/64-bit PowerPC Binaries |date=2009-02-04 |orig-date=2003 |publisher=[[Apple Inc.]] |url=https://developer.apple.com/library/mac/documentation/developertools/conceptual/MachORuntime/Reference/reference.html#//apple_ref/doc/uid/20001298-154889 |url-status=dead |archive-url=https://web.archive.org/web/20140904004108/https://developer.apple.com/library/mac/documentation/developertools/conceptual/MachORuntime/Reference/reference.html#//apple_ref/doc/uid/20001298-154889 |archive-date=2014-09-04}}</ref> }} ==Further reading== * {{cite book |author-last=Levine |author-first=John R. |author-link=John R. Levine |title=Linkers and Loaders |date=2000 |orig-date=October 1999 |edition=1 |publisher=[[Morgan Kaufmann]] |series=The Morgan Kaufmann Series in Software Engineering and Programming |location=San Francisco, California, USA |isbn=1-55860-496-0 |oclc=42413382 |pages=256 |chapter=Chapter 3: Object files |chapter-url=http://www.iecc.com/linker/linker03.html |access-date=2020-01-12 |url-status=dead |archive-url=https://archive.today/20130125220014/http://www.iecc.com/linker/linker03.html |archive-date=2013-01-25}} Code: [https://archive.today/20200114225034/https://linker.iecc.com/code.html][ftp://ftp.iecc.com/pub/linker/]{{dead link|date=May 2025|bot=medic}}{{cbignore|bot=medic}} Errata: [https://linker.iecc.com/] * {{cite book |title=The Microsoft OBJ File Format |publisher=[[Microsoft]], Product Support Services |id=Application Note SS0288 |url=https://www.fileformat.info/format/ms-obj/corion.htm |access-date=2017-08-21 |url-status=live |archive-url=https://archive.today/20170909092856/http://www.fileformat.info/format/ms-obj/corion.htm |archive-date=2017-09-09}} * {{cite web |title=Microsoft REL file format |author-first=John C. |author-last=Elliott |date=2002 |website=seasip.info |url=https://www.seasip.info/Cpm/rel.html |access-date=2023-11-25 |url-status=live |archive-url=https://web.archive.org/web/20231125154818/https://www.seasip.info/Cpm/rel.html |archive-date=2023-11-25}} (NB. Description of the Microsoft REL file format for relocatable objects, also used by Digital Research.) * {{cite web |author-first=John C. |author-last=Elliott |title=PRL file format |date=2012-06-05 |orig-date=2000-01-02 |website=seasip.info |url=https://www.seasip.info/Cpm/prl.html |access-date=2020-01-26 |url-status=live |archive-url=https://web.archive.org/web/20200126182027/https://www.seasip.info/Cpm/prl.html |archive-date=2020-01-26}} [https://www.seasip.info/Cpm/amsfid.html#PRL%20file%20format] * {{cite journal |title=A Machine-Independent Linker |author-first1=Christopher "Chris" W. |author-last1=Fraser |author-link1=Christopher W. Fraser |author-first2=David R. |author-last2=Hanson |author-link2=David Hanson (computer scientist) |location=University of Arizona, Tucson, Arizona, USA |journal={{ill|Software: Practice and Experience|d|Q15758146}} |issn=0038-0644 |volume=12 |issue=4 |pages=351β366 |date=AprilβMay 1982 |orig-date=1981-09-09, 1981-11-02 |doi=10.1002/spe.4380120407 |publisher=[[John Wiley & Sons, Ltd.]] |url=https://www.cs.tufts.edu/~nr/cs257/archive/david-hanson/linker-scan.pdf |access-date=2023-11-28 |url-status=live |archive-url=https://web.archive.org/web/20231128190559/https://www.cs.tufts.edu/~nr/cs257/archive/david-hanson/linker-scan.pdf |archive-date=2023-11-28}} (16 pages) * {{anchor|CUFOM}}{{cite conference |title=Cross Software Using a Universal Object Module Format, CUFOM |author-first1=Jean |author-last1=Montuelle |author-first2=Ian |author-last2=Willers |location=CERN, Geneve, Switzerland |date=25β28 September 1979 |orig-date=October 1978 |publisher= |publication-place=Euro IFIP, London, UK |id=CERN-DD/78/20 |url=https://www.researchgate.net/publication/29512298 |access-date=2023-11-28}} (1+23 pages) * {{anchor|MUFOM}}{{citation |title=Microprocessor Universal Format for Object Modules, MUFOM |publisher=[[IEEE]] Working Group |type=draft document |id=P695lD2 |url=}} * {{cite journal |title=Letter to the Editor |author-first1=Jean |author-last1=Montuelle |author-first2=Ian |author-last2=Willers |location=CERN, Geneve, Switzerland |journal={{ill|Software: Practice and Experience|d|Q15758146}} |issn=0038-0644 |volume=12 |issue=9 |pages=883β884 [884] |date=September 1982 |publisher=[[John Wiley & Sons, Ltd.]] |doi=10.1002/spe.4380120909 |doi-access=free }} (1 page) (NB. Describes the history and relationship of IEEE 695 with CUFOM and MUFOM.) * {{anchor|IEEE695}}{{cite book |title=IEEE 695-1990: IEEE Standard for Microprocessor Universal Format for Object Modules |date=1990-02-05 |isbn=978-0-7381-3028-6 |publisher=[[IEEE]] |doi=10.1109/IEEESTD.1990.101062 |url=https://ieeexplore.ieee.org/document/159333}} (NB. Superseeds IEEE 695-1985 (1985-09-09)). {{executables}} [[Category:Executable file formats]] [[Category:Compiler construction]] [[Category:Computer libraries]] [[Category:Programming language implementation]]
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:Anchor
(
edit
)
Template:Cbignore
(
edit
)
Template:Citation
(
edit
)
Template:Cite book
(
edit
)
Template:Cite conference
(
edit
)
Template:Cite journal
(
edit
)
Template:Cite web
(
edit
)
Template:Dead link
(
edit
)
Template:Executables
(
edit
)
Template:Quote
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)
Template:Use dmy dates
(
edit
)
Template:Use list-defined references
(
edit
)