Changeset 305 for GPL/branches/uniaud-2.0/tools
- Timestamp:
- Mar 24, 2008, 2:43:42 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/branches/uniaud-2.0/tools/wat2map.cmd
r293 r305 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 */ 1 /* $Id: wat2map.cmd,v 1.1.1.1 2003/07/02 13:57:04 eleph Exp $ */ 9 2 10 3 /* SCCSID = %W% %E% */ … … 54 47 /* <End of helpText> - don't modify this string - used to flag end of help. */ 55 48 /****************************************************************************/ 56 57 Parse arg arg1 arg2 58 49 CALL RXFUNCADD 'sysloadfuncs','rexxutil','sysloadfuncs' 50 call sysloadfuncs 51 52 Parse Arg arg1 arg2 rest 59 53 If (Length( arg1 ) = 0) | (Verify( arg1, '/-?' ) = 0) Then Do; 60 54 Do i = 1 to 1000 … … 63 57 Say helpText 64 58 End; 65 Return 1 66 End; 67 68 If Length( arg2 ) == 0 Then Do; 59 Return 60 End; 61 If Length( arg2 ) = 0 Then Do; 69 62 Say " Way to go Beaver... How about an out-put file name ?" 70 Return 263 Return 71 64 End; 72 65 mapFile = arg1 /* Can be Null, in which case we pull from stdin. */ 73 66 outFile = arg2 74 fFlatMode = 0;75 67 76 68 /* erase outfile */ /* kill the old map file */ … … 81 73 Do While Lines( mapFile ) <> 0 82 74 watcomText = LineIn( mapFile ) 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; 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. */ 94 82 End; 95 83 End 96 84 If Lines( mapFile ) = 0 Then Do; /* If end of file ... */ 97 85 Say "Error: Expected to find line with text 'Executable Image:' " 98 Return 386 Return 99 87 End 100 88 … … 109 97 If Lines( mapFile ) = 0 Then Do; /* If end of file ... */ 110 98 Say "Error: Expected to find line with text 'Segments ... Size' " 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. */ 99 Return 100 End 101 junk = LineIn( mapFile ) /* Discard a couple lines of formatting. */ 102 junk = LineIn( mapFile ) 103 117 104 /*--- 4. Translate segment table. ---*/ 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)); 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 . 129 109 If segName = "" Then Leave; /* Empty line, break from loop. */ 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 ' 110 length = Substr( size, 4, 5 ) || 'H ' 140 111 segName = Left( segName, 23 ) 141 112 call lineout outfile ,' ' || address || ' ' || length || segName || className … … 153 124 Do While Lines( mapFile ) <> 0 154 125 watcomText = LineIn( mapFile ) 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*/ 126 Parse Value watcomText With seg ':' ofs 10 . 16 declaration 167 127 is_Adress = (is_Hex(seg) = 1) & (is_Hex(ofs) = 1) 168 If ((is_Adress = 1) & (seg <> '0000')) Then Do; /* bird: skip symbols with segment 0. (__DOSseg__) */ 128 If (is_Adress = 1) Then Do; 129 169 130 /*--- Haven't done the work to xlate operator symbols - skip the line. */ 170 131 If Pos( '::operator', declaration ) <> 0 Then Iterate; … … 197 158 call lineout outfile ,' ' || seg || ':' || ofs || ' ' || declaration 198 159 End; 199 200 /* check for entry point, if found we add it and quit. */201 if (pos('Entry point address', watcomText) > 0) then202 do203 parse var watcomText 'Entry point address:' sEntryPoint204 if (pos(':', sEntryPoint) <= 0) then205 sEntryPoint = '0001:'||strip(sEntryPoint);206 call lineout outfile, ''207 call lineout outfile, 'Program entry point at' strip(sEntryPoint)208 leave;209 end210 160 End; /* End While through symbol section, end of input file. */ 211 161 212 call stream outfile, 'c', 'close'; 213 call stream mapfile, 'c', 'close'; 214 215 Return 0; /* End of program. */ 162 Return; /* End of program. */ 216 163 217 164 /*--- Helper subroutines. ---*/ … … 237 184 Return StripMatchedParen( string ) 238 185 End; 239 return;186 End; 240 187 241 188 ReplaceSubstr: … … 251 198 End; 252 199 Return string 253 return;200 End; 254 201 255 202 is_Hex: … … 257 204 Parse Arg string 258 205 Return (Length(string) > 0) & (Verify( string, '0123456789abcdefABCDEF' ) = 0) 259 return;206 End;
Note:
See TracChangeset
for help on using the changeset viewer.