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
```
This commit is contained in:
Wenyong Huang 2023-11-16 10:54:39 +08:00 committed by GitHub
parent 24aa1cb408
commit 9a32e0672c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)) { else if (is_baremetal_target(arch, cpu, abi)) {
vendor_sys = "-unknown-none-"; vendor_sys = "-unknown-none-";
if (!abi)
abi = "gnu";
} }
else { else {
vendor_sys = "-pc-linux-"; vendor_sys = "-pc-linux-";