diff options
author | Jan Hubicka <hubicka@ucw.cz> | 2019-11-30 22:03:25 +0100 |
---|---|---|
committer | Jan Hubicka <hubicka@gcc.gnu.org> | 2019-11-30 21:03:25 +0000 |
commit | d7ddfbcb7fa6e700639c9b916bf8a5ed15600950 (patch) | |
tree | 3e8ad36922e2df05cdc896aec48daa30135163d6 /gcc/c-family | |
parent | 65ef05d0b7fb429c5760189e638c441dc3da33f4 (diff) | |
download | gcc-d7ddfbcb7fa6e700639c9b916bf8a5ed15600950.zip gcc-d7ddfbcb7fa6e700639c9b916bf8a5ed15600950.tar.gz gcc-d7ddfbcb7fa6e700639c9b916bf8a5ed15600950.tar.bz2 |
cgraph.h (symtab_node): Add symver flag.
2019-11-30 Jan Hubicka <hubicka@ucw.cz>
* cgraph.h (symtab_node): Add symver flag.
* cgraphunit.c (process_symver_attribute): New.
(process_common_attributes): Use process_symver_attribute.
* lto-cgraph.c (lto_output_node): Stream symver.
(lto_output_varpool_node): Stream symver.
(input_overwrite_node): Stream symver.
(input_varpool_node): Stream symver.
* output.h (do_assemble_symver): Decalre.
* symtab.c (symtab_node::dump_base): Dump symver.
(symtab_node::verify_base): Verify symver.
(symtab_node::resolve_alias): Handle symver.
* varasm.c (do_assemble_symver): New function.
* varpool.c (varpool_node::assemble_aliases): Use it.
* doc/extend.texi: (symver attribute): Document.
* config/elfos.h (ASM_OUTPUT_SYMVER_DIRECTIVE): New.
c-family/ChangeLog:
2019-11-30 Jan Hubicka <hubicka@ucw.cz>
* c-attribs.c (handle_symver_attribute): New function
(c_common_attributes): Add symver.
From-SVN: r278878
Diffstat (limited to 'gcc/c-family')
-rw-r--r-- | gcc/c-family/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/c-family/c-attribs.c | 59 |
2 files changed, 64 insertions, 0 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 763e5a2..fa3b942 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2019-11-30 Jan Hubicka <hubicka@ucw.cz> + + * c-attribs.c (handle_symver_attribute): New function + (c_common_attributes): Add symver. + 2019-11-30 Richard Sandiford <richard.sandiford@arm.com> * c-common.c (pointer_int_sum): Use verify_type_context to check diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c index 35388e8..dc56e2e 100644 --- a/gcc/c-family/c-attribs.c +++ b/gcc/c-family/c-attribs.c @@ -66,6 +66,7 @@ static tree handle_stack_protect_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_nocf_check_attribute (tree *, tree, tree, int, bool *); +static tree handle_symver_attribute (tree *, tree, tree, int, bool *); static tree handle_noicf_attribute (tree *, tree, tree, int, bool *); static tree handle_noipa_attribute (tree *, tree, tree, int, bool *); static tree handle_leaf_attribute (tree *, tree, tree, int, bool *); @@ -475,6 +476,8 @@ const struct attribute_spec c_common_attribute_table[] = NULL }, { "nocf_check", 0, 0, false, true, true, true, handle_nocf_check_attribute, NULL }, + { "symver", 1, -1, true, false, false, false, + handle_symver_attribute, NULL}, { "copy", 1, 1, false, false, false, false, handle_copy_attribute, NULL }, { "noinit", 0, 0, true, false, false, false, @@ -2335,6 +2338,62 @@ handle_noplt_attribute (tree *node, tree name, return NULL_TREE; } +/* Handle a "symver" attribute. */ + +static tree +handle_symver_attribute (tree *node, tree ARG_UNUSED (name), tree args, + int ARG_UNUSED (flags), bool *no_add_attrs) +{ + tree symver; + const char *symver_str; + + if (TREE_CODE (*node) != FUNCTION_DECL && TREE_CODE (*node) != VAR_DECL) + { + warning (OPT_Wattributes, + "%<symver%> attribute only applies to functions and variables"); + *no_add_attrs = true; + return NULL_TREE; + } + + if (!decl_in_symtab_p (*node)) + { + warning (OPT_Wattributes, + "%<symver%> attribute is only applicable to symbols"); + *no_add_attrs = true; + return NULL_TREE; + } + + for (; args; args = TREE_CHAIN (args)) + { + symver = TREE_VALUE (args); + if (TREE_CODE (symver) != STRING_CST) + { + error ("%<symver%> attribute argument not a string constant"); + *no_add_attrs = true; + return NULL_TREE; + } + + symver_str = TREE_STRING_POINTER (symver); + + int ats = 0; + for (int n = 0; (int)n < TREE_STRING_LENGTH (symver); n++) + if (symver_str[n] == '@') + ats++; + + if (ats != 1 && ats != 2) + { + error ("symver attribute argument must have format %<name@nodename%>"); + error ("%<symver%> attribute argument %qs must contain one or two " + "%<@%>", symver_str); + *no_add_attrs = true; + return NULL_TREE; + } + } + + return NULL_TREE; +} + + /* Handle an "alias" or "ifunc" attribute; arguments as in struct attribute_spec.handler, except that IS_ALIAS tells us whether this is an alias as opposed to ifunc attribute. */ |