diff --git a/gcc/config/aarch64/aarch64-builtins.c b/gcc/config/aarch64/aarch64-builtins.c
index 297ca18..186b589 100644
--- a/gcc/config/aarch64/aarch64-builtins.c
+++ b/gcc/config/aarch64/aarch64-builtins.c
@@ -1017,8 +1017,8 @@ init_aarch64_simd_builtins (void)
 
 	  gcc_assert (ftype != NULL);
 
-	  sprintf (namebuf, "__builtin_aarch64_%s%s", d->name,
-		   modenames[j]);
+	  snprintf (namebuf, sizeof (namebuf), "__builtin_aarch64_%s%s",
+		    d->name, modenames[j]);
 
 	  add_builtin_function (namebuf, ftype, fcode++, BUILT_IN_MD, NULL,
 				NULL_TREE);
diff --git a/gcc/config/aarch64/aarch64-simd.md b/gcc/config/aarch64/aarch64-simd.md
index 85c8c2b..dc795a9 100644
--- a/gcc/config/aarch64/aarch64-simd.md
+++ b/gcc/config/aarch64/aarch64-simd.md
@@ -407,14 +407,14 @@
 	if (mvn == 0)
 	  {
 	    if (widthc != 'd')
-	      sprintf (templ,"movi\t%%0.%d%c, %%1, lsl %d ",(64/width),
-							widthc, shift);
+	      snprintf (templ, sizeof (templ), "movi\t%%0.%d%c, %%1, lsl %d ",
+			64 / width, widthc, shift);
 	    else
-	      sprintf (templ,"movi\t%%d0, %%1");
+	      snprintf (templ, sizeof (templ), "movi\t%%d0, %%1");
 	  }
 	else
-	  sprintf (templ,"mvni\t%%0.%d%c, %%1, lsl %d",(64/width),
-							widthc, shift);
+	  snprintf (templ, sizeof (templ), "mvni\t%%0.%d%c, %%1, lsl %d",
+		    64 / width, widthc, shift);
 	return templ;
        }
      default: gcc_unreachable ();
@@ -455,11 +455,11 @@
 						 &mvn, &shift);
 	gcc_assert (is_valid != 0);
 	if (mvn == 0)
-	  sprintf (templ,"movi\t%%0.%d%c, %%1, lsl %d ", (128/width),
-							 widthc, shift);
+	  snprintf (templ, sizeof (templ), "movi\t%%0.%d%c, %%1, lsl %d ",
+		    128 / width, widthc, shift);
 	else
-	  sprintf (templ,"mvni\t%%0.%d%c, %%1, lsl %d", (128/width),
-							widthc, shift);
+	  snprintf (templ, sizeof (templ), "mvni\t%%0.%d%c, %%1, lsl %d",
+		    128 / width, widthc, shift);
 	return templ;
        }
      default: gcc_unreachable ();
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 34d0475..933d7d6 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -3768,7 +3768,7 @@ aarch64_elf_asm_constructor (rtx symbol, int priority)
     {
       section *s;
       char buf[18];
-      sprintf (buf, ".init_array.%.5u", priority);
+      snprintf (buf, sizeof (buf), ".init_array.%.5u", priority);
       s = get_section (buf, SECTION_WRITE, NULL);
       switch_to_section (s);
       assemble_align (POINTER_SIZE);
@@ -3787,7 +3787,7 @@ aarch64_elf_asm_destructor (rtx symbol, int priority)
     {
       section *s;
       char buf[18];
-      sprintf (buf, ".fini_array.%.5u", priority);
+      snprintf (buf, sizeof (buf), ".fini_array.%.5u", priority);
       s = get_section (buf, SECTION_WRITE, NULL);
       switch_to_section (s);
       assemble_align (POINTER_SIZE);
@@ -3836,7 +3836,8 @@ aarch64_output_casesi (rtx *operands)
   /* Need to implement table size reduction, by chaning the code below.  */
   output_asm_insn (patterns[index][0], operands);
   ASM_GENERATE_INTERNAL_LABEL (label, "Lrtx", CODE_LABEL_NUMBER (operands[2]));
-  sprintf (buf, "adr\t%%4, %s", targetm.strip_name_encoding (label));
+  snprintf (buf, sizeof (buf),
+	    "adr\t%%4, %s", targetm.strip_name_encoding (label));
   output_asm_insn (buf, operands);
   output_asm_insn (patterns[index][1], operands);
   output_asm_insn ("br\t%3", operands);
@@ -5891,7 +5892,7 @@ aarch64_output_asm_insn (emit_f emit, int label, rtx *operands,
   char buffer[256];
 
   va_start (ap, pattern);
-  vsprintf (buffer, pattern, ap);
+  vsnprintf (buffer, sizeof (buffer), pattern, ap);
   va_end (ap);
   emit (label, buffer, operands);
 }
