Skip to content

Commit bab6bc5

Browse files
committed
dtrace: ensure SDT probe processing can handle symbols with same names
The process used to determine SDT probe information on arm64 broke due to multiple occurences of the same symbol (global and local, or multiple local symbols). The logic to determine a correct matching of symbols between the linked kernel image (.tmp_vmlinux1) and the kernel object (vmlinux.o) has been updated to account for this possibility. Orabug: 29134607 Signed-off-by: Kris Van Hees <[email protected]> Reviewed-by: Nick Alcock <[email protected]>
1 parent a63343f commit bab6bc5

File tree

1 file changed

+31
-33
lines changed

1 file changed

+31
-33
lines changed

scripts/dtrace_sdt_arm64.sh

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ fi
5454
# <section> <address> B <name>
5555
# Named identifier at a specific address (global variable).
5656
#
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.
6162
# section and name
62-
# name and offset
6363
# name
6464
# (If multiple symbols map to any of the above combinations, that specific
6565
# combination is omitted from the mapping.)
@@ -68,7 +68,7 @@ fi
6868
# is not located in a section that starts with .exit.text, .init.text, or
6969
# .meminit.text) we determine its in-section offset and output a record:
7070
#
71-
# <section> <offset> F <name> <address>
71+
# <section> <offset> F <name> <address> <section-base-address>
7272
# Named function at a specific address.
7373
#
7474
# Finally, each relocation record from a non-init or exit section that relates
@@ -103,7 +103,7 @@ fi
103103
if (v0h >= v1h) {
104104
d = sprintf("%08x%08x", v0h - v1h, v0l - v1l);
105105
} else {
106-
printf "ERROR: Invalid addresses: %s vs %s\n", v0, v1;
106+
printf "ERROR: [1.a] Invalid: %s - %s\n", v0, v1;
107107
d = 0;
108108
errc++;
109109
}
@@ -113,7 +113,7 @@ fi
113113
v0l += 4294967296;
114114
d = sprintf("%08x%08x", v0h - v1h, v0l - v1l);
115115
} else {
116-
printf "ERROR: Invalid addresses: %s vs %s\n", v0, v1;
116+
printf "ERROR: [1.b] Invalid: %s - %s\n", v0, v1;
117117
d = 0;
118118
errc++;
119119
}
@@ -134,6 +134,7 @@ fi
134134
135135
/^SYMBOL / {
136136
phase++;
137+
delete scnt;
137138
next;
138139
}
139140
@@ -157,28 +158,22 @@ fi
157158
next;
158159
159160
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;
166161
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);
173166
174-
id = $6 " " off;
167+
# section and name
168+
id = $4 " " sym;
175169
if (id in smap) {
176170
if (smap[id] != $1)
177171
smap[id] = 0;
178172
} else
179173
smap[id] = $1;
180174
181-
id = $6;
175+
# name
176+
id = sym;
182177
if (id in smap) {
183178
if (smap[id] != $1)
184179
smap[id] = 0;
@@ -192,19 +187,22 @@ fi
192187
if ($4 ~ /^\.(exit|init|meminit)\.text/)
193188
next;
194189
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;
200197
if (!(id in smap))
201-
id = $6;
198+
id = sym;
199+
# name
202200
if (id in smap) {
203201
addr = smap[id];
204202
if (!addr)
205-
print "ERROR: Non-unique symbol: " $4 " " $6 " " $1;
203+
print "ERROR: Not unique: " $4 " " $6 " " $1 " ["sym"]";
206204
} else {
207-
print "ERROR: Could not find " $4 " " $6 " " $1;
205+
print "ERROR: Not found " $4 " " $6 " " $1 " ["sym"]";
208206
addr = 0;
209207
}
210208
@@ -256,7 +254,7 @@ fi
256254
if (length(d) <= 8) {
257255
d = sprintf("%08x%08x", v0h, v0l);
258256
} else {
259-
printf "#error Invalid addresses: %s + %s\n", v0, v1 \
257+
printf "#error [2.a] Invalid: %s + %s\n", v0, v1 \
260258
>"/dev/stderr";
261259
errc++;
262260
}
@@ -284,7 +282,7 @@ fi
284282
if (v0h >= v1h) {
285283
d = sprintf("%08x%08x", v0h - v1h, v0l - v1l);
286284
} else {
287-
printf "#error Invalid addresses: %s - %s\n", v0, v1 \
285+
printf "#error [2.b] Invalid: %s - %s\n", v0, v1 \
288286
>"/dev/stderr";
289287
errc++;
290288
}
@@ -294,7 +292,7 @@ fi
294292
v0l += 4294967296;
295293
d = sprintf("%08x%08x", v0h - v1h, v0l - v1l);
296294
} else {
297-
printf "#error Invalid addresses: %s - %s\n", v0, v1 \
295+
printf "#error [2.c] Invalid: %s - %s\n", v0, v1 \
298296
>"/dev/stderr";
299297
errc++;
300298
}

0 commit comments

Comments
 (0)