Build: Refactor code-sharing primitives

Makes the interface more aligned with modern cmake, and generally
streamlines the experience.

Change-Id: Iad289c7e6be1af1e7ae80d3792698a31b2d9368e
Signed-off-by: Raef Coles <raef.coles@arm.com>
diff --git a/bl2/CMakeLists.txt b/bl2/CMakeLists.txt
index f2c3365..5ad6a8b 100644
--- a/bl2/CMakeLists.txt
+++ b/bl2/CMakeLists.txt
@@ -136,7 +136,7 @@
 ############################### CODE SHARING ###################################
 
 if (TFM_CODE_SHARING)
-    compiler_create_shared_code(bl2 ${CMAKE_CURRENT_SOURCE_DIR}/src/shared_symbol_template.txt)
+    target_share_symbols(bl2 ${CMAKE_CURRENT_SOURCE_DIR}/bl2_shared_symbols.txt)
 
     if (NOT EXISTS ${MBEDCRYPTO_PATH}/library/code_share.c)
         message(FATAL_ERROR "File ${MBEDCRYPTO_PATH}/library/code_share.c does not exist.
diff --git a/bl2/bl2_shared_symbols.txt b/bl2/bl2_shared_symbols.txt
new file mode 100644
index 0000000..b7a1935
--- /dev/null
+++ b/bl2/bl2_shared_symbols.txt
@@ -0,0 +1,18 @@
+mbedtls_asn1*
+mbedtls_mpi*
+mbedtls_platform*
+mbedtls_rsa*
+
+mbedtls_md*
+
+mbedtls_internal_sha256*
+mbedtls_sha256_free
+mbedtls_sha256_init
+mbedtls_sha256_finish
+mbedtls_sha256_starts
+
+mbedtls_calloc*
+mbedtls_free*
+
+mbedtls_exit*
+memset_func*
diff --git a/bl2/src/shared_symbol_template.txt b/bl2/src/shared_symbol_template.txt
deleted file mode 100644
index 429e0bd..0000000
--- a/bl2/src/shared_symbol_template.txt
+++ /dev/null
@@ -1,34 +0,0 @@
-# -----------------------------------------------------------
-# Copyright (c) 2020, Arm Limited. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
-#
-# -----------------------------------------------------------
-
-#Groups of functions that can be always shared with no exceptions
-mbedtls_asn1
-
-mbedtls_mpi
-
-mbedtls_platform
-
-mbedtls_rsa
-
-#This group is only relevant if BL2 image encryption is on
-mbedtls_md
-
-#This group has two functions that cause runtime errors when shared, so the
-#error-free ones are listed piece by piece
-mbedtls_internal_sha256
-mbedtls_sha256_free
-mbedtls_sha256_init
-mbedtls_sha256_ret
-mbedtls_sha256_starts_ret
-
-#Symbols necessary to make sharing additional functions possible
-mbedtls_calloc
-mbedtls_free
-
-#Miscellaneous functions
-mbedtls_exit
-memset_func
\ No newline at end of file