From c17c7aaf40151230320b0d17873734effe131ff1 Mon Sep 17 00:00:00 2001 From: Andrew Carlotti Date: Fri, 12 Jan 2024 01:42:08 +0000 Subject: [PATCH] aarch64: Fix option parsing to disallow prefixes of valid options Add "+rdm" as an explicit alias for "+rdma", to maintain existing compatibility with Clang. --- gas/config/tc-aarch64.c | 4 +++- gas/testsuite/gas/aarch64/opt-invalid.d | 1 + gas/testsuite/gas/aarch64/opt-invalid.s | 1 + gas/testsuite/gas/aarch64/rdma.d | 1 + 4 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 gas/testsuite/gas/aarch64/opt-invalid.d create mode 100644 gas/testsuite/gas/aarch64/opt-invalid.s diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c index 6b11c4e..c2f77a4 100644 --- a/gas/config/tc-aarch64.c +++ b/gas/config/tc-aarch64.c @@ -10274,6 +10274,7 @@ static const struct aarch64_option_cpu_value_table aarch64_features[] = { {"lor", AARCH64_FEATURE (LOR), AARCH64_NO_FEATURES}, {"ras", AARCH64_FEATURE (RAS), AARCH64_NO_FEATURES}, {"rdma", AARCH64_FEATURE (RDMA), AARCH64_FEATURE (SIMD)}, + {"rdm", AARCH64_FEATURE (RDMA), AARCH64_FEATURE (SIMD)}, {"fp16", AARCH64_FEATURE (F16), AARCH64_FEATURE (FP)}, {"fp16fml", AARCH64_FEATURE (F16_FML), AARCH64_FEATURE (F16)}, {"profile", AARCH64_FEATURE (PROFILE), AARCH64_NO_FEATURES}, @@ -10438,7 +10439,8 @@ aarch64_parse_features (const char *str, const aarch64_feature_set **opt_p, gas_assert (adding_value != -1); for (opt = aarch64_features; opt->name != NULL; opt++) - if (strncmp (opt->name, str, optlen) == 0) + if (optlen == (int) strlen(opt->name) + && strncmp (opt->name, str, optlen) == 0) { aarch64_feature_set set; diff --git a/gas/testsuite/gas/aarch64/opt-invalid.d b/gas/testsuite/gas/aarch64/opt-invalid.d new file mode 100644 index 0000000..500c68a --- /dev/null +++ b/gas/testsuite/gas/aarch64/opt-invalid.d @@ -0,0 +1 @@ +#error: .*: Error: unknown architectural extension `s' diff --git a/gas/testsuite/gas/aarch64/opt-invalid.s b/gas/testsuite/gas/aarch64/opt-invalid.s new file mode 100644 index 0000000..058d4c1 --- /dev/null +++ b/gas/testsuite/gas/aarch64/opt-invalid.s @@ -0,0 +1 @@ +.arch armv8-a+s diff --git a/gas/testsuite/gas/aarch64/rdma.d b/gas/testsuite/gas/aarch64/rdma.d index d634909..b506d7d 100644 --- a/gas/testsuite/gas/aarch64/rdma.d +++ b/gas/testsuite/gas/aarch64/rdma.d @@ -1,5 +1,6 @@ #objdump: -dr #as: -march=armv8-a+rdma +#as: -march=armv8-a+rdm .*: file format .* -- 2.7.4