aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2019-02-04 23:49:49 +1030
committerAlan Modra <amodra@gcc.gnu.org>2019-02-04 23:49:49 +1030
commit13157c1056407bc8c7d0d28772981bdd7cbc82c4 (patch)
tree8528a3cfde4f870ccd2dc6202fcec502839adb3d /gcc
parentd92ec61d23834a69e962fe66acd7c192c3abc972 (diff)
downloadgcc-13157c1056407bc8c7d0d28772981bdd7cbc82c4.zip
gcc-13157c1056407bc8c7d0d28772981bdd7cbc82c4.tar.gz
gcc-13157c1056407bc8c7d0d28772981bdd7cbc82c4.tar.bz2
[RS6000] Fix potiential buffer overflow
* config/rs6000/rs6000.c (rs6000_indirect_call_template_1): Increase str[] size to 160, and comment. From-SVN: r268520
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/config/rs6000/rs6000.c41
2 files changed, 44 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index efe3f5b..3c52283 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,10 @@
2019-02-04 Alan Modra <amodra@gmail.com>
+ * config/rs6000/rs6000.c (rs6000_indirect_call_template_1): Increase
+ str[] size to 160, and comment.
+
+2019-02-04 Alan Modra <amodra@gmail.com>
+
* config/rs6000/rs6000.c (rs6000_indirect_call_template_1),
(rs6000_pltseq_template): Guard output of TLS markers with
TARGET_TLS_MARKERS.
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 7d417b6..711278c 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -21609,10 +21609,47 @@ rs6000_indirect_call_template_1 (rtx *operands, unsigned int funop,
bool sibcall)
{
/* -Wformat-overflow workaround, without which gcc thinks that %u
- might produce 10 digits. */
+ might produce 10 digits. Note that -Wformat-overflow will not
+ currently warn here for str[], so do not rely on a warning to
+ ensure str[] is correctly sized. */
gcc_assert (funop <= MAX_RECOG_OPERANDS);
- static char str[144]; /* 1 spare */
+ /* Currently, funop is either 0 or 1. The maximum string is always
+ a !speculate 64-bit __tls_get_addr call.
+
+ ABI_AIX:
+ . 9 ld 2,%3\n\t
+ . 27 .reloc .,R_PPC64_TLSGD,%2\n\t
+ . 29 .reloc .,R_PPC64_PLTSEQ,%z1\n\t
+ . 9 crset 2\n\t
+ . 27 .reloc .,R_PPC64_TLSGD,%2\n\t
+ . 30 .reloc .,R_PPC64_PLTCALL,%z1\n\t
+ . 10 beq%T1l-\n\t
+ . 10 ld 2,%4(1)
+ .---
+ .151
+
+ ABI_ELFv2:
+ . 27 .reloc .,R_PPC64_TLSGD,%2\n\t
+ . 29 .reloc .,R_PPC64_PLTSEQ,%z1\n\t
+ . 9 crset 2\n\t
+ . 27 .reloc .,R_PPC64_TLSGD,%2\n\t
+ . 30 .reloc .,R_PPC64_PLTCALL,%z1\n\t
+ . 10 beq%T1l-\n\t
+ . 10 ld 2,%3(1)
+ .---
+ .142
+
+ ABI_V4:
+ . 27 .reloc .,R_PPC64_TLSGD,%2\n\t
+ . 35 .reloc .,R_PPC64_PLTSEQ,%z1+32768\n\t
+ . 9 crset 2\n\t
+ . 27 .reloc .,R_PPC64_TLSGD,%2\n\t
+ . 36 .reloc .,R_PPC64_PLTCALL,%z1+32768\n\t
+ . 8 beq%T1l-
+ .---
+ .141 */
+ static char str[160]; /* 8 spare */
char *s = str;
const char *ptrload = TARGET_64BIT ? "d" : "wz";