Patchwork libobjc/49883: Applied fix to 4.6 branch as well

login
register
mail settings
Submitter Nicola Pero
Date Oct. 14, 2011, 5:19 p.m.
Message ID <0C46A81D-2420-40A6-9DA6-218C1FBCF1AE@meta-innovation.com>
Download mbox | patch
Permalink /patch/119861/
State New
Headers show

Comments

Nicola Pero - Oct. 14, 2011, 5:19 p.m.
I applied the following patch to backport the fix for libobjc/49883 to GCC 4.6 so that
it appears in 4.6.2.  This is the clang-related problem that was recently discussed.
Again, it's an important fix, but safe, with users (the ObjFW guys) asking for it in 4.6.2,
which made total sense, so I backported the fix and committed it to the 4.6 branch.

Thanks

Patch

Index: init.c
===================================================================
--- init.c	(revision 179967)
+++ init.c	(working copy)
@@ -643,6 +643,15 @@ 
       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;
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 179996)
+++ ChangeLog	(working copy)
@@ -1,6 +1,19 @@ 
 2011-10-14  Nicola Pero  <nicola.pero@meta-innovation.com>
 
 	Backport from mainline
+	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-14  Nicola Pero  <nicola.pero@meta-innovation.com>
+
+	Backport from mainline
 	2011-08-06  Nicola Pero  <nicola.pero@meta-innovation.com>
 
 	PR libobjc/50002