From d7ddfbcb7fa6e700639c9b916bf8a5ed15600950 Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Sat, 30 Nov 2019 22:03:25 +0100 Subject: cgraph.h (symtab_node): Add symver flag. 2019-11-30 Jan Hubicka * 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 * c-attribs.c (handle_symver_attribute): New function (c_common_attributes): Add symver. From-SVN: r278878 --- gcc/c-family/ChangeLog | 5 ++++ gcc/c-family/c-attribs.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) (limited to 'gcc/c-family') 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 + + * c-attribs.c (handle_symver_attribute): New function + (c_common_attributes): Add symver. + 2019-11-30 Richard Sandiford * 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, + "% attribute only applies to functions and variables"); + *no_add_attrs = true; + return NULL_TREE; + } + + if (!decl_in_symtab_p (*node)) + { + warning (OPT_Wattributes, + "% 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 ("% 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 %"); + error ("% 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. */ -- cgit v1.1