1

我正在使用带有 arm trust-zone 的 Cortex-M33。我的安全固件中有一个安全 api,我可以从我的非安全固件中调用它。一切都按预期工作-至少在我将编译器从升级gcc-arm-none-eabi-7-2018-q2-updategcc-arm-none-eabi-10-2020-q4-major.

有问题的函数如下所示:

bool __attribute__((cmse_nonsecure_call)) (*Callback_Handler)();

__unused __attribute__((cmse_nonsecure_entry))
bool Secure_SetSomeCallbackHandler(bool (*handler)()) {
    // this cmse-check fails with the compiler in `version gcc-arm-none-eabi-10-2020-q4-major`
    // it works with the `gcc-arm-none-eabi-7-2018-q2-update` though
    handler = cmse_check_address_range(handler, 4, CMSE_NONSECURE);
    if (handler == NULL) {
        return false;
    }
    Callback_Handler = handler;
    return true;
}

我通过使用确保提供的指针确实位于非安全空间中cmse_check_address_range。这适用于版本 7,但如果我使用版本 10 编译代码,NULL则会返回。我没有更改源代码或任何其他部分的任何内容,只是编译器。

我检查了该功能的任何更改,但甚至https://github.com/gcc-mirror/gcc/commits/master/libgcc/config/arm/cmse.c没有显示任何更改。

有什么改变吗?也许我没有按预期使用该功能(我需要不同的功能标志吗?但话又说回来,它适用于版本 7。

更新:

4

1 回答 1

2

当 libgcc 检查 CMSE 支持时,这似乎是一个 GCC 错误。

它检查 $? 对于 gcc 命令的返回值,但在 Makefile 中它应该使用 $$? 反而。

diff --git a/libgcc/config/arm/t-arm b/libgcc/config/arm/t-arm
index 364f40ebe7f9..3625a2590bee 100644
--- a/libgcc/config/arm/t-arm
+++ b/libgcc/config/arm/t-arm
@@ -4,7 +4,7 @@ LIB1ASMFUNCS = _thumb1_case_sqi _thumb1_case_uqi _thumb1_case_shi \

 HAVE_CMSE:=$(findstring __ARM_FEATURE_CMSE,$(shell $(gcc_compile_bare) -dM -E - </dev/null))
 HAVE_V81M:=$(findstring armv8.1-m.main,$(gcc_compile_bare))
-ifeq ($(shell $(gcc_compile_bare) -E -mcmse - </dev/null >/dev/null 2>/dev/null; echo $?),0)
+ifeq ($(shell $(gcc_compile_bare) -E -mcmse - </dev/null >/dev/null 2>/dev/null; echo $$?),0)
 CMSE_OPTS:=-mcmse
 endif

我已经报告了这个错误:
https ://gcc.gnu.org/bugzilla/show_bug.cgi?id=99157

于 2021-02-19T07:51:55.860 回答