Rename whitelist to allowlist in tflite_ios_static_framework

PiperOrigin-RevId: 319926991
Change-Id: I18a4eb0f23c7b80cc1ccbefa16f6ce75e15a378b
This commit is contained in:
Taehee Jeong 2020-07-06 23:18:09 -07:00 committed by TensorFlower Gardener
parent 3bd8e00d55
commit dfd69610fa
6 changed files with 22 additions and 22 deletions

View File

@ -12,9 +12,9 @@ package(
)
sh_binary(
name = "hide_symbols_with_whitelist",
name = "hide_symbols_with_allowlist",
srcs = [
"hide_symbols_with_whitelist.sh",
"hide_symbols_with_allowlist.sh",
],
)
@ -53,9 +53,9 @@ tflite_ios_static_framework(
":xnnpack_delegate.h",
"//tensorflow/lite/c:common.h",
],
allowlist_symbols_file = ":allowlist_TensorFlowLiteC.txt",
bundle_name = "TensorFlowLiteC",
minimum_os_version = TFL_MINIMUM_OS_VERSION,
whitelist_symbols_file = ":whitelist_TensorFlowLiteC.txt",
deps = [
":tensorflow_lite_c",
],
@ -101,9 +101,9 @@ tflite_ios_static_framework(
hdrs = [
":coreml_delegate.h",
],
allowlist_symbols_file = ":allowlist_TensorFlowLiteCCoreML.txt",
bundle_name = "TensorFlowLiteCCoreML",
minimum_os_version = TFL_MINIMUM_OS_VERSION,
whitelist_symbols_file = ":whitelist_TensorFlowLiteCCoreML.txt",
deps = [
"//tensorflow/lite/experimental/delegates/coreml:coreml_delegate",
],
@ -120,9 +120,9 @@ tflite_ios_static_framework(
hdrs = [
"//tensorflow/lite/delegates/gpu:metal_delegate.h",
],
allowlist_symbols_file = ":allowlist_TensorFlowLiteCMetal.txt",
bundle_name = "TensorFlowLiteCMetal",
minimum_os_version = TFL_MINIMUM_OS_VERSION,
whitelist_symbols_file = ":whitelist_TensorFlowLiteCMetal.txt",
deps = [
"//tensorflow/lite/delegates/gpu:metal_delegate",
],

View File

@ -15,13 +15,13 @@
# ==============================================================================
#
# A script to merge Mach-O object files into a single object file and hide
# their internal symbols. Only whitelisted symbols will be visible in the
# their internal symbols. Only allowed symbols will be visible in the
# symbol table after this script.
# To run this script, you must set several variables:
# INPUT_FRAMEWORK: a zip file containing the iOS static framework.
# BUNDLE_NAME: the pod/bundle name of the iOS static framework.
# WHITELIST_FILE_PATH: contains the whitelisted symbols.
# ALLOWLIST_FILE_PATH: contains the allowed symbols.
# OUTPUT: the output zip file.
# Halt on any error or any unknown variable.
@ -32,15 +32,15 @@ LD_DEBUGGABLE_FLAGS="-x"
# library at a time.
# LD_DEBUGGABLE_FLAGS="-d"
# Exits if C++ symbols are found in the whitelist list.
if grep -q "^__Z" "${WHITELIST_FILE_PATH}"
# Exits if C++ symbols are found in the allowlist.
if grep -q "^__Z" "${ALLOWLIST_FILE_PATH}"
then
echo "ERROR: Failed in symbol hiding. This rule does not permit hiding of" \
"C++ symbols due to possible serious problems mixing symbol hiding," \
"shared libraries and the C++ runtime." \
"More info can be found in go/ios-symbols-hiding." \
"Please recheck the whitelist list and remove C++ symbols:"
echo "$(grep "^__Z" "${WHITELIST_FILE_PATH}")"
"Please recheck the allowlist and remove C++ symbols:"
echo "$(grep "^__Z" "${ALLOWLIST_FILE_PATH}")"
exit 1 # terminate and indicate error
fi
# Unzips the framework zip file into a temp workspace.
@ -87,7 +87,7 @@ do
mv *.o "${archdir}"/
objects_file_list=$(mktemp)
# Hides the symbols except the whitelisted ones.
# Hides the symbols except the allowed ones.
find "${archdir}" -name "*.o" >> "${objects_file_list}"
# Checks whether bitcode is enabled in the framework.
@ -104,13 +104,13 @@ do
if [[ "$all_objects_have_bitcode" = "true" ]]; then
echo "The ${arch} in ${executable_file} is fully bitcode-enabled."
xcrun ld -r -bitcode_bundle -exported_symbols_list \
"${WHITELIST_FILE_PATH}" \
"${ALLOWLIST_FILE_PATH}" \
$LD_DEBUGGABLE_FLAGS \
-filelist "${objects_file_list}" -o "${arch_file}_processed.o"
else
echo "The ${arch} in ${executable_file} is NOT fully bitcode-enabled."
xcrun ld -r -exported_symbols_list \
"${WHITELIST_FILE_PATH}" \
"${ALLOWLIST_FILE_PATH}" \
$LD_DEBUGGABLE_FLAGS \
-filelist "${objects_file_list}" -o "${arch_file}_processed.o"
fi

View File

@ -17,14 +17,14 @@ TFL_DISABLED_SANITIZER_TAGS = [
"notsan",
]
# iOS static framework with symbol whitelist. Exported C++ symbbols might cause
# symbol collision with other libraries. List of symbols to whitelist can be
# iOS static framework with symbol allowlist. Exported C++ symbbols might cause
# symbol collision with other libraries. List of symbols to allowlist can be
# generated by running `nm -m -g FRAMEWORK_LIBRARY | grep _TfLite` for framework
# built with `ios_static_framework` rule.
def tflite_ios_static_framework(
name,
bundle_name,
whitelist_symbols_file,
allowlist_symbols_file,
exclude_resources = True,
**kwargs):
"""TFLite variant of ios_static_framework with symbol hiding.
@ -33,7 +33,7 @@ def tflite_ios_static_framework(
name: The name of the target.
bundle_name: The name to give to the framework bundle, without the
".framework" extension. If omitted, the target's name will be used.
whitelist_symbols_file: a file including a list of whitelisted symbols,
allowlist_symbols_file: a file including a list of allowed symbols,
one symbol per line.
exclude_resources: Indicates whether resources should be excluded from the
bundle. This can be used to avoid unnecessarily bundling resources if
@ -54,13 +54,13 @@ def tflite_ios_static_framework(
srcs = [
framework_target,
whitelist_symbols_file,
allowlist_symbols_file,
]
cmd = ("INPUT_FRAMEWORK=\"$(location " + framework_target + ")\" " +
"BUNDLE_NAME=\"" + bundle_name + "\" " +
"WHITELIST_FILE_PATH=\"$(location " + whitelist_symbols_file + ")\" " +
"ALLOWLIST_FILE_PATH=\"$(location " + allowlist_symbols_file + ")\" " +
"OUTPUT=\"$(OUTS)\" " +
"\"$(location //tensorflow/lite/experimental/ios:hide_symbols_with_whitelist)\"")
"\"$(location //tensorflow/lite/experimental/ios:hide_symbols_with_allowlist)\"")
native.genrule(
name = name,
@ -68,6 +68,6 @@ def tflite_ios_static_framework(
outs = [name + ".zip"],
cmd = cmd,
tools = [
"//tensorflow/lite/experimental/ios:hide_symbols_with_whitelist",
"//tensorflow/lite/experimental/ios:hide_symbols_with_allowlist",
],
)