[hwasan] print globals in symbolizer-friendly format.

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D109698
This commit is contained in:
Florian Mayer 2021-09-13 16:37:44 +01:00
parent 1bd5ea968e
commit 95ba9f957a
2 changed files with 11 additions and 7 deletions

View File

@ -351,14 +351,16 @@ static void ShowHeapOrGlobalCandidate(uptr untagged_addr, tag_t *candidate,
uptr size = GetGlobalSizeFromDescriptor(mem);
if (size == 0)
// We couldn't find the size of the global from the descriptors.
Printf("%p is located to the %s of a global variable in (%s+0x%x)\n",
untagged_addr, candidate == left ? "right" : "left", module_name,
module_address);
Printf(
"%p is located to the %s of a global variable in "
"\n #0 0x%x (%s+0x%x)\n",
untagged_addr, candidate == left ? "right" : "left", mem,
module_name, module_address);
else
Printf(
"%p is located to the %s of a %zd-byte global variable in "
"(%s+0x%x)\n",
untagged_addr, candidate == left ? "right" : "left", size,
"\n #0 0x%x (%s+0x%x)\n",
untagged_addr, candidate == left ? "right" : "left", size, mem,
module_name, module_address);
}
Printf("%s", d.Default());

View File

@ -12,9 +12,11 @@ int x = 1;
int main(int argc, char **argv) {
// CHECK: Cause: global-overflow
// RSYM: is located 0 bytes to the right of 4-byte global variable x {{.*}} in {{.*}}global.c.tmp
// RNOSYM: is located to the right of a 4-byte global variable in ({{.*}}global.c.tmp+{{.*}})
// RNOSYM: is located to the right of a 4-byte global variable in
// RNOSYM-NEXT: #0 0x{{.*}} ({{.*}}global.c.tmp+{{.*}})
// LSYM: is located 4 bytes to the left of 4-byte global variable x {{.*}} in {{.*}}global.c.tmp
// LNOSYM: is located to the left of a 4-byte global variable in ({{.*}}global.c.tmp+{{.*}})
// LNOSYM: is located to the left of a 4-byte global variable in
// LNOSYM-NEXT: #0 0x{{.*}} ({{.*}}global.c.tmp+{{.*}})
// CHECK-NOT: can not describe
(&x)[atoi(argv[1])] = 1;
}