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
6 Ensure jsoncpp symbols have public visibility and are thus excluded from
7 CFI checks and whole-program optimization. This is achieved by defining
8 JSON_DLL_BUILD which in turn causes json/config.h to define JSON_API as
9 __attribute__((visibility("default"))). The latter macro is used to tag
10 jsoncpp classes and namespace functions throughout jsoncpp's headers.
14 Change-Id: I56277737b7d9ecaeb5e17c8d21a2e55f3d5d5bc9
15 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3919652
16 Reviewed-by: Thomas Anderson <thomasanderson@chromium.org>
17 Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
18 Cr-Commit-Position: refs/heads/main@{#1052077}
20 build/linux/unbundle/jsoncpp.gn | 5 +++++
21 1 file changed, 5 insertions(+)
23 diff --git a/build/linux/unbundle/jsoncpp.gn b/build/linux/unbundle/jsoncpp.gn
24 index 544f9d13c9..e84a0ef27a 100644
25 --- a/build/linux/unbundle/jsoncpp.gn
26 +++ b/build/linux/unbundle/jsoncpp.gn
27 @@ -3,6 +3,11 @@ import("//build/shim_headers.gni")
29 pkg_config("jsoncpp_config") {
30 packages = [ "jsoncpp" ]
32 + # Defining JSON_DLL_BUILD applies public visibility to jsoncpp classes
33 + # thus deactivating CFI checks for them. This avoids CFI violations in
34 + # virtual calls to system jsoncpp library (https://crbug.com/1365218).
35 + defines = [ "JSON_DLL_BUILD" ]
38 shim_headers("jsoncpp_shim") {