diff options
author | Martin Liska <mliska@suse.cz> | 2020-05-15 14:42:12 +0200 |
---|---|---|
committer | Martin Liska <mliska@suse.cz> | 2020-10-22 10:10:50 +0200 |
commit | 346b302d09c1e6db56d9fe69048acb32fbb97845 (patch) | |
tree | dc5b9b9594325c30b81f676d19c75dbc3a34343f /gcc/ada/gcc-interface/utils.c | |
parent | 5a99796b85c93fe9d61ee52fc3a38b8698709479 (diff) | |
download | gcc-346b302d09c1e6db56d9fe69048acb32fbb97845.zip gcc-346b302d09c1e6db56d9fe69048acb32fbb97845.tar.gz gcc-346b302d09c1e6db56d9fe69048acb32fbb97845.tar.bz2 |
Implement no_stack_protector attribute.
gcc/ChangeLog:
2020-05-18 Martin Liska <mliska@suse.cz>
PR c/94722
* cfgexpand.c (stack_protect_decl_phase):
Guard with lookup_attribute("no_stack_protector") at
various places.
(expand_used_vars): Likewise here.
* doc/extend.texi: Document no_stack_protector attribute.
gcc/ada/ChangeLog:
2020-05-18 Martin Liska <mliska@suse.cz>
PR c/94722
* gcc-interface/utils.c (handle_no_stack_protect_attribute):
New.
(handle_stack_protect_attribute): Add error message for a
no_stack_protector function.
gcc/c-family/ChangeLog:
2020-05-18 Martin Liska <mliska@suse.cz>
PR c/94722
* c-attribs.c (handle_no_stack_protect_function_attribute): New.
(handle_stack_protect_attribute): Add error message for a
no_stack_protector function.
gcc/testsuite/ChangeLog:
2020-05-18 Martin Liska <mliska@suse.cz>
PR c/94722
* g++.dg/no-stack-protector-attr-2.C: New test.
* g++.dg/no-stack-protector-attr-3.C: New test.
* g++.dg/no-stack-protector-attr.C: New test.
Diffstat (limited to 'gcc/ada/gcc-interface/utils.c')
-rw-r--r-- | gcc/ada/gcc-interface/utils.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c index 048a0cf..d50872f 100644 --- a/gcc/ada/gcc-interface/utils.c +++ b/gcc/ada/gcc-interface/utils.c @@ -92,6 +92,7 @@ static tree handle_nonnull_attribute (tree *, tree, tree, int, bool *); static tree handle_sentinel_attribute (tree *, tree, tree, int, bool *); static tree handle_noreturn_attribute (tree *, tree, tree, int, bool *); static tree handle_stack_protect_attribute (tree *, tree, tree, int, bool *); +static tree handle_no_stack_protector_attribute (tree *, tree, tree, int, bool *); static tree handle_noinline_attribute (tree *, tree, tree, int, bool *); static tree handle_noclone_attribute (tree *, tree, tree, int, bool *); static tree handle_noicf_attribute (tree *, tree, tree, int, bool *); @@ -116,6 +117,13 @@ static const struct attribute_spec::exclusions attr_cold_hot_exclusions[] = { NULL , false, false, false } }; +static const struct attribute_spec::exclusions attr_stack_protect_exclusions[] = +{ + { "stack_protect", true, false, false }, + { "no_stack_protector", true, false, false }, + { NULL, false, false, false }, +}; + /* Fake handler for attributes we don't properly support, typically because they'd require dragging a lot of the common-c front-end circuitry. */ static tree fake_attribute_handler (tree *, tree, tree, int, bool *); @@ -141,7 +149,11 @@ const struct attribute_spec gnat_internal_attribute_table[] = { "noreturn", 0, 0, true, false, false, false, handle_noreturn_attribute, NULL }, { "stack_protect",0, 0, true, false, false, false, - handle_stack_protect_attribute, NULL }, + handle_stack_protect_attribute, + attr_stack_protect_exclusions }, + { "no_stack_protector",0, 0, true, false, false, false, + handle_no_stack_protector_attribute, + attr_stack_protect_exclusions }, { "noinline", 0, 0, true, false, false, false, handle_noinline_attribute, NULL }, { "noclone", 0, 0, true, false, false, false, @@ -6560,6 +6572,23 @@ handle_stack_protect_attribute (tree *node, tree name, tree, int, return NULL_TREE; } +/* Handle a "no_stack_protector" attribute; arguments as in + struct attribute_spec.handler. */ + +static tree +handle_no_stack_protector_attribute (tree *node, tree name, tree, int, + bool *no_add_attrs) +{ + if (TREE_CODE (*node) != FUNCTION_DECL) + { + warning (OPT_Wattributes, "%qE attribute ignored", name); + *no_add_attrs = true; + } + + return NULL_TREE; +} + + /* Handle a "noinline" attribute; arguments as in struct attribute_spec.handler. */ |