diff options
author | Wilco Dijkstra <wdijkstr@arm.com> | 2021-11-05 15:05:15 +0000 |
---|---|---|
committer | Wilco Dijkstra <wdijkstr@arm.com> | 2021-11-05 15:36:32 +0000 |
commit | b33b2678342c655ff8ddb9fab379b26f656adc03 (patch) | |
tree | d6333e2dec4ddb709119e844aba71fa3502fc255 /gcc | |
parent | a505e1fae4378254275ec292bd5299a16357de90 (diff) | |
download | gcc-b33b2678342c655ff8ddb9fab379b26f656adc03.zip gcc-b33b2678342c655ff8ddb9fab379b26f656adc03.tar.gz gcc-b33b2678342c655ff8ddb9fab379b26f656adc03.tar.bz2 |
AArch64: Fix PR103085
The stack protector implementation hides symbols in a const unspec, which means
movdi/movsi patterns must always support const on symbol operands and
explicitly strip away the unspec. Do this for the recently added GOT
alternatives. Add a test to ensure stack-protector tests GOT accesses as well.
2021-11-05 Wilco Dijkstra <wdijkstr@arm.com>
PR target/103085
* config/aarch64/aarch64.c (aarch64_mov_operand_p): Strip the salt
first.
* config/aarch64/constraints.md: Support const in Usw.
gcc/testsuite/
PR target/103085
* gcc.target/aarch64/pr103085.c: New test
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/config/aarch64/aarch64.c | 4 | ||||
-rw-r--r-- | gcc/config/aarch64/constraints.md | 3 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/aarch64/pr103085.c | 11 |
3 files changed, 16 insertions, 2 deletions
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index 69f0805..fdf0550 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -20379,12 +20379,14 @@ aarch64_mov_operand_p (rtx x, machine_mode mode) return aarch64_simd_valid_immediate (x, NULL); } + /* Remove UNSPEC_SALT_ADDR before checking symbol reference. */ + x = strip_salt (x); + /* GOT accesses are valid moves. */ if (SYMBOL_REF_P (x) && aarch64_classify_symbolic_expression (x) == SYMBOL_SMALL_GOT_4G) return true; - x = strip_salt (x); if (SYMBOL_REF_P (x) && mode == DImode && CONSTANT_ADDRESS_P (x)) return true; diff --git a/gcc/config/aarch64/constraints.md b/gcc/config/aarch64/constraints.md index 87c0e5f..b197ec2 100644 --- a/gcc/config/aarch64/constraints.md +++ b/gcc/config/aarch64/constraints.md @@ -152,10 +152,11 @@ (match_test "aarch64_symbolic_address_p (op)") (match_test "aarch64_mov_operand_p (op, GET_MODE (op))"))) +;; const is needed here to support UNSPEC_SALT_ADDR. (define_constraint "Usw" "@internal A constraint that matches a small GOT access." - (and (match_code "symbol_ref") + (and (match_code "const,symbol_ref") (match_test "aarch64_classify_symbolic_expression (op) == SYMBOL_SMALL_GOT_4G"))) diff --git a/gcc/testsuite/gcc.target/aarch64/pr103085.c b/gcc/testsuite/gcc.target/aarch64/pr103085.c new file mode 100644 index 0000000..dbc9c15 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/pr103085.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fstack-protector-strong -fPIC" } */ + +void g(int*); +void +f (int x) +{ + int arr[10]; + g (arr); +} + |