aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-family
diff options
context:
space:
mode:
authorSriraman Tallam <tmsriram@google.com>2015-06-04 21:14:10 +0000
committerSriraman Tallam <tmsriram@gcc.gnu.org>2015-06-04 21:14:10 +0000
commit4bb794e25d5e141fd57fd206c276d04d93e25e4a (patch)
tree6b25a7412ce088321aa5a46c7d80ebb9b7e8b619 /gcc/c-family
parent172f0ce5ab5fa74a5695cf855c9ba7c4e98c754a (diff)
downloadgcc-4bb794e25d5e141fd57fd206c276d04d93e25e4a.zip
gcc-4bb794e25d5e141fd57fd206c276d04d93e25e4a.tar.gz
gcc-4bb794e25d5e141fd57fd206c276d04d93e25e4a.tar.bz2
c-common.c (noplt): New attribute.
2015-06-04 Sriraman Tallam <tmsriram@google.com> * c-family/c-common.c (noplt): New attribute. (handle_noplt_attribute): New handler. * calls.c (prepare_call_address): Check for noplt attribute. * config/i386/i386.c (ix86_expand_call): Check for noplt attribute. (ix86_nopic_noplt_attribute_p): New function. (ix86_output_call_insn): Output indirect call for non-pic no plt calls. * doc/extend.texi (noplt): Document new attribute. * doc/invoke.texi: Document new attribute. * testsuite/gcc.target/i386/noplt-1.c: New test. * testsuite/gcc.target/i386/noplt-2.c: New test. * testsuite/gcc.target/i386/noplt-3.c: New test. * testsuite/gcc.target/i386/noplt-4.c: New test. This patch does two things: * Adds new generic function attribute "noplt" that is similar in functionality to -fno-plt except that it applies only to calls to functions that are marked with this attribute. * For x86_64, it makes -fno-plt(and the attribute) also work for non-PIC code by directly generating an indirect call via a GOT entry. From-SVN: r224138
Diffstat (limited to 'gcc/c-family')
-rw-r--r--gcc/c-family/c-common.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 8528fe4..6f4393b 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -356,6 +356,7 @@ static tree handle_mode_attribute (tree *, tree, tree, int, bool *);
static tree handle_section_attribute (tree *, tree, tree, int, bool *);
static tree handle_aligned_attribute (tree *, tree, tree, int, bool *);
static tree handle_weak_attribute (tree *, tree, tree, int, bool *) ;
+static tree handle_noplt_attribute (tree *, tree, tree, int, bool *) ;
static tree handle_alias_ifunc_attribute (bool, tree *, tree, tree, bool *);
static tree handle_ifunc_attribute (tree *, tree, tree, int, bool *);
static tree handle_alias_attribute (tree *, tree, tree, int, bool *);
@@ -705,6 +706,8 @@ const struct attribute_spec c_common_attribute_table[] =
handle_aligned_attribute, false },
{ "weak", 0, 0, true, false, false,
handle_weak_attribute, false },
+ { "noplt", 0, 0, true, false, false,
+ handle_noplt_attribute, false },
{ "ifunc", 1, 1, true, false, false,
handle_ifunc_attribute, false },
{ "alias", 1, 1, true, false, false,
@@ -8184,6 +8187,25 @@ handle_weak_attribute (tree *node, tree name,
return NULL_TREE;
}
+/* Handle a "noplt" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_noplt_attribute (tree *node, tree name,
+ tree ARG_UNUSED (args),
+ int ARG_UNUSED (flags),
+ bool * ARG_UNUSED (no_add_attrs))
+{
+ if (TREE_CODE (*node) != FUNCTION_DECL)
+ {
+ warning (OPT_Wattributes,
+ "%qE attribute is only applicable on functions", name);
+ *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. */