unbundle-jsoncpp-avoid-CFI-faults-with-is_cfi-true.patch 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. From ed8d931e35f81d8566835a579caf7d61368f85b7 Mon Sep 17 00:00:00 2001
  2. From: Evangelos Foutras <evangelos@foutrelis.com>
  3. Date: Tue, 27 Sep 2022 22:20:41 +0000
  4. Subject: [PATCH] unbundle/jsoncpp: avoid CFI faults with is_cfi=true
  5. Ensure jsoncpp symbols have public visibility and are thus excluded from
  6. CFI checks and whole-program optimization. This is achieved by defining
  7. JSON_DLL_BUILD which in turn causes json/config.h to define JSON_API as
  8. __attribute__((visibility("default"))). The latter macro is used to tag
  9. jsoncpp classes and namespace functions throughout jsoncpp's headers.
  10. BUG=1365218
  11. Change-Id: I56277737b7d9ecaeb5e17c8d21a2e55f3d5d5bc9
  12. Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3919652
  13. Reviewed-by: Thomas Anderson <thomasanderson@chromium.org>
  14. Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
  15. Cr-Commit-Position: refs/heads/main@{#1052077}
  16. ---
  17. build/linux/unbundle/jsoncpp.gn | 5 +++++
  18. 1 file changed, 5 insertions(+)
  19. diff --git a/build/linux/unbundle/jsoncpp.gn b/build/linux/unbundle/jsoncpp.gn
  20. index 544f9d13c9..e84a0ef27a 100644
  21. --- a/build/linux/unbundle/jsoncpp.gn
  22. +++ b/build/linux/unbundle/jsoncpp.gn
  23. @@ -3,6 +3,11 @@ import("//build/shim_headers.gni")
  24. pkg_config("jsoncpp_config") {
  25. packages = [ "jsoncpp" ]
  26. +
  27. + # Defining JSON_DLL_BUILD applies public visibility to jsoncpp classes
  28. + # thus deactivating CFI checks for them. This avoids CFI violations in
  29. + # virtual calls to system jsoncpp library (https://crbug.com/1365218).
  30. + defines = [ "JSON_DLL_BUILD" ]
  31. }
  32. shim_headers("jsoncpp_shim") {