Tested on x86_64-darwin, i686-darwin and x86_64-linux, pushed to trunk,
thanks
Iain

--- 8< ---

Darwin-specific preparations for changes to handle the PR:
  Allow metadata to reside in const_data.

  Add ClassList to the cases where we want the symbols to be linker-visible.

  This adds expanded comments on the meaning of the flag fields in the ImageInfo
metadata.

        PR objc/124260

gcc/ChangeLog:

        * config/darwin.cc (darwin_objc2_section): Also allow meta data
        in const_data.
        (darwin_label_is_anonymous_local_objc_name): Make ClassList linker-
        visible.
        (darwin_file_end): Update comments on the ImageInfo flags.  Do not
        claim we have signed pointers.

gcc/testsuite/ChangeLog:

        * objc.dg/image-info.m: Test revised flags value for ABI-2.

Signed-off-by: Iain Sandoe <[email protected]>
---
 gcc/config/darwin.cc               | 20 ++++++++++++++------
 gcc/testsuite/objc.dg/image-info.m |  2 +-
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/gcc/config/darwin.cc b/gcc/config/darwin.cc
index b83e96f20fc..f4726ab0e57 100644
--- a/gcc/config/darwin.cc
+++ b/gcc/config/darwin.cc
@@ -1530,7 +1530,7 @@ darwin_objc2_section (tree decl ATTRIBUTE_UNUSED, tree 
meta, section * base)
 
   objc_metadata_seen = 1;
 
-  if (base == data_section)
+  if (base == data_section || base == darwin_sections[const_data_section])
     base = darwin_sections[objc2_metadata_section];
 
   /* Most of the OBJC2 META-data end up in the base section, so check it
@@ -2041,6 +2041,8 @@ darwin_label_is_anonymous_local_objc_name (const char 
*name)
   p += 6;
   if (startswith ((const char *)p, "ClassRef"))
     return false;
+  else if (startswith ((const char *)p, "ClassList"))
+    return false;
   else if (startswith ((const char *)p, "SelRef"))
     return false;
   else if (startswith ((const char *)p, "Category"))
@@ -3188,21 +3190,27 @@ darwin_file_end (void)
     {
       unsigned int flags = 0;
       if (flag_objc_abi >= 2)
-       {
-         flags = 16;
-          switch_to_section (darwin_sections[objc2_image_info_section]);
-       }
+       switch_to_section (darwin_sections[objc2_image_info_section]);
       else
        switch_to_section (darwin_sections[objc_image_info_section]);
 
       ASM_OUTPUT_ALIGN (asm_out_file, 2);
       fputs ("L_OBJC_ImageInfo:\n", asm_out_file);
 
+      /* Bit 0 - Fix and continue (no longer supported by clang).  */
       flags |= (flag_replace_objc_classes && classes_seen) ? 1 : 0;
+      /* Bit 1 - ObjC "hybrid" GC.  */
       flags |= flag_objc_gc ? 2 : 0;
+      /* Bit 2 - Objc GC only.  */
+      /* Bit 3 - is reserved for dyld.  */
+      /* Bit 4 - is for signed pointers, we cannot yet implement.
+        The original meaning _CorrectedSynthesize has been replaced.  */
+      /* Bit 5 - is built for a simulator (not relevant yet).  */
+      /* Bit 6 - indicates we are generating class properties.  Our code-
+        gen is not yet suited to this.  */
 
       fprintf (asm_out_file, "\t.long\t0\n\t.long\t%u\n", flags);
-     }
+    }
 
   machopic_finish (asm_out_file);
   if (flag_apple_kext)
diff --git a/gcc/testsuite/objc.dg/image-info.m 
b/gcc/testsuite/objc.dg/image-info.m
index b2effe5dc86..50d93186616 100644
--- a/gcc/testsuite/objc.dg/image-info.m
+++ b/gcc/testsuite/objc.dg/image-info.m
@@ -39,4 +39,4 @@ @implementation Base
 @end
 
 /* { dg-final { scan-assembler "\t.section __OBJC, 
__image_info.*\n\t.align.*\nL_OBJC_ImageInfo.*:\n\t.long\t0\n\t.long\t1"  { 
target { *-*-darwin* && { ! lp64 } } } } } */
-/* { dg-final { scan-assembler "\t.section __DATA, 
__objc_imageinfo.*\n\t.align.*\nL_OBJC_ImageInfo.*:\n\t.long\t0\n\t.long\t17" { 
target { *-*-darwin* && { lp64 } } } } } */
+/* { dg-final { scan-assembler "\t.section __DATA, 
__objc_imageinfo.*\n\t.align.*\nL_OBJC_ImageInfo.*:\n\t.long\t0\n\t.long\t1" { 
target { *-*-darwin* && { lp64 } } } } } */
-- 
2.50.1 (Apple Git-155)

Reply via email to