In libobjc/: 2011-10-09 Nicola Pero <nicola.pero@meta-innovation.com>
authorNicola Pero <nicola.pero@meta-innovation.com>
Sun, 9 Oct 2011 10:29:50 +0000 (10:29 +0000)
committerNicola Pero <nicola@gcc.gnu.org>
Sun, 9 Oct 2011 10:29:50 +0000 (10:29 +0000)
In libobjc/:
2011-10-09  Nicola Pero  <nicola.pero@meta-innovation.com>

PR libobjc/49883
* init.c (__objc_exec_class): Work around a bug in clang's code
generation.  Clang sets the class->info field to values different
from 0x1 or 0x2 (the only allowed values in the traditional GNU
Objective-C runtime ABI) to store some additional information, but
this breaks backwards compatibility.  Wipe out all the bits in the
fields other than the first two upon loading a class.

2011-10-09  Nicola Pero  <nicola.pero@meta-innovation.com>

* class.c (objc_lookup_class): Added back for compatibility with
clang which seems to emit calls to it.

From-SVN: r179721

libobjc/ChangeLog
libobjc/class.c
libobjc/init.c

index f88f2f45cdf682aeb4c99dc38a2fc40be5986434..dbc70f190bb028bdbe81e77688c4316d7380f9d9 100644 (file)
@@ -1,3 +1,18 @@
+2011-10-09  Nicola Pero  <nicola.pero@meta-innovation.com>
+
+       PR libobjc/49883
+       * init.c (__objc_exec_class): Work around a bug in clang's code
+       generation.  Clang sets the class->info field to values different
+       from 0x1 or 0x2 (the only allowed values in the traditional GNU
+       Objective-C runtime ABI) to store some additional information, but
+       this breaks backwards compatibility.  Wipe out all the bits in the
+       fields other than the first two upon loading a class.
+
+2011-10-09  Nicola Pero  <nicola.pero@meta-innovation.com>
+       
+       * class.c (objc_lookup_class): Added back for compatibility with
+       clang which seems to emit calls to it.
+
 2011-10-08  Richard Frith-Macdonald <rfm@gnu.org>
             Nicola Pero  <nicola.pero@meta-innovation.com>
 
index edc56aa9ec4d2679e7b8f8e53f6b67bd7785e797..3b750829f3bc232ab9514102c0a3542ff3bae6d0 100644 (file)
@@ -764,6 +764,15 @@ objc_get_meta_class (const char *name)
   return objc_get_class (name)->class_pointer;
 }
 
+/* This is not used by GCC, but the clang compiler seems to use it
+   when targetting the GNU runtime.  That's wrong, but we have it to
+   be compatible.  */
+Class
+objc_lookup_class (const char *name)
+{
+  return objc_getClass (name);
+}
+
 /* This is used when the implementation of a method changes.  It goes
    through all classes, looking for the ones that have these methods
    (either method_a or method_b; method_b can be NULL), and reloads
index d4475b3b787a3742a0952bfc64099a7b591137f9..23ba41ba128b04ad52b1cc71c9bc22a34d4f78af 100644 (file)
@@ -643,6 +643,15 @@ __objc_exec_class (struct objc_module *module)
       assert (CLS_ISMETA (class->class_pointer));
       DEBUG_PRINTF (" installing class '%s'\n", class->name);
 
+      /* Workaround for a bug in clang: Clang may set flags other than
+        _CLS_CLASS and _CLS_META even when compiling for the
+        traditional ABI (version 8), confusing our runtime.  Try to
+        wipe these flags out.  */
+      if (CLS_ISCLASS (class))
+       __CLS_INFO (class) = _CLS_CLASS;
+      else
+       __CLS_INFO (class) = _CLS_META;
+
       /* Initialize the subclass list to be NULL.  In some cases it
         isn't and this crashes the program.  */
       class->subclass_list = NULL;