1 /* ----------------------------------------------------------------------- *
3 * Copyright 1996-2017 The NASM Authors - All Rights Reserved
4 * See the file AUTHORS included with the NASM distribution for
5 * the specific copyright holders.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
19 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 * ----------------------------------------------------------------------- */
35 * rdoff.h RDOFF Object File manipulation routines header file
42 * RDOFF definitions. They are used by RDOFF utilities and by NASM's
43 * 'outrdf2.c' output module.
46 /* RDOFF format revision (currently used only when printing the version) */
47 #define RDOFF2_REVISION "0.6.1"
49 /* RDOFF2 file signature */
50 #define RDOFF2_SIGNATURE "RDOFF2"
52 /* Maximum size of an import/export label (including trailing zero) */
53 #define EXIM_LABEL_MAX 256
55 /* Maximum size of library or module name (including trailing zero) */
56 #define MODLIB_NAME_MAX 128
58 /* Maximum number of segments that we can handle in one file */
59 #define RDF_MAXSEGS 64
61 /* Record types that may present the RDOFF header */
62 #define RDFREC_GENERIC 0
63 #define RDFREC_RELOC 1
64 #define RDFREC_IMPORT 2
65 #define RDFREC_GLOBAL 3
68 #define RDFREC_SEGRELOC 6
69 #define RDFREC_FARIMPORT 7
70 #define RDFREC_MODNAME 8
71 #define RDFREC_COMMON 10
74 * Generic record - contains the type and length field, plus a 128 byte
87 uint8_t type
; /* must be 1 */
88 uint8_t reclen
; /* content length */
89 uint8_t segment
; /* only 0 for code, or 1 for data supported,
90 but add 64 for relative refs (ie do not require
91 reloc @ loadtime, only linkage) */
92 int32_t offset
; /* from start of segment in which reference is loc'd */
93 uint8_t length
; /* 1 2 or 4 bytes */
94 uint16_t refseg
; /* segment to which reference refers to */
98 * Extern/import record
101 uint8_t type
; /* must be 2 */
102 uint8_t reclen
; /* content length */
103 uint8_t flags
; /* SYM_* flags (see below) */
104 uint16_t segment
; /* segment number allocated to the label for reloc
105 records - label is assumed to be at offset zero
106 in this segment, so linker must fix up with offset
107 of segment and of offset within segment */
108 char label
[EXIM_LABEL_MAX
]; /* zero terminated, should be written to file
109 until the zero, but not after it */
113 * Public/export record
116 uint8_t type
; /* must be 3 */
117 uint8_t reclen
; /* content length */
118 uint8_t flags
; /* SYM_* flags (see below) */
119 uint8_t segment
; /* segment referred to (0/1/2) */
120 int32_t offset
; /* offset within segment */
121 char label
[EXIM_LABEL_MAX
]; /* zero terminated as in import */
128 uint8_t type
; /* must be 4 */
129 uint8_t reclen
; /* content length */
130 char libname
[MODLIB_NAME_MAX
]; /* name of library to link with at load time */
137 uint8_t type
; /* must be 5 */
138 uint8_t reclen
; /* content length */
139 int32_t amount
; /* number of bytes BSS to reserve */
146 uint8_t type
; /* must be 8 */
147 uint8_t reclen
; /* content length */
148 char modname
[MODLIB_NAME_MAX
]; /* module name */
152 * Common variable record
155 uint8_t type
; /* must be 10 */
156 uint8_t reclen
; /* equals 7+label length */
157 uint16_t segment
; /* segment number */
158 int32_t size
; /* size of common variable */
159 uint16_t align
; /* alignment (power of two) */
160 char label
[EXIM_LABEL_MAX
]; /* zero terminated as in import */
163 /* Flags for ExportRec */
165 #define SYM_FUNCTION 2