]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[AArch64] Increase static buffer size in aarch64_rewrite_selected_cpu
authorktkachov <ktkachov@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 21 Apr 2015 08:14:22 +0000 (08:14 +0000)
committerktkachov <ktkachov@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 21 Apr 2015 08:14:22 +0000 (08:14 +0000)
* common/config/aarch64/aarch64-common.c (AARCH64_CPU_NAME_LENGTH):
Increase to 128.
(aarch64_rewrite_selected_cpu): Do not chop off extensions starting
at '.'.  Assert that there's enough space for everything.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222258 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/common/config/aarch64/aarch64-common.c

index 10f4dafbabf610207c5f0449d27df94b8b373583..66856a875c494024b859be4bfe93fad0a73784ac 100644 (file)
@@ -1,3 +1,10 @@
+2015-04-21  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
+
+       * common/config/aarch64/aarch64-common.c (AARCH64_CPU_NAME_LENGTH):
+       Increase to 128.
+       (aarch64_rewrite_selected_cpu): Do not chop off extensions starting
+       at '.'.  Assert that there's enough space for everything.
+
 2015-04-21  Uros Bizjak  <ubizjak@gmail.com>
 
        PR tree-optimization/64950
index 308f19c6409b1bd3191a87aedea305225436fb43..b3fd9dc5460e5f427ca773a7a98804c3be0fd836 100644 (file)
@@ -27,6 +27,7 @@
 #include "common/common-target-def.h"
 #include "opts.h"
 #include "flags.h"
+#include "errors.h"
 
 #ifdef  TARGET_BIG_ENDIAN_DEFAULT
 #undef  TARGET_DEFAULT_TARGET_FLAGS
@@ -89,23 +90,34 @@ aarch64_handle_option (struct gcc_options *opts,
 
 struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER;
 
-#define AARCH64_CPU_NAME_LENGTH 20
+#define AARCH64_CPU_NAME_LENGTH 128
 
-/* Truncate NAME at the first '.' character seen, or return
-   NAME unmodified.  */
+/* Truncate NAME at the first '.' character seen up to the first '+'
+   or return NAME unmodified.  */
 
 const char *
 aarch64_rewrite_selected_cpu (const char *name)
 {
   static char output_buf[AARCH64_CPU_NAME_LENGTH + 1] = {0};
-  char *arg_pos;
+  const char *bL_sep;
+  const char *feats;
+  size_t pref_size;
+  size_t feat_size;
 
-  strncpy (output_buf, name, AARCH64_CPU_NAME_LENGTH);
-  arg_pos = strchr (output_buf, '.');
+  bL_sep = strchr (name, '.');
+  if (!bL_sep)
+    return name;
 
-  /* If we found a '.' truncate the entry at that point.  */
-  if (arg_pos)
-    *arg_pos = '\0';
+  feats = strchr (name, '+');
+  feat_size = feats ? strnlen (feats, AARCH64_CPU_NAME_LENGTH) : 0;
+  pref_size = bL_sep - name;
+
+  if ((feat_size + pref_size) > AARCH64_CPU_NAME_LENGTH)
+    internal_error ("-mcpu string too large");
+
+  strncpy (output_buf, name, pref_size);
+  if (feats)
+    strncpy (output_buf + pref_size, feats, feat_size);
 
   return output_buf;
 }