source: trunk/src/mapsym.awk@ 196

Last change on this file since 196 was 196, checked in by Valery V. Sedletski, 8 years ago

packages: Packaging fix.

File size: 2.9 KB
Line 
1# $Id: mapsym.awk,v 1.1.1.1 2003/10/04 08:40:16 prokushev Exp $
2#
3# Converts WLINK map files for processing with IBM's MAPSYM.
4# WARNING: It has only been briefly tested with 32-bit LX output.
5# Feb 27, 2014, valerius
6# Added support for 16-bit NE executables
7# Feb 15, 2017, valerius
8# Added support for 32-bit PE executables
9
10BEGIN {
11 group=1
12 segment=2
13 memory=3
14}
15
16/^Executable Image:/ {
17 # delete the driveletter (if any)
18 sub("^[a-zA-Z]:", "", $3)
19
20 # change slashes to backslashes
21 gsub("/", "\\", $3)
22
23 # extract the basename
24 while ((p = index($3, "\\")) > 0) {
25 $3 = substr($3, ++p)
26 }
27
28 printf "\n %s\n\n", $3
29}
30
31/^Entry point address:/ {
32 if (length($4) == 8)
33 printf "\nProgram entry point at %s:%s", "0001", $4
34 else
35 printf "\nProgram entry point at %s", $4
36}
37
38/^Group *Address *Size/ {
39 mode=group
40 groups=0
41 next
42}
43
44/^Segment *Class *Group *Address *Size/ {
45 mode=segment
46 print " Start Length Name Class\n"
47}
48
49/^Address *Symbol$/ {
50 mode=memory
51 if(groups>0)
52 {
53 printf "\n Origin Group\n\n"
54 for(i=0; i<groups; i++)
55 print group_buf[i]
56 }
57 printf "\n Address Publics by Value\n\n"
58}
59
60# HACK: the following works around the problem of __DOSseg__ symbol belonging
61# to an undefined segment (0000).
62
63/__DOSseg__/ {
64 next
65}
66
67# The same with WEAK$ZERO (weak prelinker hack in newer wlinks)
68/0000\:00000000/ {
69 next
70}
71
72/^[^= ]* *....:.... *........$/ {
73 if(mode==group)
74 {
75 group_buf[groups++]=sprintf(" %s %s", toupper($2), $1)
76 }
77}
78
79/^[^= ]* *....:........ *........$/ {
80 if(mode==group)
81 {
82 group_buf[groups++]=sprintf(" %s %s", toupper($2), $1)
83 }
84}
85
86/^[^= ]* *........ *........$/ {
87 if(mode==group)
88 {
89 group_buf[groups++]=sprintf(" %s:%s %s", "0001", toupper($2), $1)
90 }
91}
92
93/^[^= ]* *[^ ]* *[^ ]* *....:.... *........$/ {
94 if(mode==segment && length($4) == 9)
95 {
96 printf " %s 0%sH %-22s %s 16-bit\n", toupper($4), toupper($5), $1, $2
97 }
98}
99
100/^[^= ]* *[^ ]* *[^ ]* *....:........ *........$/ {
101 if(mode==segment && length($4) == 13)
102 {
103 printf " %s 0%sH %-22s %s 32-bit\n", toupper($4), toupper($5), $1, $2
104 }
105}
106
107/^[^= ]* *[^ ]* *[^ ]* *........ *........$/ {
108 if(mode==segment && length($4) == 8)
109 {
110 printf " %s:%s 0%sH %-22s %s 32-bit\n", "0001", toupper($4), toupper($5), $1, $2
111 }
112}
113
114/^....:....\*? *[^ ]*$/ {
115 if(mode==memory && length($1) <= 10)
116 {
117 sel = substr($1, 1, 4)
118 off = substr($1, 6, 4)
119 printf " %s:0000%s %s\n", toupper(sel), toupper(off), $2
120 }
121}
122
123/^....:........\*? *[^ ]*$/ {
124 if(mode==memory && length($1) >= 13)
125 {
126 printf " %s %s\n", toupper(substr($1, 1, 13)), $2
127 }
128}
129
130/^[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]\*? *[^ ]*$/ {
131 if(mode==memory)
132 {
133 printf " %s:%s %s\n", "0001", toupper(substr($1, 1, 8)), $2
134 }
135}
136
137{
138 next
139}
Note: See TracBrowser for help on using the repository browser.