[llvm-commits] [llvm-gcc-4.2] r95013 - /llvm-gcc-4.2/trunk/gcc/config/darwin-c.c

Evan Cheng evan.cheng at apple.com
Mon Feb 1 14:21:08 PST 2010


Author: evancheng
Date: Mon Feb  1 16:21:08 2010
New Revision: 95013

URL: http://llvm.org/viewvc/llvm-project?rev=95013&view=rev
Log:
Do not force ustring's with embedded null chars into __TEXT,__ustring. rdar://7589850.

Modified:
    llvm-gcc-4.2/trunk/gcc/config/darwin-c.c

Modified: llvm-gcc-4.2/trunk/gcc/config/darwin-c.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/darwin-c.c?rev=95013&r1=95012&r2=95013&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/darwin-c.c (original)
+++ llvm-gcc-4.2/trunk/gcc/config/darwin-c.c Mon Feb  1 16:21:08 2010
@@ -1204,10 +1204,22 @@
   static int num;
   const char *name_prefix = "__utf16_string_";
   char *name;
+  int embedNull = 0;
 
   if (!cvt_utf8_utf16 (inbuf, length, &uniCharBuf, numUniChars))
     return NULL_TREE;
 
+  /* LLVM LOCAL begin 7589850. */
+  /* ustring with embedded null should go into __const. It should not be forced
+     into "__TEXT,__ustring" section. */
+  for (l = 0; l < length; l++) {
+    if (!inbuf[l]) {
+      embedNull = 1;
+      break;
+    }
+  }
+  /* LLVM LOCAL end 7589850. */
+
   for (l = 0; l < *numUniChars; l++)
     initlist = tree_cons (NULL_TREE, build_int_cst (char_type_node, uniCharBuf[l]), initlist);
   /* LLVM LOCAL utf16 has two trailing nulls 7095855 */
@@ -1226,9 +1238,12 @@
   TREE_READONLY (decl) = 1;
   /* LLVM LOCAL end */
 
-  attribute = tree_cons (NULL_TREE, build_string (len, section_name), NULL_TREE);
-  attribute = tree_cons (get_identifier ("section"), attribute, NULL_TREE);
-  decl_attributes (&decl, attribute, 0);
+  /* LLVM LOCAL 7589850 */
+  if (!embedNull) {
+    attribute = tree_cons (NULL_TREE, build_string (len, section_name), NULL_TREE);
+    attribute = tree_cons (get_identifier ("section"), attribute, NULL_TREE);
+    decl_attributes (&decl, attribute, 0);
+  }
   attribute = tree_cons (NULL_TREE, build_int_cst (NULL_TREE, 2), NULL_TREE);
   attribute = tree_cons (get_identifier ("aligned"), attribute, NULL_TREE);
   decl_attributes (&decl, attribute, 0);





More information about the llvm-commits mailing list