aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Sandiford <rsandifo@redhat.com>2004-01-11 10:37:49 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2004-01-11 10:37:49 +0000
commitbd9131c09c3551d08ff206b140a9f53b0ef7cc89 (patch)
treec9f37546f849e338102d34dbc8d676961752db91
parent6732ee60436e4a8849e1915ad4cca78f166a561e (diff)
downloadgcc-bd9131c09c3551d08ff206b140a9f53b0ef7cc89.zip
gcc-bd9131c09c3551d08ff206b140a9f53b0ef7cc89.tar.gz
gcc-bd9131c09c3551d08ff206b140a9f53b0ef7cc89.tar.bz2
mips.c (mips_symbolic_constant_p): Don't allow out-of-bounds accesses to string constants.
* config/mips/mips.c (mips_symbolic_constant_p): Don't allow out-of-bounds accesses to string constants. Simplify mips16 case accordingly. From-SVN: r75670
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/config/mips/mips.c18
2 files changed, 19 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index aa363b4..6d23396 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,11 @@
2004-01-11 Richard Sandiford <rsandifo@redhat.com>
+ * config/mips/mips.c (mips_symbolic_constant_p): Don't allow
+ out-of-bounds accesses to string constants. Simplify mips16
+ case accordingly.
+
+2004-01-11 Richard Sandiford <rsandifo@redhat.com>
+
PR optimization/13469
* toplev.c (rest_of_compilation): Call purge_all_dead_edges after
reload_cse_regs (-fnon-call-exceptions only).
diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
index 66bc053..1e04fa7 100644
--- a/gcc/config/mips/mips.c
+++ b/gcc/config/mips/mips.c
@@ -902,6 +902,16 @@ mips_symbolic_constant_p (rtx x, enum mips_symbol_type *symbol_type)
if (offset == 0)
return true;
+ /* If X refers to a string constant, and that constant is put into a
+ mergeable section, the linker will need to know which string is
+ being accessed. It has no way of distinguishing an out-of-bounds
+ access to X from an in-bounds access to a later or earlier string. */
+ if (GET_CODE (x) == SYMBOL_REF
+ && SYMBOL_REF_DECL (x) != 0
+ && TREE_CODE (SYMBOL_REF_DECL (x)) == STRING_CST
+ && !(offset > 0 && offset < TREE_STRING_LENGTH (SYMBOL_REF_DECL (x))))
+ return false;
+
/* Check whether a nonzero offset is valid for the underlying
relocations. */
switch (*symbol_type)
@@ -917,11 +927,9 @@ mips_symbolic_constant_p (rtx x, enum mips_symbol_type *symbol_type)
return (offset > 0 && offset < mips_section_threshold);
case SYMBOL_CONSTANT_POOL:
- /* Similarly check the range of offsets for mips16 constant
- pool entries. */
- return (CONSTANT_POOL_ADDRESS_P (x)
- && offset > 0
- && offset < (int) GET_MODE_SIZE (get_pool_mode (x)));
+ /* We don't generate out-of-bounds accesses to normal constant
+ pool entries. String constants were handled above. */
+ return true;
case SYMBOL_GOT_LOCAL:
case SYMBOL_GOTOFF_PAGE: