summaryrefslogtreecommitdiff
path: root/fuzz
diff options
context:
space:
mode:
authorAllen Webb <allenwebb@google.com>2018-08-17 14:56:33 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-09-07 18:36:33 -0700
commit6a9a3a62732ff31e247a9eb61a5f4e7c53154ee5 (patch)
tree32a71c89e7266301206cc4dd242332bd5b835892 /fuzz
parent09d4918f464b69390f0c2d12cdd8c6aeafcb2cae (diff)
downloadchrome-ec-6a9a3a62732ff31e247a9eb61a5f4e7c53154ee5.tar.gz
fuzz: Hide conflicts with cstdlib and use clang++ for linking.
This creates a build target called libec.a by setting the visibility of functions that conflict with cstdlib to hidden. It then links those symbols locally into one large object file that makes up libec.a Fuzzing targets are linked against libec.a so that they can invoke ec functionality while depending on outside libraries that need cstdlib. When linking a particular object against cstdlib, to avoid conflicting function declarations put the following before any includes from the ec codebase: #define __stdlib_compat(...) The fuzzing targets are now linked using clang++, so that c++ libraries and objects can be used as part of the fuzzers. BRANCH=none BUG=chromium:876582 TEST=make -j buildfuzztests && ./build/host/host_command_fuzz/host_command_fuzz.exe Change-Id: Ifdfdc6a51c6ef23b4e192b013ca993bf48a4411b Signed-off-by: Allen Webb <allenwebb@google.com> Reviewed-on: https://chromium-review.googlesource.com/1180401 Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'fuzz')
-rw-r--r--fuzz/build.mk14
1 files changed, 13 insertions, 1 deletions
diff --git a/fuzz/build.mk b/fuzz/build.mk
index dc3fb8eb29..7a45116fe2 100644
--- a/fuzz/build.mk
+++ b/fuzz/build.mk
@@ -8,4 +8,16 @@
fuzz-test-list-host = host_command_fuzz
-host_command_fuzz-y = host_command_fuzz.o
+# For fuzzing targets libec.a is built from the ro objects and hides functions
+# that collide with stdlib. The rw only objects are then linked against libec.a
+# with stdlib support. Therefore fuzzing targets that need to call this internal
+# functions should be marked "-y" or "-ro", and fuzzing targets that need stdlib
+# should be marked "-rw". In other words:
+#
+# Does your object file need to link against the Cr50 implementations of stdlib
+# functions?
+# Yes -> use <obj_name>-y
+# Does your object file need to link against cstdlib?
+# Yes -> use <obj_name>-rw
+# Otherwise use <obj_name>-y
+host_command_fuzz-rw = host_command_fuzz.o