summaryrefslogtreecommitdiff
path: root/gcc/varasm.c
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2006-06-21 08:58:44 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2006-06-21 08:58:44 +0000
commit1fc5c8affbf852fa27e7781cb1e23b2892983d33 (patch)
treefd1af8dab866ad596acc77b89185aabb10394617 /gcc/varasm.c
parent7a0c37debdedc3e121fb676f63c6d1cc4845859b (diff)
downloadgcc-1fc5c8affbf852fa27e7781cb1e23b2892983d33.tar.gz
* varasm.c (mergeable_string_section): Check for embedded NULs and
NUL termination in the first int_size_in_bytes (TREE_TYPE (decl)) rather than TREE_STRING_LENGTH bytes. * gcc.dg/merge-all-constants-1.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@114842 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/varasm.c')
-rw-r--r--gcc/varasm.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/gcc/varasm.c b/gcc/varasm.c
index 71158ba860b..e5abd3e2d97 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -655,16 +655,20 @@ mergeable_string_section (tree decl ATTRIBUTE_UNUSED,
unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED,
unsigned int flags ATTRIBUTE_UNUSED)
{
+ HOST_WIDE_INT len;
+
if (HAVE_GAS_SHF_MERGE && flag_merge_constants
&& TREE_CODE (decl) == STRING_CST
&& TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE
&& align <= 256
- && TREE_STRING_LENGTH (decl) >= int_size_in_bytes (TREE_TYPE (decl)))
+ && (len = int_size_in_bytes (TREE_TYPE (decl))) > 0
+ && TREE_STRING_LENGTH (decl) >= len)
{
enum machine_mode mode;
unsigned int modesize;
const char *str;
- int i, j, len, unit;
+ HOST_WIDE_INT i;
+ int j, unit;
char name[30];
mode = TYPE_MODE (TREE_TYPE (TREE_TYPE (decl)));
@@ -676,7 +680,6 @@ mergeable_string_section (tree decl ATTRIBUTE_UNUSED,
align = modesize;
str = TREE_STRING_POINTER (decl);
- len = TREE_STRING_LENGTH (decl);
unit = GET_MODE_SIZE (mode);
/* Check for embedded NUL characters. */