This is an automated email from the ASF dual-hosted git repository.

yuanz pushed a commit to branch no-std
in repository 
https://gitbox.apache.org/repos/asf/incubator-teaclave-trustzone-sdk.git

commit e843a89c9f378a49dbc0a4e1d03508c32ca35b34
Author: Sumit Garg <[email protected]>
AuthorDate: Wed Dec 27 15:15:19 2023 +0530

    examples: Reuse aarch64/arm host toolchain target for no_std TAs
    
    Along with that drop global .cargo/config and move linker specific
    configuration to TA build.rs file and Makefile. This allows TA directory
    to be self sufficient to build up corresponding TA binary.
    
    Signed-off-by: Sumit Garg <[email protected]>
---
 .cargo/config                                      | 49 ----------------------
 Makefile                                           |  4 +-
 docs/debugging-optee-ta.md                         |  2 +-
 examples/acipher-rs/host/Makefile                  |  4 +-
 examples/acipher-rs/ta/Cargo.toml                  |  1 +
 examples/acipher-rs/ta/Makefile                    | 10 +++--
 examples/acipher-rs/ta/build.rs                    |  5 +++
 examples/aes-rs/host/Makefile                      |  4 +-
 examples/aes-rs/ta/Cargo.toml                      |  1 +
 examples/aes-rs/ta/Makefile                        | 10 +++--
 examples/aes-rs/ta/build.rs                        |  5 +++
 examples/authentication-rs/host/Makefile           |  4 +-
 examples/authentication-rs/ta/Cargo.toml           |  1 +
 examples/authentication-rs/ta/Makefile             | 10 +++--
 examples/authentication-rs/ta/build.rs             |  5 +++
 examples/big_int-rs/host/Makefile                  |  4 +-
 examples/big_int-rs/ta/Cargo.toml                  |  1 +
 examples/big_int-rs/ta/Makefile                    | 10 +++--
 examples/big_int-rs/ta/build.rs                    |  5 +++
 examples/diffie_hellman-rs/host/Makefile           |  4 +-
 examples/diffie_hellman-rs/ta/Cargo.toml           |  1 +
 examples/diffie_hellman-rs/ta/Makefile             | 10 +++--
 examples/diffie_hellman-rs/ta/build.rs             |  5 +++
 examples/digest-rs/host/Makefile                   |  4 +-
 examples/digest-rs/ta/Cargo.toml                   |  1 +
 examples/digest-rs/ta/Makefile                     | 10 +++--
 examples/digest-rs/ta/build.rs                     |  5 +++
 examples/hello_world-rs/host/Makefile              |  4 +-
 examples/hello_world-rs/ta/Cargo.toml              |  1 +
 examples/hello_world-rs/ta/Makefile                | 10 +++--
 examples/hello_world-rs/ta/build.rs                |  5 +++
 examples/hotp-rs/host/Makefile                     |  4 +-
 examples/hotp-rs/ta/Cargo.toml                     |  1 +
 examples/hotp-rs/ta/Makefile                       | 10 +++--
 examples/hotp-rs/ta/build.rs                       |  5 +++
 .../message_passing_interface-rs/host/Makefile     |  4 +-
 examples/message_passing_interface-rs/ta/Makefile  |  4 +-
 examples/message_passing_interface-rs/ta/build.rs  |  6 +++
 examples/random-rs/host/Makefile                   |  4 +-
 examples/random-rs/ta/Cargo.toml                   |  1 +
 examples/random-rs/ta/Makefile                     | 10 +++--
 examples/random-rs/ta/build.rs                     |  5 +++
 examples/secure_storage-rs/host/Makefile           |  4 +-
 examples/secure_storage-rs/ta/Cargo.toml           |  1 +
 examples/secure_storage-rs/ta/Makefile             | 10 +++--
 examples/secure_storage-rs/ta/build.rs             |  5 +++
 examples/serde-rs/host/Makefile                    |  4 +-
 examples/serde-rs/ta/Makefile                      |  4 +-
 examples/serde-rs/ta/build.rs                      |  6 +++
 examples/signature_verification-rs/host/Makefile   |  4 +-
 examples/signature_verification-rs/ta/Cargo.toml   |  1 +
 examples/signature_verification-rs/ta/Makefile     | 10 +++--
 examples/signature_verification-rs/ta/build.rs     |  5 +++
 examples/supp_plugin-rs/host/Makefile              |  4 +-
 examples/supp_plugin-rs/plugin/Makefile            |  4 +-
 examples/supp_plugin-rs/ta/Cargo.toml              |  1 +
 examples/supp_plugin-rs/ta/Makefile                | 10 +++--
 examples/supp_plugin-rs/ta/build.rs                |  5 +++
 examples/tcp_client-rs/host/Makefile               |  4 +-
 examples/tcp_client-rs/ta/Makefile                 |  4 +-
 examples/tcp_client-rs/ta/build.rs                 |  6 +++
 examples/time-rs/host/Makefile                     |  4 +-
 examples/time-rs/ta/Cargo.toml                     |  1 +
 examples/time-rs/ta/Makefile                       | 10 +++--
 examples/time-rs/ta/build.rs                       |  5 +++
 examples/tls_client-rs/host/Makefile               |  4 +-
 examples/tls_client-rs/ta/Makefile                 |  4 +-
 examples/tls_client-rs/ta/build.rs                 |  6 +++
 examples/tls_server-rs/host/Makefile               |  4 +-
 examples/tls_server-rs/ta/Makefile                 |  4 +-
 examples/tls_server-rs/ta/build.rs                 |  6 +++
 examples/udp_socket-rs/host/Makefile               |  4 +-
 examples/udp_socket-rs/ta/Makefile                 |  4 +-
 examples/udp_socket-rs/ta/build.rs                 |  6 +++
 tests/test_acipher.sh                              |  2 +-
 tests/test_aes.sh                                  |  2 +-
 tests/test_authentication.sh                       |  2 +-
 tests/test_big_int.sh                              |  2 +-
 tests/test_diffie_hellman.sh                       |  2 +-
 tests/test_digest.sh                               |  2 +-
 tests/test_hello_world.sh                          |  2 +-
 tests/test_hotp.sh                                 |  2 +-
 tests/test_random.sh                               |  2 +-
 tests/test_secure_storage.sh                       |  2 +-
 tests/test_signature_verification.sh               |  2 +-
 tests/test_supp_plugin.sh                          |  2 +-
 tests/test_time.sh                                 |  2 +-
 87 files changed, 286 insertions(+), 143 deletions(-)

diff --git a/.cargo/config b/.cargo/config
deleted file mode 100644
index d8f9b85..0000000
--- a/.cargo/config
+++ /dev/null
@@ -1,49 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you 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.
-
-[target.aarch64-unknown-optee-trustzone]
-linker = "aarch64-linux-gnu-ld"
-ar = "aarch64-linux-gnu-gcc-ar"
-rustflags = [
-    "-C", "link-arg=-e__ta_entry",
-    "-C", "link-arg=-nostdlib",
-    "-C", "link-arg=-Tta.lds",
-    "-C", "link-arg=--sort-section=alignment",
-    "-C", "link-arg=-pie",
-    "-C", "link-arg=-Os",
-    "-C", "link-dead-code",
-]
-
-[target.aarch64-unknown-linux-gnu]
-linker = "aarch64-linux-gnu-gcc"
-ar = "aarch64-linux-gnu-gcc-ar"
-
-[target.arm-unknown-optee-trustzone]
-linker = "arm-linux-gnueabihf-ld.bfd"
-ar = "arm-linux-gnueabihf-ar"
-rustflags = [
-    "-C", "link-arg=-e__ta_entry",
-    "-C", "link-arg=-nostdlib",
-    "-C", "link-arg=-Tta.lds",
-    "-C", "link-arg=--sort-section=alignment",
-    "-C", "link-arg=-pie",
-    "-C", "link-dead-code",
-]
-
-[target.arm-unknown-linux-gnueabihf]
-linker = "arm-linux-gnueabihf-gcc"
-ar = "arm-linux-gnueabihf-gcc-ar"
diff --git a/Makefile b/Makefile
index 930d4b9..c92b273 100644
--- a/Makefile
+++ b/Makefile
@@ -30,12 +30,12 @@ ifneq ($(ARCH), arm)
        VENDOR := qemu_v8.mk
        AARCH_CROSS_COMPILE := 
$(OPTEE_PATH)/toolchains/aarch64/bin/aarch64-linux-gnu-
        HOST_TARGET := aarch64-unknown-linux-gnu
-       TA_TARGET := aarch64-unknown-optee-trustzone
+       TA_TARGET := aarch64-unknown-linux-gnu
 else
        VENDOR := qemu.mk
        ARCH_CROSS_COMPILE := 
$(OPTEE_PATH)/toolchains/aarch32/bin/arm-linux-gnueabihf-
        HOST_TARGET := arm-unknown-linux-gnueabihf
-       TA_TARGET := arm-unknown-optee-trustzone
+       TA_TARGET := arm-unknown-linux-gnueabihf
 endif
 
 all: toolchains optee-os optee-client examples
diff --git a/docs/debugging-optee-ta.md b/docs/debugging-optee-ta.md
index 7425428..0f69160 100644
--- a/docs/debugging-optee-ta.md
+++ b/docs/debugging-optee-ta.md
@@ -46,7 +46,7 @@ D/LD:  ldelf:168 ELF (133af0ca-bdab-11eb-9130-43bf7873bf67) 
at 0x40014000
 
 Then, you can load symbols from TA file (in debug build) to the address.
 ```sh
-(gdb) add-symbol-file 
/path/to/examples/hello_world-rs/ta/target/aarch64-unknown-optee-trustzone/debug/ta
 0x40014000
+(gdb) add-symbol-file 
/path/to/examples/hello_world-rs/ta/target/aarch64-unknown-linux-gnu/debug/ta 
0x40014000
 ```
 Now, you can add breakpoints according to your own needs in the corresponding
 functions or addresses.
diff --git a/examples/acipher-rs/host/Makefile 
b/examples/acipher-rs/host/Makefile
index 37bf3d4..d30687d 100644
--- a/examples/acipher-rs/host/Makefile
+++ b/examples/acipher-rs/host/Makefile
@@ -24,10 +24,12 @@ ifeq ($(ARCH), arm)
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin
        OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy
        TARGET := arm-unknown-linux-gnueabihf
+       LINKER_CFG := 
target.arm-unknown-linux-gnueabihf..linker=\"arm-linux-gnueabihf-gcc\"
 else
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin
        OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy
        TARGET := aarch64-unknown-linux-gnu
+       LINKER_CFG := 
target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-gcc\"
 endif
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
@@ -36,7 +38,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 all: host strip
 
 host:
-       @cargo build --target $(TARGET) --release
+       @cargo build --target $(TARGET) --release --config $(LINKER_CFG)
 
 strip:
        @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/$(NAME) $(OUT_DIR)/$(NAME)
diff --git a/examples/acipher-rs/ta/Cargo.toml 
b/examples/acipher-rs/ta/Cargo.toml
index a1f89c2..7e7cae7 100644
--- a/examples/acipher-rs/ta/Cargo.toml
+++ b/examples/acipher-rs/ta/Cargo.toml
@@ -34,5 +34,6 @@ uuid = { version = "1.6.1", default-features = false }
 proto = { path = "../proto" }
 
 [profile.release]
+panic = "abort"
 lto = true
 opt-level = 1
diff --git a/examples/acipher-rs/ta/Makefile b/examples/acipher-rs/ta/Makefile
index ffee4b2..8a2faf4 100644
--- a/examples/acipher-rs/ta/Makefile
+++ b/examples/acipher-rs/ta/Makefile
@@ -26,13 +26,15 @@ ifeq ($(ARCH), arm)
        SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm32/scripts/sign_encrypt.py
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin
        OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy
-       TARGET := arm-unknown-optee-trustzone
+       TARGET := arm-unknown-linux-gnueabihf
+       LINKER_CFG := 
target.arm-unknown-linux-gnueabihf.linker=\"arm-linux-gnueabihf-ld.bfd\"
 else
        TA_SIGN_KEY ?= 
$(OPTEE_OS_DIR)/out/arm/export-ta_arm64/keys/default_ta.pem
        SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/scripts/sign_encrypt.py
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin
        OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy
-       TARGET := aarch64-unknown-optee-trustzone
+       TARGET := aarch64-unknown-linux-gnu
+       LINKER_CFG := 
target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-ld.bfd\"
 endif
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
@@ -40,7 +42,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 all: ta strip sign
 
 ta:
-       @xargo build --target $(TARGET) --release --verbose
+       @cargo build --target $(TARGET) --release --verbose --config 
$(LINKER_CFG)
 
 strip:
        @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta
@@ -50,4 +52,4 @@ sign:
        @echo "SIGN =>  ${UUID}"
 
 clean:
-       @xargo clean
+       @cargo clean
diff --git a/examples/acipher-rs/ta/build.rs b/examples/acipher-rs/ta/build.rs
index 1199035..fb1e5dc 100644
--- a/examples/acipher-rs/ta/build.rs
+++ b/examples/acipher-rs/ta/build.rs
@@ -59,5 +59,10 @@ fn main() -> std::io::Result<()> {
     println!("cargo:rustc-link-search={}", search_path.display());
     println!("cargo:rustc-link-lib=static=utee");
     println!("cargo:rustc-link-lib=static=utils");
+    println!("cargo:rustc-link-arg=-Tta.lds");
+    println!("cargo:rustc-link-arg=-e__ta_entry");
+    println!("cargo:rustc-link-arg=-pie");
+    println!("cargo:rustc-link-arg=-Os");
+    println!("cargo:rustc-link-arg=--sort-section=alignment");
     Ok(())
 }
diff --git a/examples/aes-rs/host/Makefile b/examples/aes-rs/host/Makefile
index 7f436aa..9672825 100644
--- a/examples/aes-rs/host/Makefile
+++ b/examples/aes-rs/host/Makefile
@@ -24,10 +24,12 @@ ifeq ($(ARCH), arm)
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin
        OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy
        TARGET := arm-unknown-linux-gnueabihf
+       LINKER_CFG := 
target.arm-unknown-linux-gnueabihf..linker=\"arm-linux-gnueabihf-gcc\"
 else
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin
        OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy
        TARGET := aarch64-unknown-linux-gnu
+       LINKER_CFG := 
target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-gcc\"
 endif
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
@@ -36,7 +38,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 all: host strip
 
 host:
-       @cargo build --target $(TARGET) --release
+       @cargo build --target $(TARGET) --release --config $(LINKER_CFG)
 
 strip:
        @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/$(NAME) $(OUT_DIR)/$(NAME)
diff --git a/examples/aes-rs/ta/Cargo.toml b/examples/aes-rs/ta/Cargo.toml
index a1f89c2..7e7cae7 100644
--- a/examples/aes-rs/ta/Cargo.toml
+++ b/examples/aes-rs/ta/Cargo.toml
@@ -34,5 +34,6 @@ uuid = { version = "1.6.1", default-features = false }
 proto = { path = "../proto" }
 
 [profile.release]
+panic = "abort"
 lto = true
 opt-level = 1
diff --git a/examples/aes-rs/ta/Makefile b/examples/aes-rs/ta/Makefile
index ffee4b2..8a2faf4 100644
--- a/examples/aes-rs/ta/Makefile
+++ b/examples/aes-rs/ta/Makefile
@@ -26,13 +26,15 @@ ifeq ($(ARCH), arm)
        SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm32/scripts/sign_encrypt.py
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin
        OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy
-       TARGET := arm-unknown-optee-trustzone
+       TARGET := arm-unknown-linux-gnueabihf
+       LINKER_CFG := 
target.arm-unknown-linux-gnueabihf.linker=\"arm-linux-gnueabihf-ld.bfd\"
 else
        TA_SIGN_KEY ?= 
$(OPTEE_OS_DIR)/out/arm/export-ta_arm64/keys/default_ta.pem
        SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/scripts/sign_encrypt.py
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin
        OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy
-       TARGET := aarch64-unknown-optee-trustzone
+       TARGET := aarch64-unknown-linux-gnu
+       LINKER_CFG := 
target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-ld.bfd\"
 endif
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
@@ -40,7 +42,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 all: ta strip sign
 
 ta:
-       @xargo build --target $(TARGET) --release --verbose
+       @cargo build --target $(TARGET) --release --verbose --config 
$(LINKER_CFG)
 
 strip:
        @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta
@@ -50,4 +52,4 @@ sign:
        @echo "SIGN =>  ${UUID}"
 
 clean:
-       @xargo clean
+       @cargo clean
diff --git a/examples/aes-rs/ta/build.rs b/examples/aes-rs/ta/build.rs
index 1199035..fb1e5dc 100644
--- a/examples/aes-rs/ta/build.rs
+++ b/examples/aes-rs/ta/build.rs
@@ -59,5 +59,10 @@ fn main() -> std::io::Result<()> {
     println!("cargo:rustc-link-search={}", search_path.display());
     println!("cargo:rustc-link-lib=static=utee");
     println!("cargo:rustc-link-lib=static=utils");
+    println!("cargo:rustc-link-arg=-Tta.lds");
+    println!("cargo:rustc-link-arg=-e__ta_entry");
+    println!("cargo:rustc-link-arg=-pie");
+    println!("cargo:rustc-link-arg=-Os");
+    println!("cargo:rustc-link-arg=--sort-section=alignment");
     Ok(())
 }
diff --git a/examples/authentication-rs/host/Makefile 
b/examples/authentication-rs/host/Makefile
index f74911e..9c05bd0 100644
--- a/examples/authentication-rs/host/Makefile
+++ b/examples/authentication-rs/host/Makefile
@@ -24,10 +24,12 @@ ifeq ($(ARCH), arm)
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin
        OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy
        TARGET := arm-unknown-linux-gnueabihf
+       LINKER_CFG := 
target.arm-unknown-linux-gnueabihf..linker=\"arm-linux-gnueabihf-gcc\"
 else
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin
        OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy
        TARGET := aarch64-unknown-linux-gnu
+       LINKER_CFG := 
target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-gcc\"
 endif
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
@@ -36,7 +38,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 all: host strip
 
 host:
-       @cargo build --target $(TARGET) --release
+       @cargo build --target $(TARGET) --release --config $(LINKER_CFG)
 
 strip:
        @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/$(NAME) $(OUT_DIR)/$(NAME)
diff --git a/examples/authentication-rs/ta/Cargo.toml 
b/examples/authentication-rs/ta/Cargo.toml
index a1f89c2..7e7cae7 100644
--- a/examples/authentication-rs/ta/Cargo.toml
+++ b/examples/authentication-rs/ta/Cargo.toml
@@ -34,5 +34,6 @@ uuid = { version = "1.6.1", default-features = false }
 proto = { path = "../proto" }
 
 [profile.release]
+panic = "abort"
 lto = true
 opt-level = 1
diff --git a/examples/authentication-rs/ta/Makefile 
b/examples/authentication-rs/ta/Makefile
index ffee4b2..8a2faf4 100644
--- a/examples/authentication-rs/ta/Makefile
+++ b/examples/authentication-rs/ta/Makefile
@@ -26,13 +26,15 @@ ifeq ($(ARCH), arm)
        SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm32/scripts/sign_encrypt.py
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin
        OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy
-       TARGET := arm-unknown-optee-trustzone
+       TARGET := arm-unknown-linux-gnueabihf
+       LINKER_CFG := 
target.arm-unknown-linux-gnueabihf.linker=\"arm-linux-gnueabihf-ld.bfd\"
 else
        TA_SIGN_KEY ?= 
$(OPTEE_OS_DIR)/out/arm/export-ta_arm64/keys/default_ta.pem
        SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/scripts/sign_encrypt.py
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin
        OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy
-       TARGET := aarch64-unknown-optee-trustzone
+       TARGET := aarch64-unknown-linux-gnu
+       LINKER_CFG := 
target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-ld.bfd\"
 endif
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
@@ -40,7 +42,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 all: ta strip sign
 
 ta:
-       @xargo build --target $(TARGET) --release --verbose
+       @cargo build --target $(TARGET) --release --verbose --config 
$(LINKER_CFG)
 
 strip:
        @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta
@@ -50,4 +52,4 @@ sign:
        @echo "SIGN =>  ${UUID}"
 
 clean:
-       @xargo clean
+       @cargo clean
diff --git a/examples/authentication-rs/ta/build.rs 
b/examples/authentication-rs/ta/build.rs
index 1199035..fb1e5dc 100644
--- a/examples/authentication-rs/ta/build.rs
+++ b/examples/authentication-rs/ta/build.rs
@@ -59,5 +59,10 @@ fn main() -> std::io::Result<()> {
     println!("cargo:rustc-link-search={}", search_path.display());
     println!("cargo:rustc-link-lib=static=utee");
     println!("cargo:rustc-link-lib=static=utils");
+    println!("cargo:rustc-link-arg=-Tta.lds");
+    println!("cargo:rustc-link-arg=-e__ta_entry");
+    println!("cargo:rustc-link-arg=-pie");
+    println!("cargo:rustc-link-arg=-Os");
+    println!("cargo:rustc-link-arg=--sort-section=alignment");
     Ok(())
 }
diff --git a/examples/big_int-rs/host/Makefile 
b/examples/big_int-rs/host/Makefile
index 9f618d1..db37c49 100644
--- a/examples/big_int-rs/host/Makefile
+++ b/examples/big_int-rs/host/Makefile
@@ -24,10 +24,12 @@ ifeq ($(ARCH), arm)
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin
        OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy
        TARGET := arm-unknown-linux-gnueabihf
+       LINKER_CFG := 
target.arm-unknown-linux-gnueabihf..linker=\"arm-linux-gnueabihf-gcc\"
 else
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin
        OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy
        TARGET := aarch64-unknown-linux-gnu
+       LINKER_CFG := 
target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-gcc\"
 endif
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
@@ -36,7 +38,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 all: host strip
 
 host:
-       @cargo build --target $(TARGET) --release
+       @cargo build --target $(TARGET) --release --config $(LINKER_CFG)
 
 strip:
        @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/$(NAME) $(OUT_DIR)/$(NAME)
diff --git a/examples/big_int-rs/ta/Cargo.toml 
b/examples/big_int-rs/ta/Cargo.toml
index a1f89c2..7e7cae7 100644
--- a/examples/big_int-rs/ta/Cargo.toml
+++ b/examples/big_int-rs/ta/Cargo.toml
@@ -34,5 +34,6 @@ uuid = { version = "1.6.1", default-features = false }
 proto = { path = "../proto" }
 
 [profile.release]
+panic = "abort"
 lto = true
 opt-level = 1
diff --git a/examples/big_int-rs/ta/Makefile b/examples/big_int-rs/ta/Makefile
index ffee4b2..8a2faf4 100644
--- a/examples/big_int-rs/ta/Makefile
+++ b/examples/big_int-rs/ta/Makefile
@@ -26,13 +26,15 @@ ifeq ($(ARCH), arm)
        SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm32/scripts/sign_encrypt.py
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin
        OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy
-       TARGET := arm-unknown-optee-trustzone
+       TARGET := arm-unknown-linux-gnueabihf
+       LINKER_CFG := 
target.arm-unknown-linux-gnueabihf.linker=\"arm-linux-gnueabihf-ld.bfd\"
 else
        TA_SIGN_KEY ?= 
$(OPTEE_OS_DIR)/out/arm/export-ta_arm64/keys/default_ta.pem
        SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/scripts/sign_encrypt.py
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin
        OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy
-       TARGET := aarch64-unknown-optee-trustzone
+       TARGET := aarch64-unknown-linux-gnu
+       LINKER_CFG := 
target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-ld.bfd\"
 endif
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
@@ -40,7 +42,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 all: ta strip sign
 
 ta:
-       @xargo build --target $(TARGET) --release --verbose
+       @cargo build --target $(TARGET) --release --verbose --config 
$(LINKER_CFG)
 
 strip:
        @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta
@@ -50,4 +52,4 @@ sign:
        @echo "SIGN =>  ${UUID}"
 
 clean:
-       @xargo clean
+       @cargo clean
diff --git a/examples/big_int-rs/ta/build.rs b/examples/big_int-rs/ta/build.rs
index 1199035..fb1e5dc 100644
--- a/examples/big_int-rs/ta/build.rs
+++ b/examples/big_int-rs/ta/build.rs
@@ -59,5 +59,10 @@ fn main() -> std::io::Result<()> {
     println!("cargo:rustc-link-search={}", search_path.display());
     println!("cargo:rustc-link-lib=static=utee");
     println!("cargo:rustc-link-lib=static=utils");
+    println!("cargo:rustc-link-arg=-Tta.lds");
+    println!("cargo:rustc-link-arg=-e__ta_entry");
+    println!("cargo:rustc-link-arg=-pie");
+    println!("cargo:rustc-link-arg=-Os");
+    println!("cargo:rustc-link-arg=--sort-section=alignment");
     Ok(())
 }
diff --git a/examples/diffie_hellman-rs/host/Makefile 
b/examples/diffie_hellman-rs/host/Makefile
index 4253125..dcce1a5 100644
--- a/examples/diffie_hellman-rs/host/Makefile
+++ b/examples/diffie_hellman-rs/host/Makefile
@@ -24,10 +24,12 @@ ifeq ($(ARCH), arm)
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin
        OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy
        TARGET := arm-unknown-linux-gnueabihf
+       LINKER_CFG := 
target.arm-unknown-linux-gnueabihf..linker=\"arm-linux-gnueabihf-gcc\"
 else
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin
        OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy
        TARGET := aarch64-unknown-linux-gnu
+       LINKER_CFG := 
target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-gcc\"
 endif
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
@@ -36,7 +38,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 all: host strip
 
 host:
-       @cargo build --target $(TARGET) --release
+       @cargo build --target $(TARGET) --release --config $(LINKER_CFG)
 
 strip:
        @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/$(NAME) $(OUT_DIR)/$(NAME)
diff --git a/examples/diffie_hellman-rs/ta/Cargo.toml 
b/examples/diffie_hellman-rs/ta/Cargo.toml
index a1f89c2..7e7cae7 100644
--- a/examples/diffie_hellman-rs/ta/Cargo.toml
+++ b/examples/diffie_hellman-rs/ta/Cargo.toml
@@ -34,5 +34,6 @@ uuid = { version = "1.6.1", default-features = false }
 proto = { path = "../proto" }
 
 [profile.release]
+panic = "abort"
 lto = true
 opt-level = 1
diff --git a/examples/diffie_hellman-rs/ta/Makefile 
b/examples/diffie_hellman-rs/ta/Makefile
index ffee4b2..8a2faf4 100644
--- a/examples/diffie_hellman-rs/ta/Makefile
+++ b/examples/diffie_hellman-rs/ta/Makefile
@@ -26,13 +26,15 @@ ifeq ($(ARCH), arm)
        SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm32/scripts/sign_encrypt.py
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin
        OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy
-       TARGET := arm-unknown-optee-trustzone
+       TARGET := arm-unknown-linux-gnueabihf
+       LINKER_CFG := 
target.arm-unknown-linux-gnueabihf.linker=\"arm-linux-gnueabihf-ld.bfd\"
 else
        TA_SIGN_KEY ?= 
$(OPTEE_OS_DIR)/out/arm/export-ta_arm64/keys/default_ta.pem
        SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/scripts/sign_encrypt.py
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin
        OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy
-       TARGET := aarch64-unknown-optee-trustzone
+       TARGET := aarch64-unknown-linux-gnu
+       LINKER_CFG := 
target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-ld.bfd\"
 endif
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
@@ -40,7 +42,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 all: ta strip sign
 
 ta:
-       @xargo build --target $(TARGET) --release --verbose
+       @cargo build --target $(TARGET) --release --verbose --config 
$(LINKER_CFG)
 
 strip:
        @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta
@@ -50,4 +52,4 @@ sign:
        @echo "SIGN =>  ${UUID}"
 
 clean:
-       @xargo clean
+       @cargo clean
diff --git a/examples/diffie_hellman-rs/ta/build.rs 
b/examples/diffie_hellman-rs/ta/build.rs
index 1199035..fb1e5dc 100644
--- a/examples/diffie_hellman-rs/ta/build.rs
+++ b/examples/diffie_hellman-rs/ta/build.rs
@@ -59,5 +59,10 @@ fn main() -> std::io::Result<()> {
     println!("cargo:rustc-link-search={}", search_path.display());
     println!("cargo:rustc-link-lib=static=utee");
     println!("cargo:rustc-link-lib=static=utils");
+    println!("cargo:rustc-link-arg=-Tta.lds");
+    println!("cargo:rustc-link-arg=-e__ta_entry");
+    println!("cargo:rustc-link-arg=-pie");
+    println!("cargo:rustc-link-arg=-Os");
+    println!("cargo:rustc-link-arg=--sort-section=alignment");
     Ok(())
 }
diff --git a/examples/digest-rs/host/Makefile b/examples/digest-rs/host/Makefile
index 617b85b..ac7c5bc 100644
--- a/examples/digest-rs/host/Makefile
+++ b/examples/digest-rs/host/Makefile
@@ -24,10 +24,12 @@ ifeq ($(ARCH), arm)
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin
        OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy
        TARGET := arm-unknown-linux-gnueabihf
+       LINKER_CFG := 
target.arm-unknown-linux-gnueabihf..linker=\"arm-linux-gnueabihf-gcc\"
 else
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin
        OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy
        TARGET := aarch64-unknown-linux-gnu
+       LINKER_CFG := 
target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-gcc\"
 endif
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
@@ -36,7 +38,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 all: host strip
 
 host:
-       @cargo build --target $(TARGET) --release
+       @cargo build --target $(TARGET) --release --config $(LINKER_CFG)
 
 strip:
        @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/$(NAME) $(OUT_DIR)/$(NAME)
diff --git a/examples/digest-rs/ta/Cargo.toml b/examples/digest-rs/ta/Cargo.toml
index a1f89c2..7e7cae7 100644
--- a/examples/digest-rs/ta/Cargo.toml
+++ b/examples/digest-rs/ta/Cargo.toml
@@ -34,5 +34,6 @@ uuid = { version = "1.6.1", default-features = false }
 proto = { path = "../proto" }
 
 [profile.release]
+panic = "abort"
 lto = true
 opt-level = 1
diff --git a/examples/digest-rs/ta/Makefile b/examples/digest-rs/ta/Makefile
index ffee4b2..8a2faf4 100644
--- a/examples/digest-rs/ta/Makefile
+++ b/examples/digest-rs/ta/Makefile
@@ -26,13 +26,15 @@ ifeq ($(ARCH), arm)
        SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm32/scripts/sign_encrypt.py
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin
        OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy
-       TARGET := arm-unknown-optee-trustzone
+       TARGET := arm-unknown-linux-gnueabihf
+       LINKER_CFG := 
target.arm-unknown-linux-gnueabihf.linker=\"arm-linux-gnueabihf-ld.bfd\"
 else
        TA_SIGN_KEY ?= 
$(OPTEE_OS_DIR)/out/arm/export-ta_arm64/keys/default_ta.pem
        SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/scripts/sign_encrypt.py
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin
        OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy
-       TARGET := aarch64-unknown-optee-trustzone
+       TARGET := aarch64-unknown-linux-gnu
+       LINKER_CFG := 
target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-ld.bfd\"
 endif
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
@@ -40,7 +42,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 all: ta strip sign
 
 ta:
-       @xargo build --target $(TARGET) --release --verbose
+       @cargo build --target $(TARGET) --release --verbose --config 
$(LINKER_CFG)
 
 strip:
        @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta
@@ -50,4 +52,4 @@ sign:
        @echo "SIGN =>  ${UUID}"
 
 clean:
-       @xargo clean
+       @cargo clean
diff --git a/examples/digest-rs/ta/build.rs b/examples/digest-rs/ta/build.rs
index 1199035..fb1e5dc 100644
--- a/examples/digest-rs/ta/build.rs
+++ b/examples/digest-rs/ta/build.rs
@@ -59,5 +59,10 @@ fn main() -> std::io::Result<()> {
     println!("cargo:rustc-link-search={}", search_path.display());
     println!("cargo:rustc-link-lib=static=utee");
     println!("cargo:rustc-link-lib=static=utils");
+    println!("cargo:rustc-link-arg=-Tta.lds");
+    println!("cargo:rustc-link-arg=-e__ta_entry");
+    println!("cargo:rustc-link-arg=-pie");
+    println!("cargo:rustc-link-arg=-Os");
+    println!("cargo:rustc-link-arg=--sort-section=alignment");
     Ok(())
 }
diff --git a/examples/hello_world-rs/host/Makefile 
b/examples/hello_world-rs/host/Makefile
index bf46340..7512ada 100644
--- a/examples/hello_world-rs/host/Makefile
+++ b/examples/hello_world-rs/host/Makefile
@@ -24,10 +24,12 @@ ifeq ($(ARCH), arm)
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin
        OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy
        TARGET := arm-unknown-linux-gnueabihf
+       LINKER_CFG := 
target.arm-unknown-linux-gnueabihf..linker=\"arm-linux-gnueabihf-gcc\"
 else
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin
        OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy
        TARGET := aarch64-unknown-linux-gnu
+       LINKER_CFG := 
target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-gcc\"
 endif
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
@@ -36,7 +38,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 all: host strip
 
 host:
-       @cargo build --target $(TARGET) --release
+       @cargo build --target $(TARGET) --release --config $(LINKER_CFG)
 
 strip:
        @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/$(NAME) $(OUT_DIR)/$(NAME)
diff --git a/examples/hello_world-rs/ta/Cargo.toml 
b/examples/hello_world-rs/ta/Cargo.toml
index a1f89c2..7e7cae7 100644
--- a/examples/hello_world-rs/ta/Cargo.toml
+++ b/examples/hello_world-rs/ta/Cargo.toml
@@ -34,5 +34,6 @@ uuid = { version = "1.6.1", default-features = false }
 proto = { path = "../proto" }
 
 [profile.release]
+panic = "abort"
 lto = true
 opt-level = 1
diff --git a/examples/hello_world-rs/ta/Makefile 
b/examples/hello_world-rs/ta/Makefile
index ffee4b2..8a2faf4 100644
--- a/examples/hello_world-rs/ta/Makefile
+++ b/examples/hello_world-rs/ta/Makefile
@@ -26,13 +26,15 @@ ifeq ($(ARCH), arm)
        SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm32/scripts/sign_encrypt.py
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin
        OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy
-       TARGET := arm-unknown-optee-trustzone
+       TARGET := arm-unknown-linux-gnueabihf
+       LINKER_CFG := 
target.arm-unknown-linux-gnueabihf.linker=\"arm-linux-gnueabihf-ld.bfd\"
 else
        TA_SIGN_KEY ?= 
$(OPTEE_OS_DIR)/out/arm/export-ta_arm64/keys/default_ta.pem
        SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/scripts/sign_encrypt.py
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin
        OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy
-       TARGET := aarch64-unknown-optee-trustzone
+       TARGET := aarch64-unknown-linux-gnu
+       LINKER_CFG := 
target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-ld.bfd\"
 endif
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
@@ -40,7 +42,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 all: ta strip sign
 
 ta:
-       @xargo build --target $(TARGET) --release --verbose
+       @cargo build --target $(TARGET) --release --verbose --config 
$(LINKER_CFG)
 
 strip:
        @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta
@@ -50,4 +52,4 @@ sign:
        @echo "SIGN =>  ${UUID}"
 
 clean:
-       @xargo clean
+       @cargo clean
diff --git a/examples/hello_world-rs/ta/build.rs 
b/examples/hello_world-rs/ta/build.rs
index 1199035..fb1e5dc 100644
--- a/examples/hello_world-rs/ta/build.rs
+++ b/examples/hello_world-rs/ta/build.rs
@@ -59,5 +59,10 @@ fn main() -> std::io::Result<()> {
     println!("cargo:rustc-link-search={}", search_path.display());
     println!("cargo:rustc-link-lib=static=utee");
     println!("cargo:rustc-link-lib=static=utils");
+    println!("cargo:rustc-link-arg=-Tta.lds");
+    println!("cargo:rustc-link-arg=-e__ta_entry");
+    println!("cargo:rustc-link-arg=-pie");
+    println!("cargo:rustc-link-arg=-Os");
+    println!("cargo:rustc-link-arg=--sort-section=alignment");
     Ok(())
 }
diff --git a/examples/hotp-rs/host/Makefile b/examples/hotp-rs/host/Makefile
index fdde1c7..d6aac49 100644
--- a/examples/hotp-rs/host/Makefile
+++ b/examples/hotp-rs/host/Makefile
@@ -24,10 +24,12 @@ ifeq ($(ARCH), arm)
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin
        OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy
        TARGET := arm-unknown-linux-gnueabihf
+       LINKER_CFG := 
target.arm-unknown-linux-gnueabihf..linker=\"arm-linux-gnueabihf-gcc\"
 else
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin
        OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy
        TARGET := aarch64-unknown-linux-gnu
+       LINKER_CFG := 
target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-gcc\"
 endif
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
@@ -36,7 +38,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 all: host strip
 
 host:
-       @cargo build --target $(TARGET) --release
+       @cargo build --target $(TARGET) --release --config $(LINKER_CFG)
 
 strip:
        @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/$(NAME) $(OUT_DIR)/$(NAME)
diff --git a/examples/hotp-rs/ta/Cargo.toml b/examples/hotp-rs/ta/Cargo.toml
index a1f89c2..7e7cae7 100644
--- a/examples/hotp-rs/ta/Cargo.toml
+++ b/examples/hotp-rs/ta/Cargo.toml
@@ -34,5 +34,6 @@ uuid = { version = "1.6.1", default-features = false }
 proto = { path = "../proto" }
 
 [profile.release]
+panic = "abort"
 lto = true
 opt-level = 1
diff --git a/examples/hotp-rs/ta/Makefile b/examples/hotp-rs/ta/Makefile
index ffee4b2..8a2faf4 100644
--- a/examples/hotp-rs/ta/Makefile
+++ b/examples/hotp-rs/ta/Makefile
@@ -26,13 +26,15 @@ ifeq ($(ARCH), arm)
        SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm32/scripts/sign_encrypt.py
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin
        OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy
-       TARGET := arm-unknown-optee-trustzone
+       TARGET := arm-unknown-linux-gnueabihf
+       LINKER_CFG := 
target.arm-unknown-linux-gnueabihf.linker=\"arm-linux-gnueabihf-ld.bfd\"
 else
        TA_SIGN_KEY ?= 
$(OPTEE_OS_DIR)/out/arm/export-ta_arm64/keys/default_ta.pem
        SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/scripts/sign_encrypt.py
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin
        OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy
-       TARGET := aarch64-unknown-optee-trustzone
+       TARGET := aarch64-unknown-linux-gnu
+       LINKER_CFG := 
target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-ld.bfd\"
 endif
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
@@ -40,7 +42,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 all: ta strip sign
 
 ta:
-       @xargo build --target $(TARGET) --release --verbose
+       @cargo build --target $(TARGET) --release --verbose --config 
$(LINKER_CFG)
 
 strip:
        @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta
@@ -50,4 +52,4 @@ sign:
        @echo "SIGN =>  ${UUID}"
 
 clean:
-       @xargo clean
+       @cargo clean
diff --git a/examples/hotp-rs/ta/build.rs b/examples/hotp-rs/ta/build.rs
index 1199035..fb1e5dc 100644
--- a/examples/hotp-rs/ta/build.rs
+++ b/examples/hotp-rs/ta/build.rs
@@ -59,5 +59,10 @@ fn main() -> std::io::Result<()> {
     println!("cargo:rustc-link-search={}", search_path.display());
     println!("cargo:rustc-link-lib=static=utee");
     println!("cargo:rustc-link-lib=static=utils");
+    println!("cargo:rustc-link-arg=-Tta.lds");
+    println!("cargo:rustc-link-arg=-e__ta_entry");
+    println!("cargo:rustc-link-arg=-pie");
+    println!("cargo:rustc-link-arg=-Os");
+    println!("cargo:rustc-link-arg=--sort-section=alignment");
     Ok(())
 }
diff --git a/examples/message_passing_interface-rs/host/Makefile 
b/examples/message_passing_interface-rs/host/Makefile
index 61ef2b6..a928586 100644
--- a/examples/message_passing_interface-rs/host/Makefile
+++ b/examples/message_passing_interface-rs/host/Makefile
@@ -24,10 +24,12 @@ ifeq ($(ARCH), arm)
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin
        OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy
        TARGET := arm-unknown-linux-gnueabihf
+       LINKER_CFG := 
target.arm-unknown-linux-gnueabihf..linker=\"arm-linux-gnueabihf-gcc\"
 else
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin
        OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy
        TARGET := aarch64-unknown-linux-gnu
+       LINKER_CFG := 
target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-gcc\"
 endif
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
@@ -36,7 +38,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 all: host strip
 
 host:
-       @cargo build --target $(TARGET) --release
+       @cargo build --target $(TARGET) --release --config $(LINKER_CFG)
 
 strip:
        @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/$(NAME) $(OUT_DIR)/$(NAME)
diff --git a/examples/message_passing_interface-rs/ta/Makefile 
b/examples/message_passing_interface-rs/ta/Makefile
index ffee4b2..9496d57 100644
--- a/examples/message_passing_interface-rs/ta/Makefile
+++ b/examples/message_passing_interface-rs/ta/Makefile
@@ -27,12 +27,14 @@ ifeq ($(ARCH), arm)
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin
        OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy
        TARGET := arm-unknown-optee-trustzone
+       LINKER_CFG := 
target.arm-unknown-optee-trustzone..linker=\"arm-linux-gnueabihf-ld.bfd\"
 else
        TA_SIGN_KEY ?= 
$(OPTEE_OS_DIR)/out/arm/export-ta_arm64/keys/default_ta.pem
        SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/scripts/sign_encrypt.py
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin
        OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy
        TARGET := aarch64-unknown-optee-trustzone
+       LINKER_CFG := 
target.aarch64-unknown-optee-trustzone.linker=\"aarch64-linux-gnu-ld.bfd\"
 endif
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
@@ -40,7 +42,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 all: ta strip sign
 
 ta:
-       @xargo build --target $(TARGET) --release --verbose
+       @xargo build --target $(TARGET) --release --verbose --config 
$(LINKER_CFG)
 
 strip:
        @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta
diff --git a/examples/message_passing_interface-rs/ta/build.rs 
b/examples/message_passing_interface-rs/ta/build.rs
index 33f6cc0..fb1e5dc 100644
--- a/examples/message_passing_interface-rs/ta/build.rs
+++ b/examples/message_passing_interface-rs/ta/build.rs
@@ -58,5 +58,11 @@ fn main() -> std::io::Result<()> {
 
     println!("cargo:rustc-link-search={}", search_path.display());
     println!("cargo:rustc-link-lib=static=utee");
+    println!("cargo:rustc-link-lib=static=utils");
+    println!("cargo:rustc-link-arg=-Tta.lds");
+    println!("cargo:rustc-link-arg=-e__ta_entry");
+    println!("cargo:rustc-link-arg=-pie");
+    println!("cargo:rustc-link-arg=-Os");
+    println!("cargo:rustc-link-arg=--sort-section=alignment");
     Ok(())
 }
diff --git a/examples/random-rs/host/Makefile b/examples/random-rs/host/Makefile
index 663ed11..f6984c9 100644
--- a/examples/random-rs/host/Makefile
+++ b/examples/random-rs/host/Makefile
@@ -24,10 +24,12 @@ ifeq ($(ARCH), arm)
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin
        OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy
        TARGET := arm-unknown-linux-gnueabihf
+       LINKER_CFG := 
target.arm-unknown-linux-gnueabihf..linker=\"arm-linux-gnueabihf-gcc\"
 else
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin
        OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy
        TARGET := aarch64-unknown-linux-gnu
+       LINKER_CFG := 
target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-gcc\"
 endif
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
@@ -36,7 +38,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 all: host strip
 
 host:
-       @cargo build --target $(TARGET) --release
+       @cargo build --target $(TARGET) --release --config $(LINKER_CFG)
 
 strip:
        @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/$(NAME) $(OUT_DIR)/$(NAME)
diff --git a/examples/random-rs/ta/Cargo.toml b/examples/random-rs/ta/Cargo.toml
index a1f89c2..7e7cae7 100644
--- a/examples/random-rs/ta/Cargo.toml
+++ b/examples/random-rs/ta/Cargo.toml
@@ -34,5 +34,6 @@ uuid = { version = "1.6.1", default-features = false }
 proto = { path = "../proto" }
 
 [profile.release]
+panic = "abort"
 lto = true
 opt-level = 1
diff --git a/examples/random-rs/ta/Makefile b/examples/random-rs/ta/Makefile
index ffee4b2..8a2faf4 100644
--- a/examples/random-rs/ta/Makefile
+++ b/examples/random-rs/ta/Makefile
@@ -26,13 +26,15 @@ ifeq ($(ARCH), arm)
        SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm32/scripts/sign_encrypt.py
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin
        OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy
-       TARGET := arm-unknown-optee-trustzone
+       TARGET := arm-unknown-linux-gnueabihf
+       LINKER_CFG := 
target.arm-unknown-linux-gnueabihf.linker=\"arm-linux-gnueabihf-ld.bfd\"
 else
        TA_SIGN_KEY ?= 
$(OPTEE_OS_DIR)/out/arm/export-ta_arm64/keys/default_ta.pem
        SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/scripts/sign_encrypt.py
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin
        OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy
-       TARGET := aarch64-unknown-optee-trustzone
+       TARGET := aarch64-unknown-linux-gnu
+       LINKER_CFG := 
target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-ld.bfd\"
 endif
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
@@ -40,7 +42,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 all: ta strip sign
 
 ta:
-       @xargo build --target $(TARGET) --release --verbose
+       @cargo build --target $(TARGET) --release --verbose --config 
$(LINKER_CFG)
 
 strip:
        @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta
@@ -50,4 +52,4 @@ sign:
        @echo "SIGN =>  ${UUID}"
 
 clean:
-       @xargo clean
+       @cargo clean
diff --git a/examples/random-rs/ta/build.rs b/examples/random-rs/ta/build.rs
index 1199035..fb1e5dc 100644
--- a/examples/random-rs/ta/build.rs
+++ b/examples/random-rs/ta/build.rs
@@ -59,5 +59,10 @@ fn main() -> std::io::Result<()> {
     println!("cargo:rustc-link-search={}", search_path.display());
     println!("cargo:rustc-link-lib=static=utee");
     println!("cargo:rustc-link-lib=static=utils");
+    println!("cargo:rustc-link-arg=-Tta.lds");
+    println!("cargo:rustc-link-arg=-e__ta_entry");
+    println!("cargo:rustc-link-arg=-pie");
+    println!("cargo:rustc-link-arg=-Os");
+    println!("cargo:rustc-link-arg=--sort-section=alignment");
     Ok(())
 }
diff --git a/examples/secure_storage-rs/host/Makefile 
b/examples/secure_storage-rs/host/Makefile
index 7dbed02..602b98d 100644
--- a/examples/secure_storage-rs/host/Makefile
+++ b/examples/secure_storage-rs/host/Makefile
@@ -24,10 +24,12 @@ ifeq ($(ARCH), arm)
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin
        OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy
        TARGET := arm-unknown-linux-gnueabihf
+       LINKER_CFG := 
target.arm-unknown-linux-gnueabihf..linker=\"arm-linux-gnueabihf-gcc\"
 else
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin
        OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy
        TARGET := aarch64-unknown-linux-gnu
+       LINKER_CFG := 
target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-gcc\"
 endif
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
@@ -36,7 +38,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 all: host strip
 
 host:
-       @cargo build --target $(TARGET) --release
+       @cargo build --target $(TARGET) --release --config $(LINKER_CFG)
 
 strip:
        @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/$(NAME) $(OUT_DIR)/$(NAME)
diff --git a/examples/secure_storage-rs/ta/Cargo.toml 
b/examples/secure_storage-rs/ta/Cargo.toml
index a1f89c2..7e7cae7 100644
--- a/examples/secure_storage-rs/ta/Cargo.toml
+++ b/examples/secure_storage-rs/ta/Cargo.toml
@@ -34,5 +34,6 @@ uuid = { version = "1.6.1", default-features = false }
 proto = { path = "../proto" }
 
 [profile.release]
+panic = "abort"
 lto = true
 opt-level = 1
diff --git a/examples/secure_storage-rs/ta/Makefile 
b/examples/secure_storage-rs/ta/Makefile
index ffee4b2..8a2faf4 100644
--- a/examples/secure_storage-rs/ta/Makefile
+++ b/examples/secure_storage-rs/ta/Makefile
@@ -26,13 +26,15 @@ ifeq ($(ARCH), arm)
        SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm32/scripts/sign_encrypt.py
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin
        OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy
-       TARGET := arm-unknown-optee-trustzone
+       TARGET := arm-unknown-linux-gnueabihf
+       LINKER_CFG := 
target.arm-unknown-linux-gnueabihf.linker=\"arm-linux-gnueabihf-ld.bfd\"
 else
        TA_SIGN_KEY ?= 
$(OPTEE_OS_DIR)/out/arm/export-ta_arm64/keys/default_ta.pem
        SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/scripts/sign_encrypt.py
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin
        OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy
-       TARGET := aarch64-unknown-optee-trustzone
+       TARGET := aarch64-unknown-linux-gnu
+       LINKER_CFG := 
target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-ld.bfd\"
 endif
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
@@ -40,7 +42,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 all: ta strip sign
 
 ta:
-       @xargo build --target $(TARGET) --release --verbose
+       @cargo build --target $(TARGET) --release --verbose --config 
$(LINKER_CFG)
 
 strip:
        @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta
@@ -50,4 +52,4 @@ sign:
        @echo "SIGN =>  ${UUID}"
 
 clean:
-       @xargo clean
+       @cargo clean
diff --git a/examples/secure_storage-rs/ta/build.rs 
b/examples/secure_storage-rs/ta/build.rs
index 1199035..fb1e5dc 100644
--- a/examples/secure_storage-rs/ta/build.rs
+++ b/examples/secure_storage-rs/ta/build.rs
@@ -59,5 +59,10 @@ fn main() -> std::io::Result<()> {
     println!("cargo:rustc-link-search={}", search_path.display());
     println!("cargo:rustc-link-lib=static=utee");
     println!("cargo:rustc-link-lib=static=utils");
+    println!("cargo:rustc-link-arg=-Tta.lds");
+    println!("cargo:rustc-link-arg=-e__ta_entry");
+    println!("cargo:rustc-link-arg=-pie");
+    println!("cargo:rustc-link-arg=-Os");
+    println!("cargo:rustc-link-arg=--sort-section=alignment");
     Ok(())
 }
diff --git a/examples/serde-rs/host/Makefile b/examples/serde-rs/host/Makefile
index 8010e57..b707934 100644
--- a/examples/serde-rs/host/Makefile
+++ b/examples/serde-rs/host/Makefile
@@ -24,10 +24,12 @@ ifeq ($(ARCH), arm)
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin
        OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy
        TARGET := arm-unknown-linux-gnueabihf
+       LINKER_CFG := 
target.arm-unknown-linux-gnueabihf..linker=\"arm-linux-gnueabihf-gcc\"
 else
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin
        OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy
        TARGET := aarch64-unknown-linux-gnu
+       LINKER_CFG := 
target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-gcc\"
 endif
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
@@ -36,7 +38,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 all: host strip
 
 host:
-       @cargo build --target $(TARGET) --release
+       @cargo build --target $(TARGET) --release --config $(LINKER_CFG)
 
 strip:
        @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/$(NAME) $(OUT_DIR)/$(NAME)
diff --git a/examples/serde-rs/ta/Makefile b/examples/serde-rs/ta/Makefile
index ffee4b2..9496d57 100644
--- a/examples/serde-rs/ta/Makefile
+++ b/examples/serde-rs/ta/Makefile
@@ -27,12 +27,14 @@ ifeq ($(ARCH), arm)
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin
        OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy
        TARGET := arm-unknown-optee-trustzone
+       LINKER_CFG := 
target.arm-unknown-optee-trustzone..linker=\"arm-linux-gnueabihf-ld.bfd\"
 else
        TA_SIGN_KEY ?= 
$(OPTEE_OS_DIR)/out/arm/export-ta_arm64/keys/default_ta.pem
        SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/scripts/sign_encrypt.py
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin
        OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy
        TARGET := aarch64-unknown-optee-trustzone
+       LINKER_CFG := 
target.aarch64-unknown-optee-trustzone.linker=\"aarch64-linux-gnu-ld.bfd\"
 endif
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
@@ -40,7 +42,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 all: ta strip sign
 
 ta:
-       @xargo build --target $(TARGET) --release --verbose
+       @xargo build --target $(TARGET) --release --verbose --config 
$(LINKER_CFG)
 
 strip:
        @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta
diff --git a/examples/serde-rs/ta/build.rs b/examples/serde-rs/ta/build.rs
index 33f6cc0..fb1e5dc 100644
--- a/examples/serde-rs/ta/build.rs
+++ b/examples/serde-rs/ta/build.rs
@@ -58,5 +58,11 @@ fn main() -> std::io::Result<()> {
 
     println!("cargo:rustc-link-search={}", search_path.display());
     println!("cargo:rustc-link-lib=static=utee");
+    println!("cargo:rustc-link-lib=static=utils");
+    println!("cargo:rustc-link-arg=-Tta.lds");
+    println!("cargo:rustc-link-arg=-e__ta_entry");
+    println!("cargo:rustc-link-arg=-pie");
+    println!("cargo:rustc-link-arg=-Os");
+    println!("cargo:rustc-link-arg=--sort-section=alignment");
     Ok(())
 }
diff --git a/examples/signature_verification-rs/host/Makefile 
b/examples/signature_verification-rs/host/Makefile
index 4ab88f9..42bdb8b 100644
--- a/examples/signature_verification-rs/host/Makefile
+++ b/examples/signature_verification-rs/host/Makefile
@@ -24,10 +24,12 @@ ifeq ($(ARCH), arm)
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin
        OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy
        TARGET := arm-unknown-linux-gnueabihf
+       LINKER_CFG := 
target.arm-unknown-linux-gnueabihf..linker=\"arm-linux-gnueabihf-gcc\"
 else
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin
        OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy
        TARGET := aarch64-unknown-linux-gnu
+       LINKER_CFG := 
target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-gcc\"
 endif
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
@@ -36,7 +38,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 all: host strip
 
 host:
-       @cargo build --target $(TARGET) --release
+       @cargo build --target $(TARGET) --release --config $(LINKER_CFG)
 
 strip:
        @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/$(NAME) $(OUT_DIR)/$(NAME)
diff --git a/examples/signature_verification-rs/ta/Cargo.toml 
b/examples/signature_verification-rs/ta/Cargo.toml
index a1f89c2..7e7cae7 100644
--- a/examples/signature_verification-rs/ta/Cargo.toml
+++ b/examples/signature_verification-rs/ta/Cargo.toml
@@ -34,5 +34,6 @@ uuid = { version = "1.6.1", default-features = false }
 proto = { path = "../proto" }
 
 [profile.release]
+panic = "abort"
 lto = true
 opt-level = 1
diff --git a/examples/signature_verification-rs/ta/Makefile 
b/examples/signature_verification-rs/ta/Makefile
index ffee4b2..8a2faf4 100644
--- a/examples/signature_verification-rs/ta/Makefile
+++ b/examples/signature_verification-rs/ta/Makefile
@@ -26,13 +26,15 @@ ifeq ($(ARCH), arm)
        SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm32/scripts/sign_encrypt.py
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin
        OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy
-       TARGET := arm-unknown-optee-trustzone
+       TARGET := arm-unknown-linux-gnueabihf
+       LINKER_CFG := 
target.arm-unknown-linux-gnueabihf.linker=\"arm-linux-gnueabihf-ld.bfd\"
 else
        TA_SIGN_KEY ?= 
$(OPTEE_OS_DIR)/out/arm/export-ta_arm64/keys/default_ta.pem
        SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/scripts/sign_encrypt.py
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin
        OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy
-       TARGET := aarch64-unknown-optee-trustzone
+       TARGET := aarch64-unknown-linux-gnu
+       LINKER_CFG := 
target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-ld.bfd\"
 endif
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
@@ -40,7 +42,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 all: ta strip sign
 
 ta:
-       @xargo build --target $(TARGET) --release --verbose
+       @cargo build --target $(TARGET) --release --verbose --config 
$(LINKER_CFG)
 
 strip:
        @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta
@@ -50,4 +52,4 @@ sign:
        @echo "SIGN =>  ${UUID}"
 
 clean:
-       @xargo clean
+       @cargo clean
diff --git a/examples/signature_verification-rs/ta/build.rs 
b/examples/signature_verification-rs/ta/build.rs
index 1199035..fb1e5dc 100644
--- a/examples/signature_verification-rs/ta/build.rs
+++ b/examples/signature_verification-rs/ta/build.rs
@@ -59,5 +59,10 @@ fn main() -> std::io::Result<()> {
     println!("cargo:rustc-link-search={}", search_path.display());
     println!("cargo:rustc-link-lib=static=utee");
     println!("cargo:rustc-link-lib=static=utils");
+    println!("cargo:rustc-link-arg=-Tta.lds");
+    println!("cargo:rustc-link-arg=-e__ta_entry");
+    println!("cargo:rustc-link-arg=-pie");
+    println!("cargo:rustc-link-arg=-Os");
+    println!("cargo:rustc-link-arg=--sort-section=alignment");
     Ok(())
 }
diff --git a/examples/supp_plugin-rs/host/Makefile 
b/examples/supp_plugin-rs/host/Makefile
index 81a6b7a..5f21430 100644
--- a/examples/supp_plugin-rs/host/Makefile
+++ b/examples/supp_plugin-rs/host/Makefile
@@ -24,10 +24,12 @@ ifeq ($(ARCH), arm)
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin
        OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy
        TARGET := arm-unknown-linux-gnueabihf
+       LINKER_CFG := 
target.arm-unknown-linux-gnueabihf..linker=\"arm-linux-gnueabihf-gcc\"
 else
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin
        OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy
        TARGET := aarch64-unknown-linux-gnu
+       LINKER_CFG := 
target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-gcc\"
 endif
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
@@ -36,7 +38,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 all: host strip
 
 host:
-       @cargo build --target $(TARGET) --release
+       @cargo build --target $(TARGET) --release --config $(LINKER_CFG)
 
 strip:
        @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/$(NAME) $(OUT_DIR)/$(NAME)
diff --git a/examples/supp_plugin-rs/plugin/Makefile 
b/examples/supp_plugin-rs/plugin/Makefile
index bb39fe0..fb35348 100644
--- a/examples/supp_plugin-rs/plugin/Makefile
+++ b/examples/supp_plugin-rs/plugin/Makefile
@@ -25,10 +25,12 @@ ifeq ($(ARCH), arm)
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin
        OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy
        TARGET := arm-unknown-linux-gnueabihf
+       LINKER_CFG := 
target.arm-unknown-linux-gnueabihf..linker=\"arm-linux-gnueabihf-gcc\"
 else
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin
        OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy
        TARGET := aarch64-unknown-linux-gnu
+       LINKER_CFG := 
target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-gcc\"
 endif
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
@@ -37,7 +39,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 all: host
 
 host:
-       @cargo build --target $(TARGET) --release
+       @cargo build --target $(TARGET) --release --config $(LINKER_CFG)
        cp $(CURDIR)/target/$(TARGET)/release/lib$(NAME).so 
$(CURDIR)/target/$(TARGET)/release/$(PLUGIN_UUID).plugin.so 
 clean:
        @cargo clean
diff --git a/examples/supp_plugin-rs/ta/Cargo.toml 
b/examples/supp_plugin-rs/ta/Cargo.toml
index a1f89c2..7e7cae7 100644
--- a/examples/supp_plugin-rs/ta/Cargo.toml
+++ b/examples/supp_plugin-rs/ta/Cargo.toml
@@ -34,5 +34,6 @@ uuid = { version = "1.6.1", default-features = false }
 proto = { path = "../proto" }
 
 [profile.release]
+panic = "abort"
 lto = true
 opt-level = 1
diff --git a/examples/supp_plugin-rs/ta/Makefile 
b/examples/supp_plugin-rs/ta/Makefile
index b607f25..49b5219 100644
--- a/examples/supp_plugin-rs/ta/Makefile
+++ b/examples/supp_plugin-rs/ta/Makefile
@@ -26,13 +26,15 @@ ifeq ($(ARCH), arm)
        SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm32/scripts/sign_encrypt.py
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin
        OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy
-       TARGET := arm-unknown-optee-trustzone
+       TARGET := arm-unknown-linux-gnueabihf
+       LINKER_CFG := 
target.arm-unknown-linux-gnueabihf.linker=\"arm-linux-gnueabihf-ld.bfd\"
 else
        TA_SIGN_KEY ?= 
$(OPTEE_OS_DIR)/out/arm/export-ta_arm64/keys/default_ta.pem
        SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/scripts/sign_encrypt.py
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin
        OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy
-       TARGET := aarch64-unknown-optee-trustzone
+       TARGET := aarch64-unknown-linux-gnu
+       LINKER_CFG := 
target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-ld.bfd\"
 endif
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
@@ -40,7 +42,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 all: ta strip sign
 
 ta:
-       @xargo build --target $(TARGET) --release --verbose
+       @cargo build --target $(TARGET) --release --verbose --config 
$(LINKER_CFG)
 
 strip:
        @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta
@@ -50,4 +52,4 @@ sign:
        @echo "SIGN =>  ${UUID}"
 
 clean:
-       @xargo clean
+       @cargo clean
diff --git a/examples/supp_plugin-rs/ta/build.rs 
b/examples/supp_plugin-rs/ta/build.rs
index c67e63b..75c36c3 100644
--- a/examples/supp_plugin-rs/ta/build.rs
+++ b/examples/supp_plugin-rs/ta/build.rs
@@ -59,5 +59,10 @@ fn main() -> std::io::Result<()> {
     println!("cargo:rustc-link-search={}", search_path.display());
     println!("cargo:rustc-link-lib=static=utee");
     println!("cargo:rustc-link-lib=static=utils");
+    println!("cargo:rustc-link-arg=-Tta.lds");
+    println!("cargo:rustc-link-arg=-e__ta_entry");
+    println!("cargo:rustc-link-arg=-pie");
+    println!("cargo:rustc-link-arg=-Os");
+    println!("cargo:rustc-link-arg=--sort-section=alignment");
     Ok(())
 }
diff --git a/examples/tcp_client-rs/host/Makefile 
b/examples/tcp_client-rs/host/Makefile
index 540b970..329a7b0 100644
--- a/examples/tcp_client-rs/host/Makefile
+++ b/examples/tcp_client-rs/host/Makefile
@@ -24,10 +24,12 @@ ifeq ($(ARCH), arm)
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin
        OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy
        TARGET := arm-unknown-linux-gnueabihf
+       LINKER_CFG := 
target.arm-unknown-linux-gnueabihf..linker=\"arm-linux-gnueabihf-gcc\"
 else
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin
        OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy
        TARGET := aarch64-unknown-linux-gnu
+       LINKER_CFG := 
target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-gcc\"
 endif
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
@@ -36,7 +38,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 all: host strip
 
 host:
-       @cargo build --target $(TARGET) --release
+       @cargo build --target $(TARGET) --release --config $(LINKER_CFG)
 
 strip:
        @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/$(NAME) $(OUT_DIR)/$(NAME)
diff --git a/examples/tcp_client-rs/ta/Makefile 
b/examples/tcp_client-rs/ta/Makefile
index ffee4b2..9496d57 100644
--- a/examples/tcp_client-rs/ta/Makefile
+++ b/examples/tcp_client-rs/ta/Makefile
@@ -27,12 +27,14 @@ ifeq ($(ARCH), arm)
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin
        OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy
        TARGET := arm-unknown-optee-trustzone
+       LINKER_CFG := 
target.arm-unknown-optee-trustzone..linker=\"arm-linux-gnueabihf-ld.bfd\"
 else
        TA_SIGN_KEY ?= 
$(OPTEE_OS_DIR)/out/arm/export-ta_arm64/keys/default_ta.pem
        SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/scripts/sign_encrypt.py
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin
        OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy
        TARGET := aarch64-unknown-optee-trustzone
+       LINKER_CFG := 
target.aarch64-unknown-optee-trustzone.linker=\"aarch64-linux-gnu-ld.bfd\"
 endif
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
@@ -40,7 +42,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 all: ta strip sign
 
 ta:
-       @xargo build --target $(TARGET) --release --verbose
+       @xargo build --target $(TARGET) --release --verbose --config 
$(LINKER_CFG)
 
 strip:
        @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta
diff --git a/examples/tcp_client-rs/ta/build.rs 
b/examples/tcp_client-rs/ta/build.rs
index 33f6cc0..fb1e5dc 100644
--- a/examples/tcp_client-rs/ta/build.rs
+++ b/examples/tcp_client-rs/ta/build.rs
@@ -58,5 +58,11 @@ fn main() -> std::io::Result<()> {
 
     println!("cargo:rustc-link-search={}", search_path.display());
     println!("cargo:rustc-link-lib=static=utee");
+    println!("cargo:rustc-link-lib=static=utils");
+    println!("cargo:rustc-link-arg=-Tta.lds");
+    println!("cargo:rustc-link-arg=-e__ta_entry");
+    println!("cargo:rustc-link-arg=-pie");
+    println!("cargo:rustc-link-arg=-Os");
+    println!("cargo:rustc-link-arg=--sort-section=alignment");
     Ok(())
 }
diff --git a/examples/time-rs/host/Makefile b/examples/time-rs/host/Makefile
index 52b6786..e0b773e 100644
--- a/examples/time-rs/host/Makefile
+++ b/examples/time-rs/host/Makefile
@@ -24,10 +24,12 @@ ifeq ($(ARCH), arm)
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin
        OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy
        TARGET := arm-unknown-linux-gnueabihf
+       LINKER_CFG := 
target.arm-unknown-linux-gnueabihf..linker=\"arm-linux-gnueabihf-gcc\"
 else
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin
        OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy
        TARGET := aarch64-unknown-linux-gnu
+       LINKER_CFG := 
target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-gcc\"
 endif
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
@@ -36,7 +38,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 all: host strip
 
 host:
-       @cargo build --target $(TARGET) --release
+       @cargo build --target $(TARGET) --release --config $(LINKER_CFG)
 
 strip:
        @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/$(NAME) $(OUT_DIR)/$(NAME)
diff --git a/examples/time-rs/ta/Cargo.toml b/examples/time-rs/ta/Cargo.toml
index a1f89c2..7e7cae7 100644
--- a/examples/time-rs/ta/Cargo.toml
+++ b/examples/time-rs/ta/Cargo.toml
@@ -34,5 +34,6 @@ uuid = { version = "1.6.1", default-features = false }
 proto = { path = "../proto" }
 
 [profile.release]
+panic = "abort"
 lto = true
 opt-level = 1
diff --git a/examples/time-rs/ta/Makefile b/examples/time-rs/ta/Makefile
index ffee4b2..8a2faf4 100644
--- a/examples/time-rs/ta/Makefile
+++ b/examples/time-rs/ta/Makefile
@@ -26,13 +26,15 @@ ifeq ($(ARCH), arm)
        SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm32/scripts/sign_encrypt.py
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin
        OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy
-       TARGET := arm-unknown-optee-trustzone
+       TARGET := arm-unknown-linux-gnueabihf
+       LINKER_CFG := 
target.arm-unknown-linux-gnueabihf.linker=\"arm-linux-gnueabihf-ld.bfd\"
 else
        TA_SIGN_KEY ?= 
$(OPTEE_OS_DIR)/out/arm/export-ta_arm64/keys/default_ta.pem
        SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/scripts/sign_encrypt.py
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin
        OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy
-       TARGET := aarch64-unknown-optee-trustzone
+       TARGET := aarch64-unknown-linux-gnu
+       LINKER_CFG := 
target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-ld.bfd\"
 endif
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
@@ -40,7 +42,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 all: ta strip sign
 
 ta:
-       @xargo build --target $(TARGET) --release --verbose
+       @cargo build --target $(TARGET) --release --verbose --config 
$(LINKER_CFG)
 
 strip:
        @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta
@@ -50,4 +52,4 @@ sign:
        @echo "SIGN =>  ${UUID}"
 
 clean:
-       @xargo clean
+       @cargo clean
diff --git a/examples/time-rs/ta/build.rs b/examples/time-rs/ta/build.rs
index 1199035..fb1e5dc 100644
--- a/examples/time-rs/ta/build.rs
+++ b/examples/time-rs/ta/build.rs
@@ -59,5 +59,10 @@ fn main() -> std::io::Result<()> {
     println!("cargo:rustc-link-search={}", search_path.display());
     println!("cargo:rustc-link-lib=static=utee");
     println!("cargo:rustc-link-lib=static=utils");
+    println!("cargo:rustc-link-arg=-Tta.lds");
+    println!("cargo:rustc-link-arg=-e__ta_entry");
+    println!("cargo:rustc-link-arg=-pie");
+    println!("cargo:rustc-link-arg=-Os");
+    println!("cargo:rustc-link-arg=--sort-section=alignment");
     Ok(())
 }
diff --git a/examples/tls_client-rs/host/Makefile 
b/examples/tls_client-rs/host/Makefile
index d68659b..1cbcb7f 100644
--- a/examples/tls_client-rs/host/Makefile
+++ b/examples/tls_client-rs/host/Makefile
@@ -24,10 +24,12 @@ ifeq ($(ARCH), arm)
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin
        OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy
        TARGET := arm-unknown-linux-gnueabihf
+       LINKER_CFG := 
target.arm-unknown-linux-gnueabihf..linker=\"arm-linux-gnueabihf-gcc\"
 else
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin
        OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy
        TARGET := aarch64-unknown-linux-gnu
+       LINKER_CFG := 
target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-gcc\"
 endif
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
@@ -36,7 +38,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 all: host strip
 
 host:
-       @cargo build --target $(TARGET) --release
+       @cargo build --target $(TARGET) --release --config $(LINKER_CFG)
 
 strip:
        @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/$(NAME) $(OUT_DIR)/$(NAME)
diff --git a/examples/tls_client-rs/ta/Makefile 
b/examples/tls_client-rs/ta/Makefile
index ffee4b2..9496d57 100644
--- a/examples/tls_client-rs/ta/Makefile
+++ b/examples/tls_client-rs/ta/Makefile
@@ -27,12 +27,14 @@ ifeq ($(ARCH), arm)
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin
        OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy
        TARGET := arm-unknown-optee-trustzone
+       LINKER_CFG := 
target.arm-unknown-optee-trustzone..linker=\"arm-linux-gnueabihf-ld.bfd\"
 else
        TA_SIGN_KEY ?= 
$(OPTEE_OS_DIR)/out/arm/export-ta_arm64/keys/default_ta.pem
        SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/scripts/sign_encrypt.py
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin
        OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy
        TARGET := aarch64-unknown-optee-trustzone
+       LINKER_CFG := 
target.aarch64-unknown-optee-trustzone.linker=\"aarch64-linux-gnu-ld.bfd\"
 endif
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
@@ -40,7 +42,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 all: ta strip sign
 
 ta:
-       @xargo build --target $(TARGET) --release --verbose
+       @xargo build --target $(TARGET) --release --verbose --config 
$(LINKER_CFG)
 
 strip:
        @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta
diff --git a/examples/tls_client-rs/ta/build.rs 
b/examples/tls_client-rs/ta/build.rs
index 4b4d42d..c1ecbac 100644
--- a/examples/tls_client-rs/ta/build.rs
+++ b/examples/tls_client-rs/ta/build.rs
@@ -58,5 +58,11 @@ fn main() -> std::io::Result<()> {
 
     println!("cargo:rustc-link-search={}", search_path.display());
     println!("cargo:rustc-link-lib=static=utee");
+    println!("cargo:rustc-link-lib=static=utils");
+    println!("cargo:rustc-link-arg=-Tta.lds");
+    println!("cargo:rustc-link-arg=-e__ta_entry");
+    println!("cargo:rustc-link-arg=-pie");
+    println!("cargo:rustc-link-arg=-Os");
+    println!("cargo:rustc-link-arg=--sort-section=alignment");
     Ok(())
 }
diff --git a/examples/tls_server-rs/host/Makefile 
b/examples/tls_server-rs/host/Makefile
index 0b741ea..5c03523 100644
--- a/examples/tls_server-rs/host/Makefile
+++ b/examples/tls_server-rs/host/Makefile
@@ -24,10 +24,12 @@ ifeq ($(ARCH), arm)
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin
        OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy
        TARGET := arm-unknown-linux-gnueabihf
+       LINKER_CFG := 
target.arm-unknown-linux-gnueabihf..linker=\"arm-linux-gnueabihf-gcc\"
 else
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin
        OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy
        TARGET := aarch64-unknown-linux-gnu
+       LINKER_CFG := 
target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-gcc\"
 endif
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
@@ -36,7 +38,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 all: host strip
 
 host:
-       @cargo build --target $(TARGET) --release
+       @cargo build --target $(TARGET) --release --config $(LINKER_CFG)
 
 strip:
        @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/$(NAME) $(OUT_DIR)/$(NAME)
diff --git a/examples/tls_server-rs/ta/Makefile 
b/examples/tls_server-rs/ta/Makefile
index ffee4b2..9496d57 100644
--- a/examples/tls_server-rs/ta/Makefile
+++ b/examples/tls_server-rs/ta/Makefile
@@ -27,12 +27,14 @@ ifeq ($(ARCH), arm)
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin
        OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy
        TARGET := arm-unknown-optee-trustzone
+       LINKER_CFG := 
target.arm-unknown-optee-trustzone..linker=\"arm-linux-gnueabihf-ld.bfd\"
 else
        TA_SIGN_KEY ?= 
$(OPTEE_OS_DIR)/out/arm/export-ta_arm64/keys/default_ta.pem
        SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/scripts/sign_encrypt.py
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin
        OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy
        TARGET := aarch64-unknown-optee-trustzone
+       LINKER_CFG := 
target.aarch64-unknown-optee-trustzone.linker=\"aarch64-linux-gnu-ld.bfd\"
 endif
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
@@ -40,7 +42,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 all: ta strip sign
 
 ta:
-       @xargo build --target $(TARGET) --release --verbose
+       @xargo build --target $(TARGET) --release --verbose --config 
$(LINKER_CFG)
 
 strip:
        @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta
diff --git a/examples/tls_server-rs/ta/build.rs 
b/examples/tls_server-rs/ta/build.rs
index 4b4d42d..c1ecbac 100644
--- a/examples/tls_server-rs/ta/build.rs
+++ b/examples/tls_server-rs/ta/build.rs
@@ -58,5 +58,11 @@ fn main() -> std::io::Result<()> {
 
     println!("cargo:rustc-link-search={}", search_path.display());
     println!("cargo:rustc-link-lib=static=utee");
+    println!("cargo:rustc-link-lib=static=utils");
+    println!("cargo:rustc-link-arg=-Tta.lds");
+    println!("cargo:rustc-link-arg=-e__ta_entry");
+    println!("cargo:rustc-link-arg=-pie");
+    println!("cargo:rustc-link-arg=-Os");
+    println!("cargo:rustc-link-arg=--sort-section=alignment");
     Ok(())
 }
diff --git a/examples/udp_socket-rs/host/Makefile 
b/examples/udp_socket-rs/host/Makefile
index e765a00..5cb7197 100644
--- a/examples/udp_socket-rs/host/Makefile
+++ b/examples/udp_socket-rs/host/Makefile
@@ -24,10 +24,12 @@ ifeq ($(ARCH), arm)
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin
        OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy
        TARGET := arm-unknown-linux-gnueabihf
+       LINKER_CFG := 
target.arm-unknown-linux-gnueabihf..linker=\"arm-linux-gnueabihf-gcc\"
 else
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin
        OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy
        TARGET := aarch64-unknown-linux-gnu
+       LINKER_CFG := 
target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-gcc\"
 endif
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
@@ -36,7 +38,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 all: host strip
 
 host:
-       @cargo build --target $(TARGET) --release
+       @cargo build --target $(TARGET) --release --config $(LINKER_CFG)
 
 strip:
        @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/$(NAME) $(OUT_DIR)/$(NAME)
diff --git a/examples/udp_socket-rs/ta/Makefile 
b/examples/udp_socket-rs/ta/Makefile
index ffee4b2..9496d57 100644
--- a/examples/udp_socket-rs/ta/Makefile
+++ b/examples/udp_socket-rs/ta/Makefile
@@ -27,12 +27,14 @@ ifeq ($(ARCH), arm)
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin
        OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy
        TARGET := arm-unknown-optee-trustzone
+       LINKER_CFG := 
target.arm-unknown-optee-trustzone..linker=\"arm-linux-gnueabihf-ld.bfd\"
 else
        TA_SIGN_KEY ?= 
$(OPTEE_OS_DIR)/out/arm/export-ta_arm64/keys/default_ta.pem
        SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/scripts/sign_encrypt.py
        OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin
        OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy
        TARGET := aarch64-unknown-optee-trustzone
+       LINKER_CFG := 
target.aarch64-unknown-optee-trustzone.linker=\"aarch64-linux-gnu-ld.bfd\"
 endif
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
@@ -40,7 +42,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 all: ta strip sign
 
 ta:
-       @xargo build --target $(TARGET) --release --verbose
+       @xargo build --target $(TARGET) --release --verbose --config 
$(LINKER_CFG)
 
 strip:
        @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta
diff --git a/examples/udp_socket-rs/ta/build.rs 
b/examples/udp_socket-rs/ta/build.rs
index 33f6cc0..fb1e5dc 100644
--- a/examples/udp_socket-rs/ta/build.rs
+++ b/examples/udp_socket-rs/ta/build.rs
@@ -58,5 +58,11 @@ fn main() -> std::io::Result<()> {
 
     println!("cargo:rustc-link-search={}", search_path.display());
     println!("cargo:rustc-link-lib=static=utee");
+    println!("cargo:rustc-link-lib=static=utils");
+    println!("cargo:rustc-link-arg=-Tta.lds");
+    println!("cargo:rustc-link-arg=-e__ta_entry");
+    println!("cargo:rustc-link-arg=-pie");
+    println!("cargo:rustc-link-arg=-Os");
+    println!("cargo:rustc-link-arg=--sort-section=alignment");
     Ok(())
 }
diff --git a/tests/test_acipher.sh b/tests/test_acipher.sh
index af39d02..bba9af8 100755
--- a/tests/test_acipher.sh
+++ b/tests/test_acipher.sh
@@ -25,7 +25,7 @@ rm -rf shared
 
 curl 
https://nightlies.apache.org/teaclave/teaclave-trustzone-sdk/optee-qemuv8-3.20.0-ubuntu-20.04.tar.gz
 | tar zxv
 mkdir shared
-cp 
../examples/acipher-rs/ta/target/aarch64-unknown-optee-trustzone/release/*.ta 
shared
+cp ../examples/acipher-rs/ta/target/aarch64-unknown-linux-gnu/release/*.ta 
shared
 cp 
../examples/acipher-rs/host/target/aarch64-unknown-linux-gnu/release/acipher-rs 
shared
 
 screen -L -d -m -S qemu_screen ./optee-qemuv8.sh
diff --git a/tests/test_aes.sh b/tests/test_aes.sh
index 9ba9b59..711573a 100755
--- a/tests/test_aes.sh
+++ b/tests/test_aes.sh
@@ -25,7 +25,7 @@ rm -rf shared
 
 curl 
https://nightlies.apache.org/teaclave/teaclave-trustzone-sdk/optee-qemuv8-3.20.0-ubuntu-20.04.tar.gz
 | tar zxv
 mkdir shared
-cp ../examples/aes-rs/ta/target/aarch64-unknown-optee-trustzone/release/*.ta 
shared
+cp ../examples/aes-rs/ta/target/aarch64-unknown-linux-gnu/release/*.ta shared
 cp ../examples/aes-rs/host/target/aarch64-unknown-linux-gnu/release/aes-rs 
shared
 
 screen -L -d -m -S qemu_screen ./optee-qemuv8.sh
diff --git a/tests/test_authentication.sh b/tests/test_authentication.sh
index 337a089..03fd0f1 100755
--- a/tests/test_authentication.sh
+++ b/tests/test_authentication.sh
@@ -25,7 +25,7 @@ rm -rf shared
 
 curl 
https://nightlies.apache.org/teaclave/teaclave-trustzone-sdk/optee-qemuv8-3.20.0-ubuntu-20.04.tar.gz
 | tar zxv
 mkdir shared
-cp 
../examples/authentication-rs/ta/target/aarch64-unknown-optee-trustzone/release/*.ta
 shared
+cp 
../examples/authentication-rs/ta/target/aarch64-unknown-linux-gnu/release/*.ta 
shared
 cp 
../examples/authentication-rs/host/target/aarch64-unknown-linux-gnu/release/authentication-rs
 shared
 
 screen -L -d -m -S qemu_screen ./optee-qemuv8.sh
diff --git a/tests/test_big_int.sh b/tests/test_big_int.sh
index 87b6a7a..c3836c5 100755
--- a/tests/test_big_int.sh
+++ b/tests/test_big_int.sh
@@ -25,7 +25,7 @@ rm -rf shared
 
 curl 
https://nightlies.apache.org/teaclave/teaclave-trustzone-sdk/optee-qemuv8-3.20.0-ubuntu-20.04.tar.gz
 | tar zxv
 mkdir shared
-cp 
../examples/big_int-rs/ta/target/aarch64-unknown-optee-trustzone/release/*.ta 
shared
+cp ../examples/big_int-rs/ta/target/aarch64-unknown-linux-gnu/release/*.ta 
shared
 cp 
../examples/big_int-rs/host/target/aarch64-unknown-linux-gnu/release/big_int-rs 
shared
 
 screen -L -d -m -S qemu_screen ./optee-qemuv8.sh
diff --git a/tests/test_diffie_hellman.sh b/tests/test_diffie_hellman.sh
index 42f28eb..bc5ae5f 100755
--- a/tests/test_diffie_hellman.sh
+++ b/tests/test_diffie_hellman.sh
@@ -25,7 +25,7 @@ rm -rf shared
 
 curl 
https://nightlies.apache.org/teaclave/teaclave-trustzone-sdk/optee-qemuv8-3.20.0-ubuntu-20.04.tar.gz
 | tar zxv
 mkdir shared
-cp 
../examples/diffie_hellman-rs/ta/target/aarch64-unknown-optee-trustzone/release/*.ta
 shared
+cp 
../examples/diffie_hellman-rs/ta/target/aarch64-unknown-linux-gnu/release/*.ta 
shared
 cp 
../examples/diffie_hellman-rs/host/target/aarch64-unknown-linux-gnu/release/diffie_hellman-rs
 shared
 
 screen -L -d -m -S qemu_screen ./optee-qemuv8.sh
diff --git a/tests/test_digest.sh b/tests/test_digest.sh
index 5d0583a..2b4dbc1 100755
--- a/tests/test_digest.sh
+++ b/tests/test_digest.sh
@@ -25,7 +25,7 @@ rm -rf shared
 
 curl 
https://nightlies.apache.org/teaclave/teaclave-trustzone-sdk/optee-qemuv8-3.20.0-ubuntu-20.04.tar.gz
 | tar zxv
 mkdir shared
-cp 
../examples/digest-rs/ta/target/aarch64-unknown-optee-trustzone/release/*.ta 
shared
+cp ../examples/digest-rs/ta/target/aarch64-unknown-linux-gnu/release/*.ta 
shared
 cp 
../examples/digest-rs/host/target/aarch64-unknown-linux-gnu/release/digest-rs 
shared
 
 screen -L -d -m -S qemu_screen ./optee-qemuv8.sh
diff --git a/tests/test_hello_world.sh b/tests/test_hello_world.sh
index 3074af1..ca42341 100755
--- a/tests/test_hello_world.sh
+++ b/tests/test_hello_world.sh
@@ -25,7 +25,7 @@ rm -rf shared
 
 curl 
https://nightlies.apache.org/teaclave/teaclave-trustzone-sdk/optee-qemuv8-3.20.0-ubuntu-20.04.tar.gz
 | tar zxv
 mkdir shared
-cp 
../examples/hello_world-rs/ta/target/aarch64-unknown-optee-trustzone/release/*.ta
 shared
+cp ../examples/hello_world-rs/ta/target/aarch64-unknown-linux-gnu/release/*.ta 
shared
 cp 
../examples/hello_world-rs/host/target/aarch64-unknown-linux-gnu/release/hello_world-rs
 shared
 
 screen -L -d -m -S qemu_screen ./optee-qemuv8.sh
diff --git a/tests/test_hotp.sh b/tests/test_hotp.sh
index 9d41570..18641db 100755
--- a/tests/test_hotp.sh
+++ b/tests/test_hotp.sh
@@ -25,7 +25,7 @@ rm -rf shared
 
 curl 
https://nightlies.apache.org/teaclave/teaclave-trustzone-sdk/optee-qemuv8-3.20.0-ubuntu-20.04.tar.gz
 | tar zxv
 mkdir shared
-cp ../examples/hotp-rs/ta/target/aarch64-unknown-optee-trustzone/release/*.ta 
shared
+cp ../examples/hotp-rs/ta/target/aarch64-unknown-linux-gnu/release/*.ta shared
 cp ../examples/hotp-rs/host/target/aarch64-unknown-linux-gnu/release/hotp-rs 
shared
 
 screen -L -d -m -S qemu_screen ./optee-qemuv8.sh
diff --git a/tests/test_random.sh b/tests/test_random.sh
index 9700780..863f678 100755
--- a/tests/test_random.sh
+++ b/tests/test_random.sh
@@ -25,7 +25,7 @@ rm -rf shared
 
 curl 
https://nightlies.apache.org/teaclave/teaclave-trustzone-sdk/optee-qemuv8-3.20.0-ubuntu-20.04.tar.gz
 | tar zxv
 mkdir shared
-cp 
../examples/random-rs/ta/target/aarch64-unknown-optee-trustzone/release/*.ta 
shared
+cp ../examples/random-rs/ta/target/aarch64-unknown-linux-gnu/release/*.ta 
shared
 cp 
../examples/random-rs/host/target/aarch64-unknown-linux-gnu/release/random-rs 
shared
 
 screen -L -d -m -S qemu_screen ./optee-qemuv8.sh
diff --git a/tests/test_secure_storage.sh b/tests/test_secure_storage.sh
index 6b2995e..5a0ebd3 100755
--- a/tests/test_secure_storage.sh
+++ b/tests/test_secure_storage.sh
@@ -25,7 +25,7 @@ rm -rf shared
 
 curl 
https://nightlies.apache.org/teaclave/teaclave-trustzone-sdk/optee-qemuv8-3.20.0-ubuntu-20.04.tar.gz
 | tar zxv
 mkdir shared
-cp 
../examples/secure_storage-rs/ta/target/aarch64-unknown-optee-trustzone/release/*.ta
 shared
+cp 
../examples/secure_storage-rs/ta/target/aarch64-unknown-linux-gnu/release/*.ta 
shared
 cp 
../examples/secure_storage-rs/host/target/aarch64-unknown-linux-gnu/release/secure_storage-rs
 shared
 
 screen -L -d -m -S qemu_screen ./optee-qemuv8.sh
diff --git a/tests/test_signature_verification.sh 
b/tests/test_signature_verification.sh
index 8b7b7c8..be7e3ae 100755
--- a/tests/test_signature_verification.sh
+++ b/tests/test_signature_verification.sh
@@ -25,7 +25,7 @@ rm -rf shared
 
 curl 
https://nightlies.apache.org/teaclave/teaclave-trustzone-sdk/optee-qemuv8-3.20.0-ubuntu-20.04.tar.gz
 | tar zxv
 mkdir shared
-cp 
../examples/signature_verification-rs/ta/target/aarch64-unknown-optee-trustzone/release/*.ta
 shared
+cp 
../examples/signature_verification-rs/ta/target/aarch64-unknown-linux-gnu/release/*.ta
 shared
 cp 
../examples/signature_verification-rs/host/target/aarch64-unknown-linux-gnu/release/signature_verification-rs
 shared
 
 screen -L -d -m -S qemu_screen ./optee-qemuv8.sh
diff --git a/tests/test_supp_plugin.sh b/tests/test_supp_plugin.sh
index 3fa30fd..09e3f2f 100755
--- a/tests/test_supp_plugin.sh
+++ b/tests/test_supp_plugin.sh
@@ -25,7 +25,7 @@ rm -rf shared
 
 curl 
https://nightlies.apache.org/teaclave/teaclave-trustzone-sdk/optee-qemuv8-3.20.0-ubuntu-20.04.tar.gz
 | tar zxv
 mkdir shared
-cp 
../examples/supp_plugin-rs/ta/target/aarch64-unknown-optee-trustzone/release/*.ta
 shared
+cp ../examples/supp_plugin-rs/ta/target/aarch64-unknown-linux-gnu/release/*.ta 
shared
 cp 
../examples/supp_plugin-rs/host/target/aarch64-unknown-linux-gnu/release/supp_plugin-rs
 shared
 cp 
../examples/supp_plugin-rs/plugin/target/aarch64-unknown-linux-gnu/release/*.plugin.so
 shared
 
diff --git a/tests/test_time.sh b/tests/test_time.sh
index f49ece4..2958b09 100755
--- a/tests/test_time.sh
+++ b/tests/test_time.sh
@@ -25,7 +25,7 @@ rm -rf shared
 
 curl 
https://nightlies.apache.org/teaclave/teaclave-trustzone-sdk/optee-qemuv8-3.20.0-ubuntu-20.04.tar.gz
 | tar zxv
 mkdir shared
-cp ../examples/time-rs/ta/target/aarch64-unknown-optee-trustzone/release/*.ta 
shared
+cp ../examples/time-rs/ta/target/aarch64-unknown-linux-gnu/release/*.ta shared
 cp ../examples/time-rs/host/target/aarch64-unknown-linux-gnu/release/time-rs 
shared
 
 screen -L -d -m -S qemu_screen ./optee-qemuv8.sh


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to