We are able to treat these specially where needed in legitimate address
tests (specifically, they are guaranteed to be pointer-aligned).

tested on x86_64-darwin16, powerpc-darwin9.
applied to mainline,
thanks
Iain

gcc/ChangeLog:

2019-10-09  Iain Sandoe  <i...@sandoe.co.uk>

        * config/darwin.c (machopic_indirect_data_reference): Set flag to
        indicate that the new symbol is an indirection.
        (machopic_indirect_call_target): Likewise.
        * config/darwin.h (MACHO_SYMBOL_FLAG_INDIRECTION): New.
        (MACHO_SYMBOL_INDIRECTION_P): New.
        (MACHO_SYMBOL_FLAG_STATIC): Adjust bit number.

diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c
index 679e0c2291..35d0444b5c 100644
--- a/gcc/config/darwin.c
+++ b/gcc/config/darwin.c
@@ -707,6 +707,7 @@ machopic_indirect_data_reference (rtx orig, rtx reg)
                  machopic_indirection_name (orig, /*stub_p=*/false)));
 
       SYMBOL_REF_DATA (ptr_ref) = SYMBOL_REF_DATA (orig);
+      SYMBOL_REF_FLAGS (ptr_ref) |= MACHO_SYMBOL_FLAG_INDIRECTION;
 
       ptr_ref = gen_const_mem (Pmode, ptr_ref);
       machopic_define_symbol (ptr_ref);
@@ -806,6 +807,7 @@ machopic_indirect_call_target (rtx target)
 
       XEXP (target, 0) = gen_rtx_SYMBOL_REF (mode, stub_name);
       SYMBOL_REF_DATA (XEXP (target, 0)) = SYMBOL_REF_DATA (sym_ref);
+      SYMBOL_REF_FLAGS (XEXP (target, 0)) |= MACHO_SYMBOL_FLAG_INDIRECTION;
       MEM_READONLY_P (target) = 1;
       MEM_NOTRAP_P (target) = 1;
     }
diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index 7fab8694f0..f331fa1aa8 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -843,12 +843,19 @@ extern GTY(()) section * 
darwin_sections[NUM_DARWIN_SECTIONS];
 #define MACHO_SYMBOL_HIDDEN_VIS_P(RTX) \
   ((SYMBOL_REF_FLAGS (RTX) & MACHO_SYMBOL_FLAG_HIDDEN_VIS) != 0)
 
+/* Set on a symbol that is a pic stub or symbol indirection (i.e. the
+   L_xxxxx${stub,non_lazy_ptr,lazy_ptr}.  */
+
+#define MACHO_SYMBOL_FLAG_INDIRECTION ((SYMBOL_FLAG_SUBT_DEP) << 5)
+#define MACHO_SYMBOL_INDIRECTION_P(RTX) \
+  ((SYMBOL_REF_FLAGS (RTX) & MACHO_SYMBOL_FLAG_INDIRECTION) != 0)
+
 /* Set on a symbol to indicate when fix-and-continue style code
    generation is being used and the symbol refers to a static symbol
    that should be rebound from new instances of a translation unit to
    the original instance of the data.  */
 
-#define MACHO_SYMBOL_FLAG_STATIC ((SYMBOL_FLAG_SUBT_DEP) << 5)
+#define MACHO_SYMBOL_FLAG_STATIC ((SYMBOL_FLAG_SUBT_DEP) << 6)
 #define MACHO_SYMBOL_STATIC_P(RTX) \
   ((SYMBOL_REF_FLAGS (RTX) & MACHO_SYMBOL_FLAG_STATIC) != 0)
 

Reply via email to