]> pd.if.org Git - mmurtl/blob - mscode16/readobj/readobj.doc
autocommit for file dated 1995-02-09 12:09:16
[mmurtl] / mscode16 / readobj / readobj.doc
1 Object Module Reader V1.0\r
2 (Q & A)\r
3 (c) 1992 R.A. Burgess\r
4 \r
5 ------------------------------------------------------------------\r
6 \r
7 Q.  What is the Object Module Reader??\r
8 \r
9 A.  The Object Module Reader breaks out all the records in an Intel\r
10 "object module" so they so they can be anaylzed.  It breaks them \r
11 out in "raw" form which is a hexidecimal dump format, or it expands \r
12 some of the records and fields for more information.\r
13 \r
14 Q.  What can you use if for?\r
15 \r
16 A.  People that are interested in the format or content of\r
17 object modules from Intel based assemblers and compilers can use this\r
18 to analyze each of the records.  It also provides insight into\r
19 tools such as linkers and object module librarians.\r
20 \r
21 Q.  OK, so what.  What are object modules anyway??\r
22 \r
23 A.  A programmer writes a program.  This program is in a "source"\r
24 language such as Assembler, C or Pascal.  Most assemblers and compilers\r
25 turn the source language into sections of machine code the processor\r
26 can execute or data the processor can manipulate called Object Records.\r
27 \r
28 The machine code and data are broken into these records that can be stored\r
29 in libraries or combined to make executable programs.\r
30 \r
31 A single group of these records is produced from each source file and\r
32 is called an Object Module.  Each record inside an object module is\r
33 further divided into fields that describe the code or data associated\r
34 with that particular record.\r
35 \r
36 Q.  Ok, this make sense so far. But what are these records and what do they\r
37 describe?\r
38 \r
39 A.  Some of the records contain machine code and data that will be\r
40 placed in the executable program file, while others contain information\r
41 to tell the linker where and how to combine the code and data records\r
42 with other object module records.\r
43 \r
44 Q.  So, do they just throw these records in the object module file any old\r
45 way, or is there a method to their madness???\r
46 \r
47 A.  There is definately a method to their madness...  Back in prehistoric\r
48 microcomputer times (1979), when Intel was building their now\r
49 famous 8086 processor, they designed the Object Module formats for the\r
50 80x86 series of processors and language tools.  All versions (that I\r
51 have run across) of the 80x86 object modules are based on this design\r
52 which was documented in a book called 8086 Relocatable Object Module Formats\r
53 (which, incidently, is still available from Intel in it's original 1981 form).\r
54 \r
55 Some additions beyond those documented in the Intel manual were required\r
56 when the 32 bit processors were introduced.  These additions can be found\r
57 in object modules that are generated from IBM's CSet/2 32 bit compiler\r
58 for OS/2 (v2.x) and also from other compilers and assemblers that produce 32\r
59 bit code. Borland's Turbo assembler with the /3 option and MASM generate\r
60 additional record types also).  See "Object Module Record Descriptions"\r
61 following the Q & A portion of this manual.  Most (if not all) of the earlier\r
62 language and programming tool vendors followed the format very closely. This\r
63 is NOT the case with some vendors later extensions (mostly 32 bit).\r
64 \r
65 Q.  Can this thing take apart object module "libraries?"\r
66 \r
67 A.  No, you should get a cross reference listing using your librarian\r
68 and extract the module you are interested in, then run ReadObj against\r
69 it.\r
70 \r
71 Q. OK, now that I know all this, how do I execute the Object Module Reader?\r
72 \r
73 A.  The Object Module Reader is a single executable file (DOS or OS/2)\r
74 and has two command line parameters and one switch.  The paramters are\r
75 INPUT FILE (your object module filename), and OUTPUT FILE (the text file\r
76 that the data is put into).  The single switch is /R for RAW data only.\r
77 Normally, the object module reader gives you as much data as possible\r
78 from the object module, which means it breaks out some of the more confusing\r
79 fields from the records.  The /R option forces it to present only the\r
80 record type, offset in the obj file, the size, and the records data (hex dump).\r
81 \r
82 Example of the command line:\r
83 \r
84 C:\> ReadObj MyBad.Obj MyBad.txt /R\r
85 \r
86 This would take an object file named MyBad.Obj and put the text\r
87 descriptions into a file called MyBad.txt in RAW form. If you leave\r
88 off the /R it will expand some of fields in the records.\r
89 If you do not specifiy an output file it will send the text data\r
90 to the screen.\r
91 \r
92 To test it, try this:\r
93 \r
94 C:\mscode16\readobj> ReadObj ReadObj. Obj  Obj.txt\r
95 \r
96 then edit Obj.TXT\r
97 \r
98 ----------------------------------------------------------------\r
99 Sample Object Module Record Descriptions\r
100 \r
101 The following section contains a description of a few of the most\r
102 commonly found Object Module Records. Some are all but obsolete.\r
103 The Intel publication should be purchased if you're really interested.\r
104 \r
105 Each of the record types found in an object module is described\r
106 as a record (pseudo language).  Several of the field types use\r
107 simple names to describe the types.  They are as follows:\r
108 \r
109 LString         A string of characters preceeded by a single byte which\r
110                         contains the length of characters in this string.\r
111 \r
112 Byte            An 8 bit unsigned value\r
113 \r
114 Word            A 16 bit unsigned value\r
115 \r
116 DWord           A 32 bit unsigned value\r
117 \r
118 BitField        One or more bits in a byte that have a special meaning\r
119 \r
120 RecID           A single byte which is the first byte in a record that\r
121                         identifies it's type.\r
122 \r
123 CheckSum        1 single byte containing all the bytes in the record\r
124                         added up modulo 128 (less the Record ID byte and Size Word)\r
125 \r
126 RecSize         A Word that has the size of the record minus the RecID,\r
127                         RecSize, and Checksum.\r
128 \r
129 --------------------------\r
130 Translator Header (THEADR)\r
131         This is the first record in an object module usually containing\r
132         the name of the source module that this object module was derived\r
133         from.\r
134 \r
135 Record\r
136         RecID                   : 80h\r
137         RecSize                 : Word\r
138         Name of Module  : LString\r
139         Checksum                : Byte\r
140 End\r
141         Raw Data Example:\r
142         07 43 4F 4D 33 32 2E 43                           .COM32.C\r\r
143 \r
144 --------------------------\r
145 Comment (COMENT)\r
146         The comment field contains comments and MORE.  It can be used\r
147         to list libraries that should be used, INLCUDE files used in\r
148         the source file and other non-comment\r
149         type things.  Different language vendors have added some\r
150         proprietary things that other language vendors don't use.\r
151         A REAL standard if ever I saw one...  BUT, as near as I can\r
152         tell it doesn't directly affect the actual code or data records \r
153         contained elsewhere in the module.\r
154 \r
155 Record\r
156         RecID                   : 88h\r
157         Size:                   : Word\r
158         Comment Data    : Data (up to maximum record length)\r
159         Checksum                : Byte\r
160 End\r
161         Raw Data Example:\r
162         40 9F 4F 53 32 33 38 36 2E 4C 49 42               @.OS2386.LIB\r\r
163 \r
164 --------------------------\r
165 List of Names (LNAMES)\r
166         This lists the segment name(s) defined by the translator (assembler\r
167         or compiler). They are in LString format.\r
168 \r
169 Record\r
170         RecID:                  : 96h\r
171         Size:                   : Word\r
172         List:                   : Zero or more LStrings\r
173         Checksum:               : Byte\r
174 End\r
175         Raw Data Example:\r
176         04 43 4F 44 45 04 44 41 54 41 05 43 4F 4E 53 54   .CODE.DATA.CONST\r\r
177         03 42 53 53 06 43 4F 44 45 33 32 06 44 41 54 41   .BSS.CODE32.DATA\r\r
178         33 32 07 43 4F 4E 53 54 33 32 05 42 53 53 33 32   32.CONST32.BSS32\r\r
179         06 44 47 52 4F 55 50 04 46 4C 41 54 06 44 45 42   .DGROUP.FLAT.DEB\r\r
180         53 59 4D 09 24 24 53 59 4D 42 4F 4C 53 06 44 45   SYM.$$SYMBOLS.DE\r\r
181         42 54 59 50 07 24 24 54 59 50 45 53               BTYP.$$TYPES\r\r
182 \r
183 --------------------------\r
184 Module End (MODEND)\r
185         This single byte signifies the end of the module.\r
186 \r
187 Record\r
188         RecID:                  : 96h\r
189 End\r