This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: Fix ObjC @"string" machinery



On 28 Jun 2005, at 2.07, David Ayers wrote:
Darwin currently has two sections for storing ObjC strings:
in_objc_string_object and in_objc_constant_string_object
Dependent in the identifier name "NSConstantString" vs.
"NXConstantString" the string is currently created either in one or the
other section.

(Looking at this code (darwin.c machopic_select_section), I would assume
that the feature of selecting the constant string class via
-fconstant-string-class probably only works with one of these two class
names on Darwin.)

No; we have some additional evil Apple-local mods. Or, rather, had; the apple-local-200502-branch already contains the fix that Andrew rightly objected to for mainline. :-)

Here's what it used to look like:

:
if (!strcmp (IDENTIFIER_POINTER (name), "NSConstantString"))
objc_constant_string_object_section ();
else if (!strcmp (IDENTIFIER_POINTER (name), "NXConstantString"))
objc_string_object_section ();
/* APPLE LOCAL begin constant strings */
:
else if (constant_string_class_name
&& !strcmp (IDENTIFIER_POINTER (name),
constant_string_class_name))
{
if (flag_next_runtime) <===============
objc_constant_string_object_section ();
else
objc_string_object_section ();
}
/* APPLE LOCAL end constant strings */
:

I think, the patch is proposing to switch the semantics of choosing the
section from the identifier name to the -fgnu-runtime/-fnext-runtime switch.

Yes, exactly.

The more I think about it, the less I think it is the correct solution, independent of how one would access the flag from that file.

No; it is the current implementation that is broken. The section into which
the string literals are (or should be) spewed out is a function of the target
runtime, and _not_ the name that the string class happens to have.


Currently, if you are compiling for Darwin/NeXT, and say -fconstant-string-class=NXConstantString,
the compiler will stuff the strings into the wrong section.


--Zem
--------------------------------------------------------------
Ziemowit Laski                 1 Infinite Loop, MS 301-2K
Mac OS X Compiler Group        Cupertino, CA USA  95014-2083
Apple Computer, Inc.           +1.408.974.6229  Fax .5477


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]