From: Andrew K. <sup...@gm...> - 2018-04-06 15:49:47
|
Hello folks, When linking with LLD instead of binutils ld, valgrind does not see the debug info. I filed this bug (https://bugs.llvm.org/show_bug.cgi?id=37021) on LLD yesterday which resulted in this conversation on the mailing list: > It's more of a valgrind issue than an LLD issue, but you can work around it by linking with --no-rosegment > --rosegment puts read-only data and executable text in a single segment and make it executable, so your read-only code becomes executable. I think that shouldn't be a default behavior. If valgrind needs that, we can't fix it by changing the default. > But I can't think of a reason that valgrind needs executable data segment. It is likely that valgrind assumes some specific segment layout that the GNU linker creates and can't handle other layout even if it is valid. I had a look at readelf output and the layout of the lld-linked object file looks sane to me. Is there perhaps some adjustment to valgrind we can make to make it compatible with this other linker? Steps to reproduce: // test.c static int *foo(void) { return (int *)10000000; } int main(void) { int *x = foo(); *x += 1; } // looks good with binutils ld clang -o test test.c -g valgrind ./test ==23250== at 0x400597: main (test.c:7) // with lld, valgrind does not see debug info clang -o test test.c -g -fuse-ld=lld valgrind ./test ==24210== at 0x2010F7: ??? (in /home/andy/tmp/test) Regards, Andrew |