0

编译器:https ://releases.linaro.org/components/toolchain/binaries/7.5-2019.12/arm-eabi/gcc-linaro-7.5.0-2019.12-x86_64_arm-eabi.tar.xz

测试.c:

struct Foo{
    char a[32]; // 32 and above will produce warning, but 31 and below will not
    char d[9]; // 9 and above will produce warning, but 8 and below will not
};

int main()
{
    struct Foo foo = {0};
    (void)(foo);
    return 0;
}

编译命令和警告:

$ arm-eabi-gcc -Wstack-protector -fstack-protector-all -fstack-check -o test test.c
test.c: In function ‘main’:
test.c:6:5: warning: stack protector not protecting local variables: variable length buffer [-Wstack-protector]
 int main()
     ^~~~

我的源代码中的结构类似于Foo上面显示的源代码,它无法更改,因此我可以用 main 函数做什么来解决警告?

任何帮助将非常感激!

4

0 回答 0