aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/distrib
diff options
context:
space:
mode:
authorGravatar Muxi Yan <muxi@users.noreply.github.com>2018-08-24 09:34:58 -0700
committerGravatar GitHub <noreply@github.com>2018-08-24 09:34:58 -0700
commit35479b8a80c9c47937dbda2dfe173fc2c3b91873 (patch)
tree7452b6a53fb47fa8b392f9e990667d0806c31d64 /tools/distrib
parent088454b0b16894c90416d5d5ec6e202aaf73a3c7 (diff)
parent571109e40030548a17ea10ff208a1dec6b79f8a3 (diff)
Merge pull request #16358 from muxi/privatize-boringssl
Make symbols of BoringSSL private
Diffstat (limited to 'tools/distrib')
-rwxr-xr-xtools/distrib/check_shadow_boringssl_symbol_list.sh32
-rwxr-xr-xtools/distrib/generate_grpc_shadow_boringssl_symbol_list.sh45
2 files changed, 77 insertions, 0 deletions
diff --git a/tools/distrib/check_shadow_boringssl_symbol_list.sh b/tools/distrib/check_shadow_boringssl_symbol_list.sh
new file mode 100755
index 0000000000..34ba09e07d
--- /dev/null
+++ b/tools/distrib/check_shadow_boringssl_symbol_list.sh
@@ -0,0 +1,32 @@
+#!/bin/bash
+# Copyright 2018 gRPC authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+# Check if the commit version of BoringSSL podspec, BoringSSL submodule, and
+# the shadowed symbol list are all based on the same BoringSSL commit.
+set -e
+
+cd $(dirname $0)
+
+boringssl_podspec_original="../../src/objective-c/BoringSSL-GRPC.podspec"
+symbol_list="../../src/objective-c/grpc_shadow_boringssl_symbol_list"
+
+# Check BoringSSL version matches
+ver1=$(git submodule |grep "boringssl " | awk '{print $1}' | head -n 1)
+ver2=$(cat $boringssl_podspec_original | grep ':commit =>' | sed -E 's/.*"(.*)".*/\1/g')
+ver3=$(cat $symbol_list | sed -n '2 p')
+[ $ver1 == $ver2 ] && [ $ver1 == $ver3 ] || { echo "BoringSSL podspec (src/objective-c/BoringSSL.podspec), BoringSSL submodule (third_party/boringssl), and BoringSSL symbol list (src/objective-c/grpc_shadow_boringssl_symbol_list) commit do not match." ; echo "BoringSSL podspec: $ver1" ; echo "BoringSSL submodule: $ver2" ; echo "BoringSSL symbol list: $ver3" ; exit 1 ; }
+
+exit 0
diff --git a/tools/distrib/generate_grpc_shadow_boringssl_symbol_list.sh b/tools/distrib/generate_grpc_shadow_boringssl_symbol_list.sh
new file mode 100755
index 0000000000..2e5bb44548
--- /dev/null
+++ b/tools/distrib/generate_grpc_shadow_boringssl_symbol_list.sh
@@ -0,0 +1,45 @@
+#!/bin/bash
+# Copyright 2018 gRPC authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Generate the list of boringssl symbols that need to be shadowed based on the
+# current boringssl submodule. Requires local toolchain to build boringssl.
+set -e
+
+cd $(dirname $0)
+
+symbol_list="../../src/objective-c/grpc_shadow_boringssl_symbol_list"
+
+ssl_lib='../../third_party/boringssl/build/ssl/libssl.a'
+crypto_lib='../../third_party/boringssl/build/crypto/libcrypto.a'
+
+# Generate boringssl archives
+( cd ../../third_party/boringssl ; mkdir -p build ; cd build ; cmake .. ; make )
+
+# Generate shadow_boringssl.h
+outputs="$(nm -C $ssl_lib)"$'\n'"$(nm -C $crypto_lib)"
+symbols=$(echo "$outputs" |
+ grep '^[0-9a-f]* [A-Z] ' | # Only public symbols
+ grep -v ' bssl::' | # Filter BoringSSL symbols since they are already namespaced
+ sed 's/(.*//g' | # Remove parenthesis from C++ symbols
+ grep '^[0-9a-f]* [A-Z] _' | # Filter symbols that is not prefixed with '_'
+ sed 's/[0-9a-f]* [A-Z] _\(.*\)/\1/g') # Extract the symbol names
+
+commit=$(git submodule | grep "boringssl " | awk '{print $1}' | head -n 1)
+
+echo "# Automatically generated by tools/distrib/generate_grpc_shadow_boringssl_symbol_list.sh" > $symbol_list
+echo $commit >> $symbol_list
+echo "$symbols" >> $symbol_list
+
+exit 0