[llvm-bugs] [Bug 34636] New: make -fsanitize-coverage=pc-table friendly with -ffunction-sections -Wl, -gc-sections
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Sep 15 16:24:31 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=34636
Bug ID: 34636
Summary: make -fsanitize-coverage=pc-table friendly with
-ffunction-sections -Wl,-gc-sections
Product: new-bugs
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: new bugs
Assignee: mascasa at google.com
Reporter: kcc at google.com
CC: ekarpenkov at apple.com, eugeni.stepanov at gmail.com,
llvm-bugs at justinbogner.com, llvm-bugs at lists.llvm.org,
peter at pcc.me.uk
[discussed previously at
http://lists.llvm.org/pipermail/llvm-dev/2017-September/117315.html]
On linux we have two problems with -fsanitize=fuzzer and -ffunction-sections
-Wl,-gc-sections
Test for these: projects/compiler-rt/test/fuzzer/GcSectionsTest.cpp
First problem:
% clang -std=c++11 -ffunction-sections -Wl,-gc-sections -fsanitize=fuzzer
GcSectionsTest.cpp
/tmp/GcSectionsTest-065286.o: In function `sancov.module_ctor':
GcSectionsTest.cpp:(.text.sancov.module_ctor[sancov.module_ctor]+0x22):
undefined reference to `__start___sancov_pcs'
GcSectionsTest.cpp:(.text.sancov.module_ctor[sancov.module_ctor]+0x2c):
undefined reference to `__stop___sancov_pcs'
Here, the table produced by -fsanitize-coverage=pc-table __sancov_pcs gets
dropped by the bfd linker (on Ubuntu 14.04).
With a better linker (-fuse-ld=gold or -fuse-ld=lld) this doesn't happen,
but we still *may* need to find a workaround suitable for old ld. Or maybe not.
Second:
% clang -std=c++11 -ffunction-sections -Wl,-gc-sections -fsanitize=fuzzer
GcSectionsTest.cpp -fuse-ld=lld && nm a.out | grep Unused
000000000023f590 t UnusedFunctionShouldBeRemovedByLinker
here, gc-sections is essentially disabled because -fsanitize-coverage=pc-table
makes all functions used.
eugenis@ suggests that all we need here is to use
https://llvm.org/docs/LangRef.html#associated-metadata to mark the pc-table as
associated with it's function.
This is important, we need gc-sections to work.
But once we fix it, we'll need a test (in test/fuzzer/gc-sections.test)
but the test won't work with bfd linker, see above.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170915/d2c04007/attachment.html>
More information about the llvm-bugs
mailing list