[ This patch attempts to fix a problem, for which another patch was submitted earlier ( https://reviews.llvm.org/D34149 ). ]
Consider this test-case, which generates a segmentation fault:
...
int
main (void)
{
void *ptr = (void *)0x01; int value = *((int *) ptr); return 0;
}
...
Using LD_PRELOAD we can see how libasan handles the segfault:
...
$ LD_PRELOAD=install/lib64/libasan.so ./a.out
...
Focusing just on the backtrace part for main we have:
...
#0 0x4004a6 in main (a.out+0x4004a6)
...
and when compiled with -g, we have instead instead:
...
#0 0x4004a6 in main test.c:5
...
When we compile the test-case to assembly without -g, but compile the
assembly with -g like this:
...
$ gcc test.c -S
$ gcc test.s -gdwarf-2 -c
$ gcc test.o
...
we get this, similar to the case without -g:
...
#0 0x400481 in main (a.out+0x400481)
...
In this case, the executable contains DWARF file and line number information
for the assembly file, but it's not used because the function name is
missing in the DWARF .debug_info.
This patch fixes this, allowing us to get:
...
#0 0x400481 in main test.s:14
...