From 9a32e0672cfd0cb0ff6dbef441151671c9799503 Mon Sep 17 00:00:00 2001 From: Wenyong Huang Date: Thu, 16 Nov 2023 10:54:39 +0800 Subject: [PATCH] Fix aot compiler issue reported by Coverity (#2770) Set `abi` to "gnu" for the bare-metal target when `abi` is NULL, or the below `bh_assert` and `bh_memcpy` may deference a NULL pointer. Error is reported when running wamrc compiled with `cmake .. -DCMAKE_BUILD_TYPE=Debug`: ``` core/iwasm/compilation/aot_llvm.c:2584:13: runtime error: null pointer passed as argument 1, which is declared to never be null ``` --- core/iwasm/compilation/aot_llvm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/iwasm/compilation/aot_llvm.c b/core/iwasm/compilation/aot_llvm.c index f3fd03927..41d6e5a81 100644 --- a/core/iwasm/compilation/aot_llvm.c +++ b/core/iwasm/compilation/aot_llvm.c @@ -2572,6 +2572,8 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option) } else if (is_baremetal_target(arch, cpu, abi)) { vendor_sys = "-unknown-none-"; + if (!abi) + abi = "gnu"; } else { vendor_sys = "-pc-linux-";