From 8703bf5d31fdb4789b5eddca394f8e92a0c55801 Mon Sep 17 00:00:00 2001 From: Iain Sandoe Date: Sun, 4 Oct 2020 10:09:57 +0100 Subject: Darwin, Objective-C : Adjust objective-c symbol linkage with version. Earlier linkers cannot handle publicly-visible (or linker-visible) metadata, so we need to make the output of these conditional on version. gcc/ChangeLog: * config/darwin.c (darwin_globalize_label): Make a subset of metadate symbols global. (darwin_label_is_anonymous_local_objc_name): Make a subset of metadata symbols linker-visible. (darwin_override_options): Track more target OS versions, make the next_runtime version track this (unless it's set to 0 for GNU runtime). gcc/objc/ChangeLog: * objc-next-runtime-abi-02.c (FIXUP_NEEDED): Rename ... (USE_FIXUP_BEFORE): ... to this. (next_runtime_02_initialize): Likewise. (next_runtime_abi_02_get_arg_type_list_base): Likewise. (next_runtime_abi_02_build_objc_method_call): Likewise. --- gcc/config/darwin.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'gcc/config/darwin.c') diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c index 33c6ce4..dd4857f 100644 --- a/gcc/config/darwin.c +++ b/gcc/config/darwin.c @@ -1876,7 +1876,10 @@ darwin_globalize_label (FILE *stream, const char *name) { if (!!strncmp (name, "_OBJC_", 6)) default_globalize_label (stream, name); - /* We have some Objective C cases that need to be global. */ + /* We have some Objective C cases that need to be global, but only on newer + OS versions. */ + if (flag_objc_abi < 2 || flag_next_runtime < 100700) + return; if (!strncmp (name+6, "LabelPro", 8)) default_globalize_label (stream, name); if (!strncmp (name+6, "Protocol_", 9)) @@ -1901,8 +1904,14 @@ darwin_label_is_anonymous_local_objc_name (const char *name) } if (strncmp ((const char *)p, "_OBJC_", 6) != 0) return false; + /* We need some of the objective c meta-data symbols to be visible to the - linker. FIXME: this is horrible, we need a better mechanism. */ + linker (when the target OS version is newer). FIXME: this is horrible, + we need a better mechanism. */ + + if (flag_objc_abi < 2 || flag_next_runtime < 100700) + return true; + p += 6; if (!strncmp ((const char *)p, "ClassRef", 8)) return false; @@ -3183,10 +3192,14 @@ darwin_override_options (void) /* Keep track of which (major) version we're generating code for. */ if (darwin_macosx_version_min) { - if (strverscmp (darwin_macosx_version_min, "10.6") >= 0) + if (strverscmp (darwin_macosx_version_min, "10.7") >= 0) + generating_for_darwin_version = 11; + else if (strverscmp (darwin_macosx_version_min, "10.6") >= 0) generating_for_darwin_version = 10; else if (strverscmp (darwin_macosx_version_min, "10.5") >= 0) generating_for_darwin_version = 9; + else if (strverscmp (darwin_macosx_version_min, "10.4") >= 0) + generating_for_darwin_version = 8; /* Earlier versions are not specifically accounted, until required. */ } @@ -3202,6 +3215,20 @@ darwin_override_options (void) should check for correctness re. the ABI. TODO: check and provide the flags (runtime & ABI) from the lto wrapper). */ + /* At present, make a hard update to the runtime version based on the target + OS version. */ + if (flag_next_runtime) + { + if (generating_for_darwin_version > 10) + flag_next_runtime = 100705; + else if (generating_for_darwin_version > 9) + flag_next_runtime = 100608; + else if (generating_for_darwin_version > 8) + flag_next_runtime = 100508; + else + flag_next_runtime = 100000; + } + /* Unless set, force ABI=2 for NeXT and m64, 0 otherwise. */ if (!global_options_set.x_flag_objc_abi) global_options.x_flag_objc_abi -- cgit v1.1