diff options
Diffstat (limited to 'gcc/config/darwin-c.c')
-rw-r--r-- | gcc/config/darwin-c.c | 55 |
1 files changed, 52 insertions, 3 deletions
diff --git a/gcc/config/darwin-c.c b/gcc/config/darwin-c.c index 08de2f8..a642f66 100644 --- a/gcc/config/darwin-c.c +++ b/gcc/config/darwin-c.c @@ -25,6 +25,7 @@ along with GCC; see the file COPYING3. If not see #include "tm.h" #include "cpplib.h" #include "tree.h" +#include "target.h" #include "incpath.h" #include "c-family/c-common.h" #include "c-family/c-pragma.h" @@ -36,6 +37,7 @@ along with GCC; see the file COPYING3. If not see #include "prefix.h" #include "c-family/c-target.h" #include "c-family/c-target-def.h" +#include "cgraph.h" /* Pragmas. */ @@ -711,13 +713,60 @@ EXPORTED_CONST format_kind_info darwin_additional_format_types[] = { } }; -#undef TARGET_HANDLE_C_OPTION + +/* Support routines to dump the class references for NeXT ABI v1, aka + 32-bits ObjC-2.0, as top-level asms. + The following two functions should only be called from + objc/objc-next-runtime-abi-01.c. */ + +static void +darwin_objc_declare_unresolved_class_reference (const char *name) +{ + const char *lazy_reference = ".lazy_reference\t"; + const char *hard_reference = ".reference\t"; + const char *reference = MACHOPIC_INDIRECT ? lazy_reference : hard_reference; + size_t len = strlen (reference) + strlen(name) + 2; + char *buf = (char *) alloca (len); + + gcc_checking_assert (!strncmp (name, ".objc_class_name_", 17)); + + snprintf (buf, len, "%s%s", reference, name); + add_asm_node (build_string (strlen (buf), buf)); +} + +static void +darwin_objc_declare_class_definition (const char *name) +{ + const char *xname = targetm.strip_name_encoding (name); + size_t len = strlen (xname) + 7 + 5; + char *buf = (char *) alloca (len); + + gcc_checking_assert (!strncmp (name, ".objc_class_name_", 17) + || !strncmp (name, "*.objc_category_name_", 21)); + + /* Mimic default_globalize_label. */ + snprintf (buf, len, ".globl\t%s", xname); + add_asm_node (build_string (strlen (buf), buf)); + + snprintf (buf, len, "%s = 0", xname); + add_asm_node (build_string (strlen (buf), buf)); +} + +#undef TARGET_HANDLE_C_OPTION #define TARGET_HANDLE_C_OPTION handle_c_option -#undef TARGET_OBJC_CONSTRUCT_STRING_OBJECT +#undef TARGET_OBJC_CONSTRUCT_STRING_OBJECT #define TARGET_OBJC_CONSTRUCT_STRING_OBJECT darwin_objc_construct_string -#undef TARGET_STRING_OBJECT_REF_TYPE_P +#undef TARGET_OBJC_DECLARE_UNRESOLVED_CLASS_REFERENCE +#define TARGET_OBJC_DECLARE_UNRESOLVED_CLASS_REFERENCE \ + darwin_objc_declare_unresolved_class_reference + +#undef TARGET_OBJC_DECLARE_CLASS_DEFINITION +#define TARGET_OBJC_DECLARE_CLASS_DEFINITION \ + darwin_objc_declare_class_definition + +#undef TARGET_STRING_OBJECT_REF_TYPE_P #define TARGET_STRING_OBJECT_REF_TYPE_P darwin_cfstring_ref_p #undef TARGET_CHECK_STRING_OBJECT_FORMAT_ARG |