Changeset 293 for GPL/trunk/tools
- Timestamp:
- Feb 17, 2008, 8:39:48 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/trunk/tools/wat2map.cmd
r32 r293 1 /* $Id: wat2map.cmd,v 1.1.1.1 2003/07/02 13:57:04 eleph Exp $ */ 1 /* 2 * Includes fixes from Helper script MapSym.cmd by Knut (aka bird). 3 * 4 * Copyright (c) 2002 knut st. osmundsen (bird@anduin.net) 5 * 6 * Project Odin Software License can be found in LICENSE.TXT 7 * 8 */ 2 9 3 10 /* SCCSID = %W% %E% */ … … 47 54 /* <End of helpText> - don't modify this string - used to flag end of help. */ 48 55 /****************************************************************************/ 49 CALL RXFUNCADD 'sysloadfuncs','rexxutil','sysloadfuncs' 50 call sysloadfuncs 51 52 Parse Arg arg1 arg2 rest 56 57 Parse arg arg1 arg2 58 53 59 If (Length( arg1 ) = 0) | (Verify( arg1, '/-?' ) = 0) Then Do; 54 60 Do i = 1 to 1000 … … 57 63 Say helpText 58 64 End; 59 Return 65 Return 1 60 66 End; 61 If Length( arg2 ) = 0 Then Do; 67 68 If Length( arg2 ) == 0 Then Do; 62 69 Say " Way to go Beaver... How about an out-put file name ?" 63 Return 70 Return 2 64 71 End; 65 72 mapFile = arg1 /* Can be Null, in which case we pull from stdin. */ 66 73 outFile = arg2 74 fFlatMode = 0; 67 75 68 76 /* erase outfile */ /* kill the old map file */ … … 73 81 Do While Lines( mapFile ) <> 0 74 82 watcomText = LineIn( mapFile ) 75 Parse Value watcomText With "Executable Image: " fileName "." fileExt 76 77 If fileName <> "" Then Do; /* Found match */ 78 call lineout outfile ,' ' 79 call lineout outfile ,' ' || fileName 80 call lineout outfile ,' ' 81 Leave; /* Break from loop. */ 83 /*Parse Value watcomText With "Executable Image: " fileName "." fileExt*/ 84 Parse Value watcomText With "Executable Image: " sFilename 85 If (sFilename <> '') Then Do; 86 sFilename = filespec('name', sFilename); 87 Parse Var sFilename fileName "." fileExt 88 If fileName <> "" Then Do; /* Found match */ 89 call lineout outfile ,' ' 90 call lineout outfile ,' ' || fileName 91 call lineout outfile ,' ' 92 Leave; /* Break from loop. */ 93 End; 82 94 End; 83 95 End 84 96 If Lines( mapFile ) = 0 Then Do; /* If end of file ... */ 85 97 Say "Error: Expected to find line with text 'Executable Image:' " 86 Return 98 Return 3 87 99 End 88 100 … … 97 109 If Lines( mapFile ) = 0 Then Do; /* If end of file ... */ 98 110 Say "Error: Expected to find line with text 'Segments ... Size' " 99 Return 100 End 101 junk = LineIn( mapFile ) /* Discard a couple lines of formatting. */ 102 junk = LineIn( mapFile ) 103 111 Return 4 112 End 113 114 115 junk = LineIn( mapFile ) /* Discard a couple lines of formatting. */ 116 junk = LineIn( mapFile ) /* Discard a couple lines of formatting. */ 104 117 /*--- 4. Translate segment table. ---*/ 105 call lineout outfile , " Start Length Name Class" 106 Do While Lines( mapFile ) <> 0 107 watcomText = LineIn( mapFile ) 108 Parse Value watcomText With segName className groupName address size . 118 /*"Segment Class Group Address Size"*/ 119 iClass = pos('Class', watcomText); 120 iGroup = pos('Group', watcomText); 121 iAddress = pos('Address', watcomText); 122 iSize = pos('Size', watcomText); 123 124 call lineout outfile , " Start Length Name Class" /* bird bird bird fixed!!! */ 125 Do While Lines( mapFile ) <> 0 126 watcomText = LineIn( mapFile ) 127 /* do it the hard way to make sure we support spaces segment names. */ 128 segName = strip(substr(watcomText, 1, iClass-1)); 109 129 If segName = "" Then Leave; /* Empty line, break from loop. */ 110 length = Substr( size, 4, 5 ) || 'H ' 130 className = strip(substr(watcomText, iClass, iGroup-iClass)); 131 groupName = strip(substr(watcomText, iGroup, iAddress-iGroup)); 132 address = strip(substr(watcomText, iAddress, iSize-iAddress)); 133 size = strip(substr(watcomText, iSize)); 134 if (pos(':', address) <= 0) then /* NT binaries doesn't have a segment number. */ 135 do 136 fFlatMode = 1; 137 address = '0001:'||address; 138 end 139 length = right(strip(strip(size), 'L', '0'), 9, '0') || 'H ' 111 140 segName = Left( segName, 23 ) 112 141 call lineout outfile ,' ' || address || ' ' || length || segName || className … … 124 153 Do While Lines( mapFile ) <> 0 125 154 watcomText = LineIn( mapFile ) 126 Parse Value watcomText With seg ':' ofs 10 . 16 declaration 155 Parse Value watcomText With seg ':' ofs 14 . 16 declaration 156 if (fFlatMode) then 157 do 158 seg = '0001'; 159 Parse Value watcomText With ofs 9 . 16 declaration 160 end 161 else 162 do /* kso: more workarounds */ 163 if (is_Hex(seg) & length(ofs) > 4 & \is_Hex(substr(ofs,5,1))) then 164 ofs = '0000'||left(ofs,4); 165 end 166 /*say ofs '-'declaration*/ 127 167 is_Adress = (is_Hex(seg) = 1) & (is_Hex(ofs) = 1) 128 If (is_Adress = 1) Then Do; 129 168 If ((is_Adress = 1) & (seg <> '0000')) Then Do; /* bird: skip symbols with segment 0. (__DOSseg__) */ 130 169 /*--- Haven't done the work to xlate operator symbols - skip the line. */ 131 170 If Pos( '::operator', declaration ) <> 0 Then Iterate; … … 158 197 call lineout outfile ,' ' || seg || ':' || ofs || ' ' || declaration 159 198 End; 199 200 /* check for entry point, if found we add it and quit. */ 201 if (pos('Entry point address', watcomText) > 0) then 202 do 203 parse var watcomText 'Entry point address:' sEntryPoint 204 if (pos(':', sEntryPoint) <= 0) then 205 sEntryPoint = '0001:'||strip(sEntryPoint); 206 call lineout outfile, '' 207 call lineout outfile, 'Program entry point at' strip(sEntryPoint) 208 leave; 209 end 160 210 End; /* End While through symbol section, end of input file. */ 161 211 162 Return; /* End of program. */ 212 call stream outfile, 'c', 'close'; 213 call stream mapfile, 'c', 'close'; 214 215 Return 0; /* End of program. */ 163 216 164 217 /*--- Helper subroutines. ---*/ … … 184 237 Return StripMatchedParen( string ) 185 238 End; 186 End;239 return; 187 240 188 241 ReplaceSubstr: … … 198 251 End; 199 252 Return string 200 End;253 return; 201 254 202 255 is_Hex: … … 204 257 Parse Arg string 205 258 Return (Length(string) > 0) & (Verify( string, '0123456789abcdefABCDEF' ) = 0) 206 End;259 return;
Note:
See TracChangeset
for help on using the changeset viewer.