{"id":550261,"date":"2021-12-24T11:17:39","date_gmt":"2021-12-24T03:17:39","guid":{"rendered":"http:\/\/4563.org\/?p=550261"},"modified":"2021-12-24T11:17:39","modified_gmt":"2021-12-24T03:17:39","slug":"%e8%af%b7%e6%95%99%e5%90%84%e4%bd%8d%ef%bc%8c%e5%a6%82%e4%bd%95%e8%a7%a3%e5%86%b3-warning-stack-protector-not-protecting-local-variables-variable-length-buffer","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=550261","title":{"rendered":"\u8bf7\u6559\u5404\u4f4d\uff0c\u5982\u4f55\u89e3\u51b3 warning: stack protector not protecting local variables: variable length buffer"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1> \u8bf7\u6559\u5404\u4f4d\uff0c\u5982\u4f55\u89e3\u51b3 warning: stack protector not protecting local variables: variable length buffer <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : fenglala <\/span>  <span><i><\/i> 30<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u7f16\u8bd1\u5668: 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<\/p>\n<p>test.c:<\/p>\n<pre><code>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; } <\/code><\/pre>\n<p>\u7f16\u8bd1\u547d\u4ee4\u53ca\u8f93\u51fa\uff1a<\/p>\n<pre><code>$ arm-eabi-gcc -Wstack-protector -fstack-protector-all -fstack-check -o test test.c test.c: In function \u2018main\u2019: test.c:6:5: warning: stack protector not protecting local variables: variable length buffer [-Wstack-protector]  int main()      ^~~~ <\/code><\/pre>\n<p>\u5b9e\u9645\u4ee3\u7801\u4e2d\u7684\u7ed3\u6784\u4f53\u7c7b\u4f3c\u4e0a\u6587\u7684 Foo \uff0c\u6211\u4e0d\u80fd\u6539\uff0c\u4f46\u662f main \u6211\u53ef\u4ee5\u6539\uff0c\u8bf7\u95ee\u600e\u4e48\u6539 main \u80fd\u89e3\u51b3\u8fd9\u4e2a warning \uff1f<\/p>\n<p>\u611f\u8c22\u5404\u4f4d\uff01<\/p>\n<p>\u5404\u4f4d\u4e5f\u53ef\u4ee5\u53bb https:\/\/stackoverflow.com\/questions\/70133887\/how-can-i-fix-warning-stack-protector-not-protecting-local-variables-variable \u4e0a\u56de\u7b54\uff0c\u6211 Google \u4e86\u4e00\u5708\u90fd\u6ca1\u627e\u5230\u600e\u4e48\u89e3\u3002<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>3<\/span>) <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"7147755\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : wudicgi <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>  <\/span> <\/div>\n<\/p><\/div>\n<div> #pragma \u76f4\u63a5\u5c4f\u853d\u6389\u8fd9\u4e2a warning [\u72d7\u5934]<br \/>https:\/\/github.com\/search?l=C&amp;p=2&amp;q=stack+protector+not+protecting+local+variables&amp;type=Code<br \/>https:\/\/github.com\/solomonndungu\/kubernetes\/blob\/ad220b896530cfce895a47188e66235686e79e6c\/kubernetes_test\/keepalived-2.0.15\/lib\/warnings.h#L45 <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"7147756\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : fenglala <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>  <\/span> <\/div>\n<\/p><\/div>\n<div> @wudicgi \u662f\u4e2a\u529e\u6cd5\uff0c\u76f4\u63a5\u53bb\u6389-Wstack-protector \u6216\u8bb8\u66f4\u76f4\u63a5  <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"7147757\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ExplorerLog <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>  <\/span> <\/div>\n<\/p><\/div>\n<div> static ? <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u8bf7\u6559\u5404\u4f4d\uff0c\u5982\u4f55\u89e3\u51b3 warning&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/550261"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=550261"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/550261\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=550261"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=550261"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=550261"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}