diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2021-12-07 05:09:34 -0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2021-12-07 05:24:47 -0800 |
commit | 7ef68c37b3a46e69ed4a5ff6b2b368e2c9a8023f (patch) | |
tree | 5e9d4462160b6ffa17ea637879452bb6cdab7083 | |
parent | 6e8a31275fda445fb3e8d98e53f5e1541f4727af (diff) | |
download | gcc-7ef68c37b3a46e69ed4a5ff6b2b368e2c9a8023f.zip gcc-7ef68c37b3a46e69ed4a5ff6b2b368e2c9a8023f.tar.gz gcc-7ef68c37b3a46e69ed4a5ff6b2b368e2c9a8023f.tar.bz2 |
x86: Check FUNCTION_DECL before calling cgraph_node::get
gcc/
PR target/103594
* config/i386/i386.c (ix86_call_use_plt_p): Check FUNCTION_DECL
before calling cgraph_node::get.
gcc/testsuite/
PR target/103594
* gcc.dg/pr103594.c: New test.
-rw-r--r-- | gcc/config/i386/i386.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr103594.c | 14 |
2 files changed, 16 insertions, 1 deletions
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 52547b0..f1e41fd 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -15987,7 +15987,8 @@ ix86_call_use_plt_p (rtx call_op) { if (SYMBOL_REF_LOCAL_P (call_op)) { - if (SYMBOL_REF_DECL (call_op)) + if (SYMBOL_REF_DECL (call_op) + && TREE_CODE (SYMBOL_REF_DECL (call_op)) == FUNCTION_DECL) { /* NB: All ifunc functions must be called via PLT. */ cgraph_node *node diff --git a/gcc/testsuite/gcc.dg/pr103594.c b/gcc/testsuite/gcc.dg/pr103594.c new file mode 100644 index 0000000..0eae239 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr103594.c @@ -0,0 +1,14 @@ +/* { dg-do compile { target fpic } } */ +/* { dg-options "-O1 -fpic" } */ + +int regex_subst(void) +{ + const void *subst = ""; + return (*(int (*)(int))subst) (0); +} + +int foobar (void) +{ + int x; + return (*(int (*)(void))&x) (); +} |