From ecd616f68067cca5e7051c8872b76311b09d8f45 Mon Sep 17 00:00:00 2001 From: Iain Sandoe Date: Sat, 3 Oct 2020 13:40:03 +0100 Subject: [PATCH] Objective-C, Darwin : Update metadata section uses. Newer versions of ld64 are more picky about adherence to placement rules for objective c metadata. This adds protocol refs and uses the ivar refs for all targets. gcc/ChangeLog: * config/darwin-sections.def (objc2_data_section): New. (objc2_ivar_section): New. * config/darwin.c (darwin_objc2_section): Act on Protocol and ivar refs. gcc/objc/ChangeLog: * objc-next-runtime-abi-02.c (next_runtime_abi_02_init_metadata_attributes): Make protocol refs a distinct section. --- gcc/config/darwin-sections.def | 4 ++++ gcc/config/darwin.c | 6 ++++++ gcc/objc/objc-next-runtime-abi-02.c | 4 ++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/gcc/config/darwin-sections.def b/gcc/config/darwin-sections.def index d3251db..65bf5ad 100644 --- a/gcc/config/darwin-sections.def +++ b/gcc/config/darwin-sections.def @@ -201,6 +201,10 @@ DEF_SECTION (objc2_constant_string_object_section, 0, /* Additions for compatibility with later runtime conventions especially for sections containing strings. */ +DEF_SECTION (objc2_data_section, 0, ".section __DATA, __data", 1) + +DEF_SECTION (objc2_ivar_section, 0, ".section __DATA, __objc_ivar", 1) + DEF_SECTION (objc2_class_names_section, 0, ".section __TEXT, __objc_classname, cstring_literals", 1) diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c index 7eb288e..e101f8e 100644 --- a/gcc/config/darwin.c +++ b/gcc/config/darwin.c @@ -1460,6 +1460,9 @@ darwin_objc2_section (tree decl ATTRIBUTE_UNUSED, tree meta, section * base) else if (!strncmp (p, "G2_META", 7) || !strncmp (p, "G2_CLAS", 7)) return darwin_sections[objc2_classdefs_section]; + else if (!strncmp (p, "V2_PCOL", 7)) + return ld_uses_coal_sects ? darwin_sections[data_coal_section] + : darwin_sections[objc2_data_section]; else if (!strncmp (p, "V2_MREF", 7)) return darwin_sections[objc2_message_refs_section]; else if (!strncmp (p, "V2_CLRF", 7)) @@ -1495,6 +1498,9 @@ darwin_objc2_section (tree decl ATTRIBUTE_UNUSED, tree meta, section * base) else if (!strncmp (p, "V2_CSTR", 7)) return darwin_sections[objc2_constant_string_object_section]; + else if (!strncmp (p, "V2_IVRF", 7)) + return darwin_sections[objc2_ivar_section]; + /* Not recognized, default. */ return base; } diff --git a/gcc/objc/objc-next-runtime-abi-02.c b/gcc/objc/objc-next-runtime-abi-02.c index b4019cd..6d1badc 100644 --- a/gcc/objc/objc-next-runtime-abi-02.c +++ b/gcc/objc/objc-next-runtime-abi-02.c @@ -305,8 +305,8 @@ next_runtime_abi_02_init_metadata_attributes (void) meta_class = get_identifier ("G2_CLAS"); meta_metaclass = get_identifier ("G2_META"); - meta_category = - meta_protocol = meta_base; + meta_category = meta_base; + meta_protocol = get_identifier ("V2_PCOL"); meta_clac_vars = meta_clai_vars = meta_base; -- 2.7.4