|
54 | 54 | # <section> <address> B <name>
|
55 | 55 | # Named identifier at a specific address (global variable).
|
56 | 56 | #
|
57 |
| -# We also process any function symbols, and build a lookup map with varying |
58 |
| -# levels of detail to assist in symbol lookup later on (each map entry stores |
59 |
| -# the symbol offset relative to its section): |
60 |
| -# section, name, and offset |
| 57 | +# We also process any function symbols, and build a lookup map for section-name |
| 58 | +# pairs and just name. Due to the possibility of having symbols with identical |
| 59 | +# names (in the same section, e.g. global and/or one or more local), we append |
| 60 | +# -<n> to every 2nd and later copy of the same symbol name in the current |
| 61 | +# section. |
61 | 62 | # section and name
|
62 |
| -# name and offset |
63 | 63 | # name
|
64 | 64 | # (If multiple symbols map to any of the above combinations, that specific
|
65 | 65 | # combination is omitted from the mapping.)
|
|
68 | 68 | # is not located in a section that starts with .exit.text, .init.text, or
|
69 | 69 | # .meminit.text) we determine its in-section offset and output a record:
|
70 | 70 | #
|
71 |
| -# <section> <offset> F <name> <address> |
| 71 | +# <section> <offset> F <name> <address> <section-base-address> |
72 | 72 | # Named function at a specific address.
|
73 | 73 | #
|
74 | 74 | # Finally, each relocation record from a non-init or exit section that relates
|
|
103 | 103 | if (v0h >= v1h) {
|
104 | 104 | d = sprintf("%08x%08x", v0h - v1h, v0l - v1l);
|
105 | 105 | } else {
|
106 |
| - printf "ERROR: Invalid addresses: %s vs %s\n", v0, v1; |
| 106 | + printf "ERROR: [1.a] Invalid: %s - %s\n", v0, v1; |
107 | 107 | d = 0;
|
108 | 108 | errc++;
|
109 | 109 | }
|
|
113 | 113 | v0l += 4294967296;
|
114 | 114 | d = sprintf("%08x%08x", v0h - v1h, v0l - v1l);
|
115 | 115 | } else {
|
116 |
| - printf "ERROR: Invalid addresses: %s vs %s\n", v0, v1; |
| 116 | + printf "ERROR: [1.b] Invalid: %s - %s\n", v0, v1; |
117 | 117 | d = 0;
|
118 | 118 | errc++;
|
119 | 119 | }
|
|
134 | 134 |
|
135 | 135 | /^SYMBOL / {
|
136 | 136 | phase++;
|
| 137 | + delete scnt; |
137 | 138 | next;
|
138 | 139 | }
|
139 | 140 |
|
|
157 | 158 | next;
|
158 | 159 |
|
159 | 160 | off = subl($1, secs[$4]);
|
160 |
| - id = $4 " " $6 " " off; |
161 |
| - if (id in smap) { |
162 |
| - if (smap[id] != $1) |
163 |
| - smap[id] = 0; |
164 |
| - } else |
165 |
| - smap[id] = $1; |
166 | 161 |
|
167 |
| - id = $4 " " $6; |
168 |
| - if (id in smap) { |
169 |
| - if (smap[id] != $1) |
170 |
| - smap[id] = 0; |
171 |
| - } else |
172 |
| - smap[id] = $1; |
| 162 | + sym = $NF; |
| 163 | + scnt[sym]++; |
| 164 | + if (scnt[sym] > 1) |
| 165 | + sym = sym"-"(scnt[sym] - 1); |
173 | 166 |
|
174 |
| - id = $6 " " off; |
| 167 | + # section and name |
| 168 | + id = $4 " " sym; |
175 | 169 | if (id in smap) {
|
176 | 170 | if (smap[id] != $1)
|
177 | 171 | smap[id] = 0;
|
178 | 172 | } else
|
179 | 173 | smap[id] = $1;
|
180 | 174 |
|
181 |
| - id = $6; |
| 175 | + # name |
| 176 | + id = sym; |
182 | 177 | if (id in smap) {
|
183 | 178 | if (smap[id] != $1)
|
184 | 179 | smap[id] = 0;
|
|
192 | 187 | if ($4 ~ /^\.(exit|init|meminit)\.text/)
|
193 | 188 | next;
|
194 | 189 |
|
195 |
| - id = $4 " " $6 " " $1; |
196 |
| - if (!(id in smap)) |
197 |
| - id = $4 " " $6; |
198 |
| - if (!(id in smap)) |
199 |
| - id = $6 " " $1; |
| 190 | + sym = $NF; |
| 191 | + scnt[sym]++; |
| 192 | + if (scnt[sym] > 1) |
| 193 | + sym = sym"-"(scnt[sym] - 1); |
| 194 | +
|
| 195 | + # section and name |
| 196 | + id = $4 " " sym; |
200 | 197 | if (!(id in smap))
|
201 |
| - id = $6; |
| 198 | + id = sym; |
| 199 | + # name |
202 | 200 | if (id in smap) {
|
203 | 201 | addr = smap[id];
|
204 | 202 | if (!addr)
|
205 |
| - print "ERROR: Non-unique symbol: " $4 " " $6 " " $1; |
| 203 | + print "ERROR: Not unique: " $4 " " $6 " " $1 " ["sym"]"; |
206 | 204 | } else {
|
207 |
| - print "ERROR: Could not find " $4 " " $6 " " $1; |
| 205 | + print "ERROR: Not found " $4 " " $6 " " $1 " ["sym"]"; |
208 | 206 | addr = 0;
|
209 | 207 | }
|
210 | 208 |
|
|
256 | 254 | if (length(d) <= 8) {
|
257 | 255 | d = sprintf("%08x%08x", v0h, v0l);
|
258 | 256 | } else {
|
259 |
| - printf "#error Invalid addresses: %s + %s\n", v0, v1 \ |
| 257 | + printf "#error [2.a] Invalid: %s + %s\n", v0, v1 \ |
260 | 258 | >"/dev/stderr";
|
261 | 259 | errc++;
|
262 | 260 | }
|
|
284 | 282 | if (v0h >= v1h) {
|
285 | 283 | d = sprintf("%08x%08x", v0h - v1h, v0l - v1l);
|
286 | 284 | } else {
|
287 |
| - printf "#error Invalid addresses: %s - %s\n", v0, v1 \ |
| 285 | + printf "#error [2.b] Invalid: %s - %s\n", v0, v1 \ |
288 | 286 | >"/dev/stderr";
|
289 | 287 | errc++;
|
290 | 288 | }
|
|
294 | 292 | v0l += 4294967296;
|
295 | 293 | d = sprintf("%08x%08x", v0h - v1h, v0l - v1l);
|
296 | 294 | } else {
|
297 |
| - printf "#error Invalid addresses: %s - %s\n", v0, v1 \ |
| 295 | + printf "#error [2.c] Invalid: %s - %s\n", v0, v1 \ |
298 | 296 | >"/dev/stderr";
|
299 | 297 | errc++;
|
300 | 298 | }
|
|
0 commit comments