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


The following commit(s) were added to refs/heads/no-std by this push:
     new bc6ae89  examples: 32-bit TAs: Fix runtime abort
bc6ae89 is described below

commit bc6ae8911b6ae093e8369a53a42b8c99307f7dc5
Author: Sumit Garg <[email protected]>
AuthorDate: Mon Jan 15 13:15:37 2024 +0530

    examples: 32-bit TAs: Fix runtime abort
    
    Refactor TAs build script code to reuse 64K section alignment hook for
    32-bit TAs. This would allow linker to separate executable code from
    writable data and in turn fix following runtime abort with 32-bit TAs:
    
    E/TC:? 0
    E/TC:? 0 User mode prefetch-abort at address 0x400410e4 (read permission 
fault)
    E/TC:? 0  esr 0x8200000f  ttbr0 0x200000e1b2020   ttbr1 0x00000000   cidr 
0x0
    E/TC:? 0  cpu #1          cpsr 0x00000110
    E/TC:? 0  x0  0000000000000000 x1  000000000009e850
    E/TC:? 0  x2  0000000040015f80 x3  0000000000000000
    E/TC:? 0  x4  0000000000000000 x5  0000000000000000
    E/TC:? 0  x6  0000000000000000 x7  0000000000000000
    E/TC:? 0  x8  0000000000000000 x9  0000000000000000
    E/TC:? 0  x10 0000000000000000 x11 0000000000000000
    E/TC:? 0  x12 0000000000000000 x13 0000000040015f80
    E/TC:? 0  x14 0000000000000000 x15 0000000000000000
    E/TC:? 0  x16 0000000000000000 x17 0000000000000000
    E/TC:? 0  x18 0000000000000000 x19 0000000000000000
    E/TC:? 0  x20 0000000000000000 x21 0000000000000000
    E/TC:? 0  x22 0000000000000000 x23 0000000000000000
    E/TC:? 0  x24 0000000000000000 x25 0000000000000000
    E/TC:? 0  x26 0000000000000000 x27 0000000000000000
    E/TC:? 0  x28 0000000000000000 x29 0000000000000000
    E/TC:? 0  x30 0000000000000000 elr 00000000400410e4
    E/TC:? 0  sp_el0 0000000040015f80
    E/LD:  Status of TA 133af0ca-bdab-11eb-9130-43bf7873bf67
    E/LD:   arch: arm
    E/LD:  region  0: va 0x40005000 pa 0x0e301000 size 0x002000 flags rw-s 
(ldelf)
    E/LD:  region  1: va 0x40007000 pa 0x0e303000 size 0x008000 flags r-xs 
(ldelf)
    E/LD:  region  2: va 0x4000f000 pa 0x0e30b000 size 0x001000 flags rw-s 
(ldelf)
    E/LD:  region  3: va 0x40010000 pa 0x0e30c000 size 0x004000 flags rw-s 
(ldelf)
    E/LD:  region  4: va 0x40014000 pa 0x0e310000 size 0x001000 flags r--s
    E/LD:  region  5: va 0x40015000 pa 0x0e32f000 size 0x001000 flags rw-s 
(stack)
    E/LD:  region  6: va 0x4003f000 pa 0x00010000 size 0x01e000 flags rwxs [0]
    E/LD:   [0] 133af0ca-bdab-11eb-9130-43bf7873bf67 @ 0x4003f000
    
    Tested-by: Jerome Forissier <[email protected]>
    Signed-off-by: Sumit Garg <[email protected]>
---
 examples/acipher-rs/ta/build.rs                | 58 +++++++++++++-------------
 examples/aes-rs/ta/build.rs                    | 58 +++++++++++++-------------
 examples/authentication-rs/ta/build.rs         | 58 +++++++++++++-------------
 examples/big_int-rs/ta/build.rs                | 58 +++++++++++++-------------
 examples/diffie_hellman-rs/ta/build.rs         | 58 +++++++++++++-------------
 examples/digest-rs/ta/build.rs                 | 58 +++++++++++++-------------
 examples/hello_world-rs/ta/build.rs            | 58 +++++++++++++-------------
 examples/hotp-rs/ta/build.rs                   | 58 +++++++++++++-------------
 examples/random-rs/ta/build.rs                 | 58 +++++++++++++-------------
 examples/secure_storage-rs/ta/build.rs         | 58 +++++++++++++-------------
 examples/signature_verification-rs/ta/build.rs | 58 +++++++++++++-------------
 examples/supp_plugin-rs/ta/build.rs            | 58 +++++++++++++-------------
 examples/time-rs/ta/build.rs                   | 58 +++++++++++++-------------
 13 files changed, 377 insertions(+), 377 deletions(-)

diff --git a/examples/acipher-rs/ta/build.rs b/examples/acipher-rs/ta/build.rs
index 19aae62..5618f03 100644
--- a/examples/acipher-rs/ta/build.rs
+++ b/examples/acipher-rs/ta/build.rs
@@ -43,6 +43,15 @@ fn main() -> std::io::Result<()> {
         time_low, time_mid, time_hi_and_version, clock_seq_and_node
     )?;
 
+    let mut aarch64_flag = true;
+    match env::var("TARGET") {
+        Ok(ref v) if v == "arm-unknown-linux-gnueabihf" => {
+            println!("cargo:rustc-link-arg=--no-warn-mismatch");
+            aarch64_flag = false;
+        },
+        _ => {}
+    };
+
     let optee_os_dir = env::var("TA_DEV_KIT_DIR").unwrap();
     let search_path = Path::new(&optee_os_dir).join("lib");
 
@@ -51,39 +60,30 @@ fn main() -> std::io::Result<()> {
     let f = File::open(optee_os_path.join("src/ta.ld.S"))?;
     let f = BufReader::new(f);
 
-    match env::var("TARGET") {
-        Ok(ref v) if v == "arm-unknown-linux-gnueabihf" => {
-            println!("cargo:rustc-link-arg=--no-warn-mismatch");
-            for line in f.lines() {
-                let l = line?;
+    for line in f.lines() {
+        let l = line?;
 
-                if l.starts_with('#') ||
-                   l == "OUTPUT_FORMAT(\"elf64-littleaarch64\")" ||
-                   l == "OUTPUT_ARCH(aarch64)" {
-                    continue;
-                }
-
-                write!(ta_lds, "{}\n", l)?;
+        if aarch64_flag {
+            if l.starts_with('#') ||
+                l == "OUTPUT_FORMAT(\"elf32-littlearm\")" ||
+                l == "OUTPUT_ARCH(arm)" {
+                continue;
             }
-        },
-        _ => {
-            for line in f.lines() {
-                let l = line?;
-
-                if l.starts_with('#') ||
-                   l == "OUTPUT_FORMAT(\"elf32-littlearm\")" ||
-                   l == "OUTPUT_ARCH(arm)" {
-                    continue;
-                }
-
-                if l == "\t. = ALIGN(4096);" {
-                    write!(ta_lds, "\t. = ALIGN(65536);\n")?;
-                } else {
-                    write!(ta_lds, "{}\n", l)?;
-                }
+        } else {
+            if l.starts_with('#') ||
+                l == "OUTPUT_FORMAT(\"elf64-littleaarch64\")" ||
+                l == "OUTPUT_ARCH(aarch64)" {
+                continue;
             }
         }
-    };
+
+        if l == "\t. = ALIGN(4096);" {
+            write!(ta_lds, "\t. = ALIGN(65536);\n")?;
+        } else {
+            write!(ta_lds, "{}\n", l)?;
+        }
+    }
+
     println!("cargo:rustc-link-search={}", out.display());
     println!("cargo:rerun-if-changed=ta.lds");
 
diff --git a/examples/aes-rs/ta/build.rs b/examples/aes-rs/ta/build.rs
index 19aae62..5618f03 100644
--- a/examples/aes-rs/ta/build.rs
+++ b/examples/aes-rs/ta/build.rs
@@ -43,6 +43,15 @@ fn main() -> std::io::Result<()> {
         time_low, time_mid, time_hi_and_version, clock_seq_and_node
     )?;
 
+    let mut aarch64_flag = true;
+    match env::var("TARGET") {
+        Ok(ref v) if v == "arm-unknown-linux-gnueabihf" => {
+            println!("cargo:rustc-link-arg=--no-warn-mismatch");
+            aarch64_flag = false;
+        },
+        _ => {}
+    };
+
     let optee_os_dir = env::var("TA_DEV_KIT_DIR").unwrap();
     let search_path = Path::new(&optee_os_dir).join("lib");
 
@@ -51,39 +60,30 @@ fn main() -> std::io::Result<()> {
     let f = File::open(optee_os_path.join("src/ta.ld.S"))?;
     let f = BufReader::new(f);
 
-    match env::var("TARGET") {
-        Ok(ref v) if v == "arm-unknown-linux-gnueabihf" => {
-            println!("cargo:rustc-link-arg=--no-warn-mismatch");
-            for line in f.lines() {
-                let l = line?;
+    for line in f.lines() {
+        let l = line?;
 
-                if l.starts_with('#') ||
-                   l == "OUTPUT_FORMAT(\"elf64-littleaarch64\")" ||
-                   l == "OUTPUT_ARCH(aarch64)" {
-                    continue;
-                }
-
-                write!(ta_lds, "{}\n", l)?;
+        if aarch64_flag {
+            if l.starts_with('#') ||
+                l == "OUTPUT_FORMAT(\"elf32-littlearm\")" ||
+                l == "OUTPUT_ARCH(arm)" {
+                continue;
             }
-        },
-        _ => {
-            for line in f.lines() {
-                let l = line?;
-
-                if l.starts_with('#') ||
-                   l == "OUTPUT_FORMAT(\"elf32-littlearm\")" ||
-                   l == "OUTPUT_ARCH(arm)" {
-                    continue;
-                }
-
-                if l == "\t. = ALIGN(4096);" {
-                    write!(ta_lds, "\t. = ALIGN(65536);\n")?;
-                } else {
-                    write!(ta_lds, "{}\n", l)?;
-                }
+        } else {
+            if l.starts_with('#') ||
+                l == "OUTPUT_FORMAT(\"elf64-littleaarch64\")" ||
+                l == "OUTPUT_ARCH(aarch64)" {
+                continue;
             }
         }
-    };
+
+        if l == "\t. = ALIGN(4096);" {
+            write!(ta_lds, "\t. = ALIGN(65536);\n")?;
+        } else {
+            write!(ta_lds, "{}\n", l)?;
+        }
+    }
+
     println!("cargo:rustc-link-search={}", out.display());
     println!("cargo:rerun-if-changed=ta.lds");
 
diff --git a/examples/authentication-rs/ta/build.rs 
b/examples/authentication-rs/ta/build.rs
index 19aae62..5618f03 100644
--- a/examples/authentication-rs/ta/build.rs
+++ b/examples/authentication-rs/ta/build.rs
@@ -43,6 +43,15 @@ fn main() -> std::io::Result<()> {
         time_low, time_mid, time_hi_and_version, clock_seq_and_node
     )?;
 
+    let mut aarch64_flag = true;
+    match env::var("TARGET") {
+        Ok(ref v) if v == "arm-unknown-linux-gnueabihf" => {
+            println!("cargo:rustc-link-arg=--no-warn-mismatch");
+            aarch64_flag = false;
+        },
+        _ => {}
+    };
+
     let optee_os_dir = env::var("TA_DEV_KIT_DIR").unwrap();
     let search_path = Path::new(&optee_os_dir).join("lib");
 
@@ -51,39 +60,30 @@ fn main() -> std::io::Result<()> {
     let f = File::open(optee_os_path.join("src/ta.ld.S"))?;
     let f = BufReader::new(f);
 
-    match env::var("TARGET") {
-        Ok(ref v) if v == "arm-unknown-linux-gnueabihf" => {
-            println!("cargo:rustc-link-arg=--no-warn-mismatch");
-            for line in f.lines() {
-                let l = line?;
+    for line in f.lines() {
+        let l = line?;
 
-                if l.starts_with('#') ||
-                   l == "OUTPUT_FORMAT(\"elf64-littleaarch64\")" ||
-                   l == "OUTPUT_ARCH(aarch64)" {
-                    continue;
-                }
-
-                write!(ta_lds, "{}\n", l)?;
+        if aarch64_flag {
+            if l.starts_with('#') ||
+                l == "OUTPUT_FORMAT(\"elf32-littlearm\")" ||
+                l == "OUTPUT_ARCH(arm)" {
+                continue;
             }
-        },
-        _ => {
-            for line in f.lines() {
-                let l = line?;
-
-                if l.starts_with('#') ||
-                   l == "OUTPUT_FORMAT(\"elf32-littlearm\")" ||
-                   l == "OUTPUT_ARCH(arm)" {
-                    continue;
-                }
-
-                if l == "\t. = ALIGN(4096);" {
-                    write!(ta_lds, "\t. = ALIGN(65536);\n")?;
-                } else {
-                    write!(ta_lds, "{}\n", l)?;
-                }
+        } else {
+            if l.starts_with('#') ||
+                l == "OUTPUT_FORMAT(\"elf64-littleaarch64\")" ||
+                l == "OUTPUT_ARCH(aarch64)" {
+                continue;
             }
         }
-    };
+
+        if l == "\t. = ALIGN(4096);" {
+            write!(ta_lds, "\t. = ALIGN(65536);\n")?;
+        } else {
+            write!(ta_lds, "{}\n", l)?;
+        }
+    }
+
     println!("cargo:rustc-link-search={}", out.display());
     println!("cargo:rerun-if-changed=ta.lds");
 
diff --git a/examples/big_int-rs/ta/build.rs b/examples/big_int-rs/ta/build.rs
index 19aae62..5618f03 100644
--- a/examples/big_int-rs/ta/build.rs
+++ b/examples/big_int-rs/ta/build.rs
@@ -43,6 +43,15 @@ fn main() -> std::io::Result<()> {
         time_low, time_mid, time_hi_and_version, clock_seq_and_node
     )?;
 
+    let mut aarch64_flag = true;
+    match env::var("TARGET") {
+        Ok(ref v) if v == "arm-unknown-linux-gnueabihf" => {
+            println!("cargo:rustc-link-arg=--no-warn-mismatch");
+            aarch64_flag = false;
+        },
+        _ => {}
+    };
+
     let optee_os_dir = env::var("TA_DEV_KIT_DIR").unwrap();
     let search_path = Path::new(&optee_os_dir).join("lib");
 
@@ -51,39 +60,30 @@ fn main() -> std::io::Result<()> {
     let f = File::open(optee_os_path.join("src/ta.ld.S"))?;
     let f = BufReader::new(f);
 
-    match env::var("TARGET") {
-        Ok(ref v) if v == "arm-unknown-linux-gnueabihf" => {
-            println!("cargo:rustc-link-arg=--no-warn-mismatch");
-            for line in f.lines() {
-                let l = line?;
+    for line in f.lines() {
+        let l = line?;
 
-                if l.starts_with('#') ||
-                   l == "OUTPUT_FORMAT(\"elf64-littleaarch64\")" ||
-                   l == "OUTPUT_ARCH(aarch64)" {
-                    continue;
-                }
-
-                write!(ta_lds, "{}\n", l)?;
+        if aarch64_flag {
+            if l.starts_with('#') ||
+                l == "OUTPUT_FORMAT(\"elf32-littlearm\")" ||
+                l == "OUTPUT_ARCH(arm)" {
+                continue;
             }
-        },
-        _ => {
-            for line in f.lines() {
-                let l = line?;
-
-                if l.starts_with('#') ||
-                   l == "OUTPUT_FORMAT(\"elf32-littlearm\")" ||
-                   l == "OUTPUT_ARCH(arm)" {
-                    continue;
-                }
-
-                if l == "\t. = ALIGN(4096);" {
-                    write!(ta_lds, "\t. = ALIGN(65536);\n")?;
-                } else {
-                    write!(ta_lds, "{}\n", l)?;
-                }
+        } else {
+            if l.starts_with('#') ||
+                l == "OUTPUT_FORMAT(\"elf64-littleaarch64\")" ||
+                l == "OUTPUT_ARCH(aarch64)" {
+                continue;
             }
         }
-    };
+
+        if l == "\t. = ALIGN(4096);" {
+            write!(ta_lds, "\t. = ALIGN(65536);\n")?;
+        } else {
+            write!(ta_lds, "{}\n", l)?;
+        }
+    }
+
     println!("cargo:rustc-link-search={}", out.display());
     println!("cargo:rerun-if-changed=ta.lds");
 
diff --git a/examples/diffie_hellman-rs/ta/build.rs 
b/examples/diffie_hellman-rs/ta/build.rs
index 19aae62..5618f03 100644
--- a/examples/diffie_hellman-rs/ta/build.rs
+++ b/examples/diffie_hellman-rs/ta/build.rs
@@ -43,6 +43,15 @@ fn main() -> std::io::Result<()> {
         time_low, time_mid, time_hi_and_version, clock_seq_and_node
     )?;
 
+    let mut aarch64_flag = true;
+    match env::var("TARGET") {
+        Ok(ref v) if v == "arm-unknown-linux-gnueabihf" => {
+            println!("cargo:rustc-link-arg=--no-warn-mismatch");
+            aarch64_flag = false;
+        },
+        _ => {}
+    };
+
     let optee_os_dir = env::var("TA_DEV_KIT_DIR").unwrap();
     let search_path = Path::new(&optee_os_dir).join("lib");
 
@@ -51,39 +60,30 @@ fn main() -> std::io::Result<()> {
     let f = File::open(optee_os_path.join("src/ta.ld.S"))?;
     let f = BufReader::new(f);
 
-    match env::var("TARGET") {
-        Ok(ref v) if v == "arm-unknown-linux-gnueabihf" => {
-            println!("cargo:rustc-link-arg=--no-warn-mismatch");
-            for line in f.lines() {
-                let l = line?;
+    for line in f.lines() {
+        let l = line?;
 
-                if l.starts_with('#') ||
-                   l == "OUTPUT_FORMAT(\"elf64-littleaarch64\")" ||
-                   l == "OUTPUT_ARCH(aarch64)" {
-                    continue;
-                }
-
-                write!(ta_lds, "{}\n", l)?;
+        if aarch64_flag {
+            if l.starts_with('#') ||
+                l == "OUTPUT_FORMAT(\"elf32-littlearm\")" ||
+                l == "OUTPUT_ARCH(arm)" {
+                continue;
             }
-        },
-        _ => {
-            for line in f.lines() {
-                let l = line?;
-
-                if l.starts_with('#') ||
-                   l == "OUTPUT_FORMAT(\"elf32-littlearm\")" ||
-                   l == "OUTPUT_ARCH(arm)" {
-                    continue;
-                }
-
-                if l == "\t. = ALIGN(4096);" {
-                    write!(ta_lds, "\t. = ALIGN(65536);\n")?;
-                } else {
-                    write!(ta_lds, "{}\n", l)?;
-                }
+        } else {
+            if l.starts_with('#') ||
+                l == "OUTPUT_FORMAT(\"elf64-littleaarch64\")" ||
+                l == "OUTPUT_ARCH(aarch64)" {
+                continue;
             }
         }
-    };
+
+        if l == "\t. = ALIGN(4096);" {
+            write!(ta_lds, "\t. = ALIGN(65536);\n")?;
+        } else {
+            write!(ta_lds, "{}\n", l)?;
+        }
+    }
+
     println!("cargo:rustc-link-search={}", out.display());
     println!("cargo:rerun-if-changed=ta.lds");
 
diff --git a/examples/digest-rs/ta/build.rs b/examples/digest-rs/ta/build.rs
index 19aae62..5618f03 100644
--- a/examples/digest-rs/ta/build.rs
+++ b/examples/digest-rs/ta/build.rs
@@ -43,6 +43,15 @@ fn main() -> std::io::Result<()> {
         time_low, time_mid, time_hi_and_version, clock_seq_and_node
     )?;
 
+    let mut aarch64_flag = true;
+    match env::var("TARGET") {
+        Ok(ref v) if v == "arm-unknown-linux-gnueabihf" => {
+            println!("cargo:rustc-link-arg=--no-warn-mismatch");
+            aarch64_flag = false;
+        },
+        _ => {}
+    };
+
     let optee_os_dir = env::var("TA_DEV_KIT_DIR").unwrap();
     let search_path = Path::new(&optee_os_dir).join("lib");
 
@@ -51,39 +60,30 @@ fn main() -> std::io::Result<()> {
     let f = File::open(optee_os_path.join("src/ta.ld.S"))?;
     let f = BufReader::new(f);
 
-    match env::var("TARGET") {
-        Ok(ref v) if v == "arm-unknown-linux-gnueabihf" => {
-            println!("cargo:rustc-link-arg=--no-warn-mismatch");
-            for line in f.lines() {
-                let l = line?;
+    for line in f.lines() {
+        let l = line?;
 
-                if l.starts_with('#') ||
-                   l == "OUTPUT_FORMAT(\"elf64-littleaarch64\")" ||
-                   l == "OUTPUT_ARCH(aarch64)" {
-                    continue;
-                }
-
-                write!(ta_lds, "{}\n", l)?;
+        if aarch64_flag {
+            if l.starts_with('#') ||
+                l == "OUTPUT_FORMAT(\"elf32-littlearm\")" ||
+                l == "OUTPUT_ARCH(arm)" {
+                continue;
             }
-        },
-        _ => {
-            for line in f.lines() {
-                let l = line?;
-
-                if l.starts_with('#') ||
-                   l == "OUTPUT_FORMAT(\"elf32-littlearm\")" ||
-                   l == "OUTPUT_ARCH(arm)" {
-                    continue;
-                }
-
-                if l == "\t. = ALIGN(4096);" {
-                    write!(ta_lds, "\t. = ALIGN(65536);\n")?;
-                } else {
-                    write!(ta_lds, "{}\n", l)?;
-                }
+        } else {
+            if l.starts_with('#') ||
+                l == "OUTPUT_FORMAT(\"elf64-littleaarch64\")" ||
+                l == "OUTPUT_ARCH(aarch64)" {
+                continue;
             }
         }
-    };
+
+        if l == "\t. = ALIGN(4096);" {
+            write!(ta_lds, "\t. = ALIGN(65536);\n")?;
+        } else {
+            write!(ta_lds, "{}\n", l)?;
+        }
+    }
+
     println!("cargo:rustc-link-search={}", out.display());
     println!("cargo:rerun-if-changed=ta.lds");
 
diff --git a/examples/hello_world-rs/ta/build.rs 
b/examples/hello_world-rs/ta/build.rs
index 19aae62..5618f03 100644
--- a/examples/hello_world-rs/ta/build.rs
+++ b/examples/hello_world-rs/ta/build.rs
@@ -43,6 +43,15 @@ fn main() -> std::io::Result<()> {
         time_low, time_mid, time_hi_and_version, clock_seq_and_node
     )?;
 
+    let mut aarch64_flag = true;
+    match env::var("TARGET") {
+        Ok(ref v) if v == "arm-unknown-linux-gnueabihf" => {
+            println!("cargo:rustc-link-arg=--no-warn-mismatch");
+            aarch64_flag = false;
+        },
+        _ => {}
+    };
+
     let optee_os_dir = env::var("TA_DEV_KIT_DIR").unwrap();
     let search_path = Path::new(&optee_os_dir).join("lib");
 
@@ -51,39 +60,30 @@ fn main() -> std::io::Result<()> {
     let f = File::open(optee_os_path.join("src/ta.ld.S"))?;
     let f = BufReader::new(f);
 
-    match env::var("TARGET") {
-        Ok(ref v) if v == "arm-unknown-linux-gnueabihf" => {
-            println!("cargo:rustc-link-arg=--no-warn-mismatch");
-            for line in f.lines() {
-                let l = line?;
+    for line in f.lines() {
+        let l = line?;
 
-                if l.starts_with('#') ||
-                   l == "OUTPUT_FORMAT(\"elf64-littleaarch64\")" ||
-                   l == "OUTPUT_ARCH(aarch64)" {
-                    continue;
-                }
-
-                write!(ta_lds, "{}\n", l)?;
+        if aarch64_flag {
+            if l.starts_with('#') ||
+                l == "OUTPUT_FORMAT(\"elf32-littlearm\")" ||
+                l == "OUTPUT_ARCH(arm)" {
+                continue;
             }
-        },
-        _ => {
-            for line in f.lines() {
-                let l = line?;
-
-                if l.starts_with('#') ||
-                   l == "OUTPUT_FORMAT(\"elf32-littlearm\")" ||
-                   l == "OUTPUT_ARCH(arm)" {
-                    continue;
-                }
-
-                if l == "\t. = ALIGN(4096);" {
-                    write!(ta_lds, "\t. = ALIGN(65536);\n")?;
-                } else {
-                    write!(ta_lds, "{}\n", l)?;
-                }
+        } else {
+            if l.starts_with('#') ||
+                l == "OUTPUT_FORMAT(\"elf64-littleaarch64\")" ||
+                l == "OUTPUT_ARCH(aarch64)" {
+                continue;
             }
         }
-    };
+
+        if l == "\t. = ALIGN(4096);" {
+            write!(ta_lds, "\t. = ALIGN(65536);\n")?;
+        } else {
+            write!(ta_lds, "{}\n", l)?;
+        }
+    }
+
     println!("cargo:rustc-link-search={}", out.display());
     println!("cargo:rerun-if-changed=ta.lds");
 
diff --git a/examples/hotp-rs/ta/build.rs b/examples/hotp-rs/ta/build.rs
index 19aae62..5618f03 100644
--- a/examples/hotp-rs/ta/build.rs
+++ b/examples/hotp-rs/ta/build.rs
@@ -43,6 +43,15 @@ fn main() -> std::io::Result<()> {
         time_low, time_mid, time_hi_and_version, clock_seq_and_node
     )?;
 
+    let mut aarch64_flag = true;
+    match env::var("TARGET") {
+        Ok(ref v) if v == "arm-unknown-linux-gnueabihf" => {
+            println!("cargo:rustc-link-arg=--no-warn-mismatch");
+            aarch64_flag = false;
+        },
+        _ => {}
+    };
+
     let optee_os_dir = env::var("TA_DEV_KIT_DIR").unwrap();
     let search_path = Path::new(&optee_os_dir).join("lib");
 
@@ -51,39 +60,30 @@ fn main() -> std::io::Result<()> {
     let f = File::open(optee_os_path.join("src/ta.ld.S"))?;
     let f = BufReader::new(f);
 
-    match env::var("TARGET") {
-        Ok(ref v) if v == "arm-unknown-linux-gnueabihf" => {
-            println!("cargo:rustc-link-arg=--no-warn-mismatch");
-            for line in f.lines() {
-                let l = line?;
+    for line in f.lines() {
+        let l = line?;
 
-                if l.starts_with('#') ||
-                   l == "OUTPUT_FORMAT(\"elf64-littleaarch64\")" ||
-                   l == "OUTPUT_ARCH(aarch64)" {
-                    continue;
-                }
-
-                write!(ta_lds, "{}\n", l)?;
+        if aarch64_flag {
+            if l.starts_with('#') ||
+                l == "OUTPUT_FORMAT(\"elf32-littlearm\")" ||
+                l == "OUTPUT_ARCH(arm)" {
+                continue;
             }
-        },
-        _ => {
-            for line in f.lines() {
-                let l = line?;
-
-                if l.starts_with('#') ||
-                   l == "OUTPUT_FORMAT(\"elf32-littlearm\")" ||
-                   l == "OUTPUT_ARCH(arm)" {
-                    continue;
-                }
-
-                if l == "\t. = ALIGN(4096);" {
-                    write!(ta_lds, "\t. = ALIGN(65536);\n")?;
-                } else {
-                    write!(ta_lds, "{}\n", l)?;
-                }
+        } else {
+            if l.starts_with('#') ||
+                l == "OUTPUT_FORMAT(\"elf64-littleaarch64\")" ||
+                l == "OUTPUT_ARCH(aarch64)" {
+                continue;
             }
         }
-    };
+
+        if l == "\t. = ALIGN(4096);" {
+            write!(ta_lds, "\t. = ALIGN(65536);\n")?;
+        } else {
+            write!(ta_lds, "{}\n", l)?;
+        }
+    }
+
     println!("cargo:rustc-link-search={}", out.display());
     println!("cargo:rerun-if-changed=ta.lds");
 
diff --git a/examples/random-rs/ta/build.rs b/examples/random-rs/ta/build.rs
index 19aae62..5618f03 100644
--- a/examples/random-rs/ta/build.rs
+++ b/examples/random-rs/ta/build.rs
@@ -43,6 +43,15 @@ fn main() -> std::io::Result<()> {
         time_low, time_mid, time_hi_and_version, clock_seq_and_node
     )?;
 
+    let mut aarch64_flag = true;
+    match env::var("TARGET") {
+        Ok(ref v) if v == "arm-unknown-linux-gnueabihf" => {
+            println!("cargo:rustc-link-arg=--no-warn-mismatch");
+            aarch64_flag = false;
+        },
+        _ => {}
+    };
+
     let optee_os_dir = env::var("TA_DEV_KIT_DIR").unwrap();
     let search_path = Path::new(&optee_os_dir).join("lib");
 
@@ -51,39 +60,30 @@ fn main() -> std::io::Result<()> {
     let f = File::open(optee_os_path.join("src/ta.ld.S"))?;
     let f = BufReader::new(f);
 
-    match env::var("TARGET") {
-        Ok(ref v) if v == "arm-unknown-linux-gnueabihf" => {
-            println!("cargo:rustc-link-arg=--no-warn-mismatch");
-            for line in f.lines() {
-                let l = line?;
+    for line in f.lines() {
+        let l = line?;
 
-                if l.starts_with('#') ||
-                   l == "OUTPUT_FORMAT(\"elf64-littleaarch64\")" ||
-                   l == "OUTPUT_ARCH(aarch64)" {
-                    continue;
-                }
-
-                write!(ta_lds, "{}\n", l)?;
+        if aarch64_flag {
+            if l.starts_with('#') ||
+                l == "OUTPUT_FORMAT(\"elf32-littlearm\")" ||
+                l == "OUTPUT_ARCH(arm)" {
+                continue;
             }
-        },
-        _ => {
-            for line in f.lines() {
-                let l = line?;
-
-                if l.starts_with('#') ||
-                   l == "OUTPUT_FORMAT(\"elf32-littlearm\")" ||
-                   l == "OUTPUT_ARCH(arm)" {
-                    continue;
-                }
-
-                if l == "\t. = ALIGN(4096);" {
-                    write!(ta_lds, "\t. = ALIGN(65536);\n")?;
-                } else {
-                    write!(ta_lds, "{}\n", l)?;
-                }
+        } else {
+            if l.starts_with('#') ||
+                l == "OUTPUT_FORMAT(\"elf64-littleaarch64\")" ||
+                l == "OUTPUT_ARCH(aarch64)" {
+                continue;
             }
         }
-    };
+
+        if l == "\t. = ALIGN(4096);" {
+            write!(ta_lds, "\t. = ALIGN(65536);\n")?;
+        } else {
+            write!(ta_lds, "{}\n", l)?;
+        }
+    }
+
     println!("cargo:rustc-link-search={}", out.display());
     println!("cargo:rerun-if-changed=ta.lds");
 
diff --git a/examples/secure_storage-rs/ta/build.rs 
b/examples/secure_storage-rs/ta/build.rs
index 19aae62..5618f03 100644
--- a/examples/secure_storage-rs/ta/build.rs
+++ b/examples/secure_storage-rs/ta/build.rs
@@ -43,6 +43,15 @@ fn main() -> std::io::Result<()> {
         time_low, time_mid, time_hi_and_version, clock_seq_and_node
     )?;
 
+    let mut aarch64_flag = true;
+    match env::var("TARGET") {
+        Ok(ref v) if v == "arm-unknown-linux-gnueabihf" => {
+            println!("cargo:rustc-link-arg=--no-warn-mismatch");
+            aarch64_flag = false;
+        },
+        _ => {}
+    };
+
     let optee_os_dir = env::var("TA_DEV_KIT_DIR").unwrap();
     let search_path = Path::new(&optee_os_dir).join("lib");
 
@@ -51,39 +60,30 @@ fn main() -> std::io::Result<()> {
     let f = File::open(optee_os_path.join("src/ta.ld.S"))?;
     let f = BufReader::new(f);
 
-    match env::var("TARGET") {
-        Ok(ref v) if v == "arm-unknown-linux-gnueabihf" => {
-            println!("cargo:rustc-link-arg=--no-warn-mismatch");
-            for line in f.lines() {
-                let l = line?;
+    for line in f.lines() {
+        let l = line?;
 
-                if l.starts_with('#') ||
-                   l == "OUTPUT_FORMAT(\"elf64-littleaarch64\")" ||
-                   l == "OUTPUT_ARCH(aarch64)" {
-                    continue;
-                }
-
-                write!(ta_lds, "{}\n", l)?;
+        if aarch64_flag {
+            if l.starts_with('#') ||
+                l == "OUTPUT_FORMAT(\"elf32-littlearm\")" ||
+                l == "OUTPUT_ARCH(arm)" {
+                continue;
             }
-        },
-        _ => {
-            for line in f.lines() {
-                let l = line?;
-
-                if l.starts_with('#') ||
-                   l == "OUTPUT_FORMAT(\"elf32-littlearm\")" ||
-                   l == "OUTPUT_ARCH(arm)" {
-                    continue;
-                }
-
-                if l == "\t. = ALIGN(4096);" {
-                    write!(ta_lds, "\t. = ALIGN(65536);\n")?;
-                } else {
-                    write!(ta_lds, "{}\n", l)?;
-                }
+        } else {
+            if l.starts_with('#') ||
+                l == "OUTPUT_FORMAT(\"elf64-littleaarch64\")" ||
+                l == "OUTPUT_ARCH(aarch64)" {
+                continue;
             }
         }
-    };
+
+        if l == "\t. = ALIGN(4096);" {
+            write!(ta_lds, "\t. = ALIGN(65536);\n")?;
+        } else {
+            write!(ta_lds, "{}\n", l)?;
+        }
+    }
+
     println!("cargo:rustc-link-search={}", out.display());
     println!("cargo:rerun-if-changed=ta.lds");
 
diff --git a/examples/signature_verification-rs/ta/build.rs 
b/examples/signature_verification-rs/ta/build.rs
index 19aae62..5618f03 100644
--- a/examples/signature_verification-rs/ta/build.rs
+++ b/examples/signature_verification-rs/ta/build.rs
@@ -43,6 +43,15 @@ fn main() -> std::io::Result<()> {
         time_low, time_mid, time_hi_and_version, clock_seq_and_node
     )?;
 
+    let mut aarch64_flag = true;
+    match env::var("TARGET") {
+        Ok(ref v) if v == "arm-unknown-linux-gnueabihf" => {
+            println!("cargo:rustc-link-arg=--no-warn-mismatch");
+            aarch64_flag = false;
+        },
+        _ => {}
+    };
+
     let optee_os_dir = env::var("TA_DEV_KIT_DIR").unwrap();
     let search_path = Path::new(&optee_os_dir).join("lib");
 
@@ -51,39 +60,30 @@ fn main() -> std::io::Result<()> {
     let f = File::open(optee_os_path.join("src/ta.ld.S"))?;
     let f = BufReader::new(f);
 
-    match env::var("TARGET") {
-        Ok(ref v) if v == "arm-unknown-linux-gnueabihf" => {
-            println!("cargo:rustc-link-arg=--no-warn-mismatch");
-            for line in f.lines() {
-                let l = line?;
+    for line in f.lines() {
+        let l = line?;
 
-                if l.starts_with('#') ||
-                   l == "OUTPUT_FORMAT(\"elf64-littleaarch64\")" ||
-                   l == "OUTPUT_ARCH(aarch64)" {
-                    continue;
-                }
-
-                write!(ta_lds, "{}\n", l)?;
+        if aarch64_flag {
+            if l.starts_with('#') ||
+                l == "OUTPUT_FORMAT(\"elf32-littlearm\")" ||
+                l == "OUTPUT_ARCH(arm)" {
+                continue;
             }
-        },
-        _ => {
-            for line in f.lines() {
-                let l = line?;
-
-                if l.starts_with('#') ||
-                   l == "OUTPUT_FORMAT(\"elf32-littlearm\")" ||
-                   l == "OUTPUT_ARCH(arm)" {
-                    continue;
-                }
-
-                if l == "\t. = ALIGN(4096);" {
-                    write!(ta_lds, "\t. = ALIGN(65536);\n")?;
-                } else {
-                    write!(ta_lds, "{}\n", l)?;
-                }
+        } else {
+            if l.starts_with('#') ||
+                l == "OUTPUT_FORMAT(\"elf64-littleaarch64\")" ||
+                l == "OUTPUT_ARCH(aarch64)" {
+                continue;
             }
         }
-    };
+
+        if l == "\t. = ALIGN(4096);" {
+            write!(ta_lds, "\t. = ALIGN(65536);\n")?;
+        } else {
+            write!(ta_lds, "{}\n", l)?;
+        }
+    }
+
     println!("cargo:rustc-link-search={}", out.display());
     println!("cargo:rerun-if-changed=ta.lds");
 
diff --git a/examples/supp_plugin-rs/ta/build.rs 
b/examples/supp_plugin-rs/ta/build.rs
index 12d8660..be2c872 100644
--- a/examples/supp_plugin-rs/ta/build.rs
+++ b/examples/supp_plugin-rs/ta/build.rs
@@ -43,6 +43,15 @@ fn main() -> std::io::Result<()> {
         time_low, time_mid, time_hi_and_version, clock_seq_and_node
     )?;
 
+    let mut aarch64_flag = true;
+    match env::var("TARGET") {
+        Ok(ref v) if v == "arm-unknown-linux-gnueabihf" => {
+            println!("cargo:rustc-link-arg=--no-warn-mismatch");
+            aarch64_flag = false;
+        },
+        _ => {}
+    };
+
     let optee_os_dir = env::var("TA_DEV_KIT_DIR").unwrap();
     let search_path = Path::new(&optee_os_dir).join("lib");
 
@@ -51,39 +60,30 @@ fn main() -> std::io::Result<()> {
     let f = File::open(optee_os_path.join("src/ta.ld.S"))?;
     let f = BufReader::new(f);
 
-    match env::var("TARGET") {
-        Ok(ref v) if v == "arm-unknown-linux-gnueabihf" => {
-            println!("cargo:rustc-link-arg=--no-warn-mismatch");
-            for line in f.lines() {
-                let l = line?;
+    for line in f.lines() {
+        let l = line?;
 
-                if l.starts_with('#') ||
-                   l == "OUTPUT_FORMAT(\"elf64-littleaarch64\")" ||
-                   l == "OUTPUT_ARCH(aarch64)" {
-                    continue;
-                }
-
-                write!(ta_lds, "{}\n", l)?;
+        if aarch64_flag {
+            if l.starts_with('#') ||
+                l == "OUTPUT_FORMAT(\"elf32-littlearm\")" ||
+                l == "OUTPUT_ARCH(arm)" {
+                continue;
             }
-        },
-        _ => {
-            for line in f.lines() {
-                let l = line?;
-
-                if l.starts_with('#') ||
-                   l == "OUTPUT_FORMAT(\"elf32-littlearm\")" ||
-                   l == "OUTPUT_ARCH(arm)" {
-                    continue;
-                }
-
-                if l == "\t. = ALIGN(4096);" {
-                    write!(ta_lds, "\t. = ALIGN(65536);\n")?;
-                } else {
-                    write!(ta_lds, "{}\n", l)?;
-                }
+        } else {
+            if l.starts_with('#') ||
+                l == "OUTPUT_FORMAT(\"elf64-littleaarch64\")" ||
+                l == "OUTPUT_ARCH(aarch64)" {
+                continue;
             }
         }
-    };
+
+        if l == "\t. = ALIGN(4096);" {
+            write!(ta_lds, "\t. = ALIGN(65536);\n")?;
+        } else {
+            write!(ta_lds, "{}\n", l)?;
+        }
+    }
+
     println!("cargo:rustc-link-search={}", out.display());
     println!("cargo:rerun-if-changed=ta.lds");
 
diff --git a/examples/time-rs/ta/build.rs b/examples/time-rs/ta/build.rs
index 19aae62..5618f03 100644
--- a/examples/time-rs/ta/build.rs
+++ b/examples/time-rs/ta/build.rs
@@ -43,6 +43,15 @@ fn main() -> std::io::Result<()> {
         time_low, time_mid, time_hi_and_version, clock_seq_and_node
     )?;
 
+    let mut aarch64_flag = true;
+    match env::var("TARGET") {
+        Ok(ref v) if v == "arm-unknown-linux-gnueabihf" => {
+            println!("cargo:rustc-link-arg=--no-warn-mismatch");
+            aarch64_flag = false;
+        },
+        _ => {}
+    };
+
     let optee_os_dir = env::var("TA_DEV_KIT_DIR").unwrap();
     let search_path = Path::new(&optee_os_dir).join("lib");
 
@@ -51,39 +60,30 @@ fn main() -> std::io::Result<()> {
     let f = File::open(optee_os_path.join("src/ta.ld.S"))?;
     let f = BufReader::new(f);
 
-    match env::var("TARGET") {
-        Ok(ref v) if v == "arm-unknown-linux-gnueabihf" => {
-            println!("cargo:rustc-link-arg=--no-warn-mismatch");
-            for line in f.lines() {
-                let l = line?;
+    for line in f.lines() {
+        let l = line?;
 
-                if l.starts_with('#') ||
-                   l == "OUTPUT_FORMAT(\"elf64-littleaarch64\")" ||
-                   l == "OUTPUT_ARCH(aarch64)" {
-                    continue;
-                }
-
-                write!(ta_lds, "{}\n", l)?;
+        if aarch64_flag {
+            if l.starts_with('#') ||
+                l == "OUTPUT_FORMAT(\"elf32-littlearm\")" ||
+                l == "OUTPUT_ARCH(arm)" {
+                continue;
             }
-        },
-        _ => {
-            for line in f.lines() {
-                let l = line?;
-
-                if l.starts_with('#') ||
-                   l == "OUTPUT_FORMAT(\"elf32-littlearm\")" ||
-                   l == "OUTPUT_ARCH(arm)" {
-                    continue;
-                }
-
-                if l == "\t. = ALIGN(4096);" {
-                    write!(ta_lds, "\t. = ALIGN(65536);\n")?;
-                } else {
-                    write!(ta_lds, "{}\n", l)?;
-                }
+        } else {
+            if l.starts_with('#') ||
+                l == "OUTPUT_FORMAT(\"elf64-littleaarch64\")" ||
+                l == "OUTPUT_ARCH(aarch64)" {
+                continue;
             }
         }
-    };
+
+        if l == "\t. = ALIGN(4096);" {
+            write!(ta_lds, "\t. = ALIGN(65536);\n")?;
+        } else {
+            write!(ta_lds, "{}\n", l)?;
+        }
+    }
+
     println!("cargo:rustc-link-search={}", out.display());
     println!("cargo:rerun-if-changed=ta.lds");
 


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


Reply via email to