1 RDOFF: Relocatable Dynamically-linked Object File Format
2 ========================================================
4 RDOFF was designed initially to test the object-file production
5 interface to NASM. It soon became apparent that it could be enhanced
6 for use in serious applications due to its simplicity; code to load
7 and execute an RDOFF object module is very simple. It also contains
8 enhancements to allow it to be linked with a dynamic link library at
9 either run- or load- time, depending on how complex you wish to make
12 The RDOFF format (version 1.1, as produced by NASM v0.91) is defined
15 The first six bytes of the file contain the string 'RDOFF1'. Other
16 versions of the format may contain other last characters other than
17 '1' - all little endian versions of the file will always contain an
18 ASCII character with value greater than 32. If RDOFF is used on a
19 big-endian machine at some point in the future, the version will be
20 encoded in decimal rather than ASCII, so will be below 32.
22 All multi-byte fields follwing this are encoded in either little- or
23 big-endian format depending on the system described by this version
24 information. Object files should be encoded in the endianness of
25 their target machine; files of incorrect endianness will be rejected
26 by the loader - this means that loaders do not need to convert
27 endianness, as RDOFF has been designed with simplicity of loading at
28 the forefront of the design requirements.
30 The next 4 byte field is the length of the header in bytes. The
31 header consists of a sequence of variable length records. Each
32 record's type is identified by the first byte of the record. Record
33 types 1-4 are currently supported. Record type 5 will be added in
34 the near future, when I implement BSS segments. Record type 6 may be
35 to do with debugging, when I get debugging implemented.
40 Offset Length Description
42 1 1 Segment that contains reference (0 = text, 1 = data)
43 Add 64 to this number to indicate a relative linkage
44 to an external symbol (see notes)
45 2 4 Offset of reference
46 6 1 Length of reference (1,2 or 4 bytes)
47 7 2 Segment to which reference is made (0 = text, 1 =
48 data, 2 = BSS [when implemented]) others are external
51 Total length = 9 bytes
57 1 2 Segment number that will be used in references to this
59 3 ? Null terminated string containing label (up to 32
60 chars) to match against exports in linkage.
66 1 1 Segment containing object to be exported (0/1/2)
67 2 4 Offset within segment
68 6 ? Null terminate string containing label to export (32
71 Type 4: Dynamic Link Library
72 ============================
75 1 ? Library name (up to 128 chars)
81 1 4 Amount of BSS space to reserve in bytes
85 -----------------------------------------------------------------------------
87 Following the header is the text (code) segment. This is preceded by
88 a 4-byte integer, which is its length in bytes. This is followed by
89 the length of the data segment (also 4 bytes), and finally the data
95 Relative linking: The number stored at the address is offset
96 required from the imported symbol, with the address of the end of
97 the instruction subtracted from it. This means that the linker can
98 simply add the address of the label relative to the beginning of the
99 current segment to it.