gcc/
authorChristophe Lyon <christophe.lyon@linaro.org>
Mon, 30 Jan 2017 10:19:18 +0000 (10:19 +0000)
committerYvan Roux <yvan.roux@linaro.org>
Mon, 30 Jan 2017 13:43:39 +0000 (13:43 +0000)
Backport from trunk r244828.
2017-01-23  Andreas Tobler  <andreast@gcc.gnu.org>

* config/aarch64/aarch64.c (aarch64_elf_asm_constructor): Increase
size of buf.
(aarch64_elf_asm_destructor): Likewise.

Change-Id: I22482fe29e558254616a97aeddd6b39c48718a85

gcc/config/aarch64/aarch64.c

index c2bf18c..354207d 100644 (file)
@@ -5464,7 +5464,10 @@ aarch64_elf_asm_constructor (rtx symbol, int priority)
   else
     {
       section *s;
-      char buf[18];
+      /* While priority is known to be in range [0, 65535], so 18 bytes
+         would be enough, the compiler might not know that.  To avoid
+         -Wformat-truncation false positive, use a larger size.  */
+      char buf[23];
       snprintf (buf, sizeof (buf), ".init_array.%.5u", priority);
       s = get_section (buf, SECTION_WRITE, NULL);
       switch_to_section (s);
@@ -5481,7 +5484,10 @@ aarch64_elf_asm_destructor (rtx symbol, int priority)
   else
     {
       section *s;
-      char buf[18];
+      /* While priority is known to be in range [0, 65535], so 18 bytes
+         would be enough, the compiler might not know that.  To avoid
+         -Wformat-truncation false positive, use a larger size.  */
+      char buf[23];
       snprintf (buf, sizeof (buf), ".fini_array.%.5u", priority);
       s = get_section (buf, SECTION_WRITE, NULL);
       switch_to_section (s);