VirtualBox

source: vbox/trunk/include/iprt/formats/omf.h@ 104212

Last change on this file since 104212 was 98103, checked in by vboxsync, 23 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 12.6 KB
Line 
1/* $Id: omf.h 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * IPRT - Relocatable Object Module Format (OMF).
4 *
5 * @remarks For a more details description, see specification from Tools
6 * Interface Standards (TIS), version 1.1 dated May 2015.
7 * Typically named found as OMF_v1.1.pdf.
8 */
9
10/*
11 * Copyright (C) 2006-2023 Oracle and/or its affiliates.
12 *
13 * This file is part of VirtualBox base platform packages, as
14 * available from https://www.virtualbox.org.
15 *
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License
18 * as published by the Free Software Foundation, in version 3 of the
19 * License.
20 *
21 * This program is distributed in the hope that it will be useful, but
22 * WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 * General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, see <https://www.gnu.org/licenses>.
28 *
29 * The contents of this file may alternatively be used under the terms
30 * of the Common Development and Distribution License Version 1.0
31 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
32 * in the VirtualBox distribution, in which case the provisions of the
33 * CDDL are applicable instead of those of the GPL.
34 *
35 * You may elect to license modified versions of this file under the
36 * terms and conditions of either the GPL or the CDDL or both.
37 *
38 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
39 */
40
41#ifndef IPRT_INCLUDED_formats_omf_h
42#define IPRT_INCLUDED_formats_omf_h
43#ifndef RT_WITHOUT_PRAGMA_ONCE
44# pragma once
45#endif
46
47#include <iprt/stdint.h>
48#include <iprt/assertcompile.h>
49
50
51/** @defgroup grp_rt_formats_omf Relocatable Object Module Format (OMF) structures and definitions
52 * @ingroup grp_rt_formats
53 * @{
54 */
55
56/**
57 * OMF record header.
58 */
59#pragma pack(1)
60typedef struct OMFRECHDR
61{
62 /** The record type. */
63 uint8_t bType;
64 /** The record length, excluding the this header. */
65 uint16_t cbLen;
66} OMFRECHDR;
67#pragma pack()
68AssertCompileSize(OMFRECHDR, 3);
69/** Pointer to an OMF header. */
70typedef OMFRECHDR *POMFRECHDR;
71/** Pointer to a const OMF header. */
72typedef OMFRECHDR *PCOMFRECHDR;
73
74/** The max OMF record length, including the header. */
75#define OMF_MAX_RECORD_LENGTH UINT16_C(1024)
76
77/** The max OMF record payload, including CRC byte. */
78#define OMF_MAX_RECORD_PAYLOAD UINT16_C(1021)
79
80
81/** @name OMF Record Types (OMFRECHDR::bType).
82 * @{ */
83/** Record type flag indicating 32-bit record. */
84#define OMF_REC32 UINT8_C(0x01)
85/** Object file header record.
86 * Is followed by a length prefixed string */
87#define OMF_THEADR UINT8_C(0x80)
88/** Comment record.
89 * Is followed by a comment type byte and a commen class byte, thereafter comes
90 * type specific byte sequence. */
91#define OMF_COMENT UINT8_C(0x88)
92/** Local name table referenced by segment and group defintions.
93 * Array of length prefixed strings. Multi record. */
94#define OMF_LNAMES UINT8_C(0x96)
95/** 16-bit segment definition.
96 * Complicated, see TIS docs. */
97#define OMF_SEGDEF16 UINT8_C(0x98)
98/** 32-bit segment definition.
99 * Complicated, see TIS docs. */
100#define OMF_SEGDEF32 UINT8_C(0x99)
101/** Segment group definition.
102 * Starts with an LNAMES index (one or two bytes) of the group name. Followed
103 * by an array which entries consists of a 0xff byte and a segment
104 * defintion index (one or two bytes). */
105#define OMF_GRPDEF UINT8_C(0x9a)
106/** External symbol defintions.
107 * Array where each entry is a length prefixed symbol name string followed by a
108 * one or two byte type number. */
109#define OMF_EXTDEF UINT8_C(0x8c)
110/** 16-but public symbol definitions.
111 * Starts with a group index (one or two bytes) and a segment index (ditto)
112 * which indicates which group/segment the symbols belong to.
113 * Is followed by an array with entries consiting of a length prefixed symbol
114 * name string, a two byte segment offset, and a one or two byte type index. */
115#define OMF_PUBDEF16 UINT8_C(0x90)
116/** 32-but public symbol definitions.
117 * Identical to #OMF_PUBDEF16 except that the symbol offset field is four
118 * byte. */
119#define OMF_PUBDEF32 UINT8_C(0x91)
120/** 16-bit local symbol definitions.
121 * Same format as #OMF_PUBDEF16. */
122#define OMF_LPUBDEF16 UINT8_C(0xb6)
123/** 16-bit local symbol definitions.
124 * Same format as #OMF_PUBDEF32. */
125#define OMF_LPUBDEF32 UINT8_C(0xb7)
126/** Logical enumerated data record (a chunk of raw segment bits).
127 * Starts with the index of the segment it contributes to (one or two bytes) and
128 * is followed by the offset into the segment of the bytes (two bytes).
129 * After that comes the raw data bytes. */
130#define OMF_LEDATA16 UINT8_C(0xa0)
131/** Logical enumerated data record (a chunk of raw segment bits).
132 * Identical to #OMF_LEDATA16 except that is has a the segment offset field is
133 * four bytes. */
134#define OMF_LEDATA32 UINT8_C(0xa1)
135/** 16-bit fixup record.
136 * Complicated, see TIS docs. */
137#define OMF_FIXUPP16 UINT8_C(0x9c)
138/** 32-bit fixup record.
139 * Complicated, see TIS docs. */
140#define OMF_FIXUPP32 UINT8_C(0x9d)
141/** 16-bit line numbers record. */
142#define OMF_LINNUM16 UINT8_C(0x94)
143/** 32-bit line numbers record. */
144#define OMF_LINNUM32 UINT8_C(0x95)
145/** 16-bit object file end record.
146 * Duh! wrong bitfield order.
147 *
148 * Starts with a byte bitfield indicating module type: bit 0 is set if this is a
149 * main program module; bit 1 is set if this is a start address is available;
150 * bits 2 thru 6 are reserved and must be zero; bit 7 is set to indicate
151 * a non-absolute start address.
152 *
153 * When bit 1 is set what follow is: A FIXUPP byte, one or two byte frame datum,
154 * one or two byte target datum, and a 2 byte target displacement. */
155#define OMF_MODEND16 UINT8_C(0x8a)
156/** 32-bit object file end record.
157 * Identical to #OMF_MODEND16 except that is has a 4 byte target
158 * displacement field. */
159#define OMF_MODEND32 UINT8_C(0x8b)
160/** @} */
161
162/** @name OMF COMENT Type Flags
163 * @{ */
164/** Comment type: Don't remove comment when object is manipulated. */
165#define OMF_CTYP_NO_PURGE UINT8_C(0x80)
166/** Comment type: Don't include in object listing. */
167#define OMF_CTYP_NO_LIST UINT8_C(0x40)
168/** @} */
169
170/** @name OMF COMENT Classes
171 * @{ */
172/** Comment class: Dependency file.
173 * Is followed by a dword timestamp (1980 based?) and a length prefix
174 * filename string. */
175#define OMF_CCLS_DEP_FILE UINT8_C(0x88)
176/** Comment class: Link pass separator.
177 * Contains a byte with the value 01 to indicate the linker can stop pass 1
178 * processing now. */
179#define OMF_CCLS_LINK_PASS_SEP UINT8_C(0xa2)
180/** Comment class: Borland type information. */
181#define OMF_CCLS_BORLAND_TYPES UINT8_C(0xe3)
182/** Comment class: Borland symbol information. */
183#define OMF_CCLS_BORLAND_SYMBOLS UINT8_C(0xe6)
184/** Comment class: Borland source file (applies to subsequent LINNUMs). */
185#define OMF_CCLS_BORLAND_SRC_FILE UINT8_C(0xe8)
186/** Comment class: Borland dependency files. */
187#define OMF_CCLS_BORLAND_DEP_FILES UINT8_C(0xe9)
188/** @} */
189
190/** @name OMF SEGDEF Attrib.
191 * @{ */
192#define OMF_SEG_ATTR_ALIGN_ABS (UINT8_C(0) << 5) /**< SEGDEF attrib A: absolute - frame and offset fields present. */
193#define OMF_SEG_ATTR_ALIGN_BYTE (UINT8_C(1) << 5) /**< SEGDEF attrib A: 1-byte alignment. */
194#define OMF_SEG_ATTR_ALIGN_WORD (UINT8_C(2) << 5) /**< SEGDEF attrib A: 2-byte alignment. */
195#define OMF_SEG_ATTR_ALIGN_PARA (UINT8_C(3) << 5) /**< SEGDEF attrib A: 16-byte alignment. */
196#define OMF_SEG_ATTR_ALIGN_PAGE (UINT8_C(4) << 5) /**< SEGDEF attrib A: 4096-byte alignment (or 256-byte). */
197#define OMF_SEG_ATTR_ALIGN_DWORD (UINT8_C(5) << 5) /**< SEGDEF attrib A: 4-byte alignment. */
198#define OMF_SEG_ATTR_ALIGN_6 (UINT8_C(6) << 5) /**< SEGDEF attrib A: not supported (load-time locatable, paragraph aligned). */
199#define OMF_SEG_ATTR_ALIGN_7 (UINT8_C(7) << 5) /**< SEGDEF attrib A: undefined. */
200#define OMF_SEG_ATTR_ALIGN_MASK (UINT8_C(7) << 5) /**< SEGDEF attrib A: Mask for the alignment field. */
201#define OMF_SEG_ATTR_ALIGN_SHIFT 5 /**< SEGDEF attrib A: Shift count for the alignment field. */
202
203#define OMF_SEG_ATTR_COMB_PRIVATE (UINT8_C(0) << 2) /**< SEGDEF attrib C: Private - do not combine with anyone. */
204#define OMF_SEG_ATTR_COMB_1 (UINT8_C(1) << 2) /**< SEGDEF attrib C: Reserved */
205#define OMF_SEG_ATTR_COMB_PUBLIC (UINT8_C(2) << 2) /**< SEGDEF attrib C: Public - append at offset meeting alignment. */
206#define OMF_SEG_ATTR_COMB_3 (UINT8_C(3) << 2) /**< SEGDEF attrib C: Reserved */
207#define OMF_SEG_ATTR_COMB_PUBLIC_4 (UINT8_C(4) << 2) /**< SEGDEF attrib C: Public - append at offset meeting alignment. */
208#define OMF_SEG_ATTR_COMB_STACK (UINT8_C(5) << 2) /**< SEGDEF attrib C: Stack - same as public, but forced byte alignment. */
209#define OMF_SEG_ATTR_COMB_COMMON (UINT8_C(6) << 2) /**< SEGDEF attrib C: Common - overlay using maximum size. */
210#define OMF_SEG_ATTR_COMB_PUBLIC_7 (UINT8_C(5) << 2) /**< SEGDEF attrib C: Public - append at offset meeting alignment. */
211#define OMF_SEG_ATTR_COMB_MASK (UINT8_C(7) << 2) /**< SEGDEF attrib C: Mask for the combination field. */
212#define OMF_SEG_ATTR_COMB_SHIFT 2 /**< SEGDEF attrib C: Shift count for the combination field. */
213#define OMF_SEG_ATTR_BIG UINT8_C(2) /**< SEGDEF attrib B: Big segment 64K / 4GB. */
214#define OMF_SEG_ATTR_USE32 UINT8_C(1) /**< SEGDEF attrib P: Indicates 32-bit data or code. */
215#define OMF_SEG_ATTR_USE16 UINT8_C(0) /**< SEGDEF attrib ~P: Just for spelling out !USE32. */
216/** @} */
217
218
219/** @name OMF FIXUPP Locations.
220 * @{ */
221#define OMF_FIX_LOC_8BIT_LOW_BYTE UINT8_C(0) /**< FIXUP location: low byte (offset or displacement). */
222#define OMF_FIX_LOC_16BIT_OFFSET UINT8_C(1) /**< FIXUP location: 16-bit offset. */
223#define OMF_FIX_LOC_16BIT_SEGMENT UINT8_C(2) /**< FIXUP location: 16-bit segment. */
224#define OMF_FIX_LOC_1616FAR UINT8_C(3) /**< FIXUP location: 16:16 far pointer. */
225#define OMF_FIX_LOC_8BIT_HIGH_BYTE UINT8_C(4) /**< FIXUP location: high byte (offset). Not supported by MS/IBM. */
226#define OMF_FIX_LOC_16BIT_OFFSET_LDR UINT8_C(5) /**< FIXUP location: 16-bit loader resolved offset, same a 1 for linker. PharLab conflict. */
227#define OMF_FIX_LOC_RESERVED_FAR1632 UINT8_C(6) /**< FIXUP location: PharLab 16:32 far pointers, not defined by MS/IBM. */
228#define OMF_FIX_LOC_RESERVED_7 UINT8_C(7) /**< FIXUP location: Not defined. */
229#define OMF_FIX_LOC_RESERVED_8 UINT8_C(8) /**< FIXUP location: Not defined. */
230#define OMF_FIX_LOC_32BIT_OFFSET UINT8_C(9) /**< FIXUP location: 32-bit offset. */
231#define OMF_FIX_LOC_RESERVED_10 UINT8_C(10) /**< FIXUP location: Not defined. */
232#define OMF_FIX_LOC_1632FAR UINT8_C(11) /**< FIXUP location: 16:32 far pointer. */
233#define OMF_FIX_LOC_RESERVED_12 UINT8_C(12) /**< FIXUP location: Not defined. */
234#define OMF_FIX_LOC_32BIT_OFFSET_LDR UINT8_C(13) /**< FIXUP location: 32-bit loader resolved offset, same as 9 for linker. */
235/** @} */
236/** @name OMF FIXUPP Targets
237 * @{ */
238#define OMF_FIX_T_SEGDEF UINT8_C(0) /**< FIXUP target: SEGDEF index. */
239#define OMF_FIX_T_GRPDEF UINT8_C(1) /**< FIXUP target: GRPDEF index. */
240#define OMF_FIX_T_EXTDEF UINT8_C(2) /**< FIXUP target: EXTDEF index. */
241#define OMF_FIX_T_FRAME_NO UINT8_C(3) /**< FIXUP target: Explicit frame number, not supported by MS/IBM. */
242#define OMF_FIX_T_SEGDEF_NO_DISP UINT8_C(4) /**< FIXUP target: SEGDEF index only, displacement take as 0. */
243#define OMF_FIX_T_GRPDEF_NO_DISP UINT8_C(5) /**< FIXUP target: GRPDEF index only, displacement take as 0. */
244#define OMF_FIX_T_EXTDEF_NO_DISP UINT8_C(6) /**< FIXUP target: EXTDEF index only, displacement take as 0. */
245/** @} */
246/** @name OMF FIXUPP Frames
247 * @{ */
248#define OMF_FIX_F_SEGDEF UINT8_C(0) /**< FIXUP frame: SEGDEF index. */
249#define OMF_FIX_F_GRPDEF UINT8_C(1) /**< FIXUP frame: GRPDEF index. */
250#define OMF_FIX_F_EXTDEF UINT8_C(2) /**< FIXUP frame: EXTDEF index. */
251#define OMF_FIX_F_FRAME_NO UINT8_C(3) /**< FIXUP frame: Explicit frame number, not supported by any linkers. */
252#define OMF_FIX_F_LXDATA_SEG UINT8_C(4) /**< FIXUP frame: Determined from the data being fixed up. (No index field.) */
253#define OMF_FIX_F_TARGET_SEG UINT8_C(5) /**< FIXUP frame: Determined from the target. (No index field.) */
254#define OMF_FIX_F_RESERVED_6 UINT8_C(6) /**< FIXUP frame: Reserved. */
255/** @} */
256
257
258/** @} */
259#endif /* !IPRT_INCLUDED_formats_omf_h */
260
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette