]> gcc.gnu.org Git - gcc.git/commitdiff
update darwin x86 output.
authorIain Sandoe <iains@gcc.gnu.org>
Tue, 2 Nov 2010 14:40:03 +0000 (14:40 +0000)
committerIain Sandoe <iains@gcc.gnu.org>
Tue, 2 Nov 2010 14:40:03 +0000 (14:40 +0000)
gcc:
Merge from FSF "apple/trunk" branch.

* config/rs6000/darwin.opt (mdynamic-no-pic): move from here ...
* config/darwin.opt: .. to here.
(matt-stubs): New option.
* config/i386/darwin.opt: Delete.
* config/i386/i386.h (MACHOPIC_ATT_STUB): New.
(MACHO_DYNAMIC_NO_PIC_P): New.
(MACHOPIC_INDIRECT): New.
(MACHOPIC_PURE): New.
* config/i386/darwin.h (DARWIN_X86) Define to 1.
(MACHOPIC_ATT_STUB): New.
(CC1_SPEC): Do not remove mdynamic-no-pic.
Move HOT_TEXT_SECTION_NAME: move to config/darwin.h
UNLIKELY_EXECUTED_TEXT_SECTION_NAME: Likewise.
(FUNCTION_PROFILER): Correct over-length line.
(SUBTARGET_OVERRIDE_OPTIONS): New.
(MACHOPIC_NL_SYMBOL_PTR_SECTION): New.
* config/i386/i386.c (config/i386/i386.c): Darwin has no PLT.
(legitimate_constant_p): Handle mdynamic-no-pic.
(ix86_legitimate_address_p): Likewise.
(ix86_legitimize_address): Likewise.
(ix86_expand_move): Likewise.
(machopic_output_stub): Update for ATT-style stubs and
mdynamic-no-pic.
* config/darwin-protos.h (machopic_symbol_defined_p): New.
* config/rs6000/darwin.h (DARWIN_PPC): Define to 1.
TARGET_DYNAMIC_NO_PIC: Remove.
Move HOT_TEXT_SECTION_NAME: move to config/darwin.h
UNLIKELY_EXECUTED_TEXT_SECTION_NAME: Likewise.
* config/rs6000/rs6000.c (darwin_rs6000_override_options):
Remove handling of mdynamic-no-pic.
* config/darwin.c (HAVE_lo_sum, gen_macho_high, gen_macho_low):
Define if required.
(machopic_symbol_defined_p): Do not try to use current_function_decl
when generating _get_pc thunks within stubs.
(machopic_indirect_data_reference): Rework for direct conditionals
rather than #ifdefs, add x86 mdynamic-no-pic
(machopic_legitimize_pic_address): Update to use HAVE_lo_sum with a
defined value.
(darwin_override_options): Handle mdynamic-no-pic here.
* config/darwin-sections.def (machopic_lazy_symbol_ptr2_section): New.
(machopic_lazy_symbol_ptr3_section): New.
(machopic_picsymbol_stub2_section): New.
(machopic_picsymbol_stub3_section): New.
* config/darwin.h (DARWIN_X86, DARWIN_PPC): Define to 0.
(MACHOPIC_NL_SYMBOL_PTR_SECTION): New.
(HOT_TEXT_SECTION_NAME, UNLIKELY_EXECUTED_TEXT_SECTION_NAME):
Moved common definition from x86 and rs6000.
(MACHO_DYNAMIC_NO_PIC_P): Override value.
(MACHOPIC_INDIRECT): Likewise.
(MACHOPIC_PURE): Likewise.
* config.gcc (x86-darwin-*): Remove darwin.opt.

From-SVN: r166184

14 files changed:
gcc/ChangeLog
gcc/config.gcc
gcc/config/darwin-protos.h
gcc/config/darwin-sections.def
gcc/config/darwin.c
gcc/config/darwin.h
gcc/config/darwin.opt
gcc/config/i386/darwin.h
gcc/config/i386/darwin.opt [deleted file]
gcc/config/i386/i386.c
gcc/config/i386/i386.h
gcc/config/rs6000/darwin.h
gcc/config/rs6000/darwin.opt
gcc/config/rs6000/rs6000.c

index f46c18f7ce8e4db046247dcd7cdfcc9b667a8d32..f16a43670032492d6dd0756bb370f794ecab9972 100644 (file)
@@ -1,3 +1,59 @@
+2010-11-02  Iain Sandoe  <iains@gcc.gnu.org>
+
+       Merge from FSF "apple/trunk" branch.
+
+       * config/rs6000/darwin.opt (mdynamic-no-pic): move from here ...
+       * config/darwin.opt: .. to here.
+       (matt-stubs): New option.
+       * config/i386/darwin.opt: Delete.
+       * config/i386/i386.h (MACHOPIC_ATT_STUB): New.
+       (MACHO_DYNAMIC_NO_PIC_P): New.
+       (MACHOPIC_INDIRECT): New.
+       (MACHOPIC_PURE): New.
+       * config/i386/darwin.h (DARWIN_X86) Define to 1.
+       (MACHOPIC_ATT_STUB): New.
+       (CC1_SPEC): Do not remove mdynamic-no-pic.
+       Move HOT_TEXT_SECTION_NAME: move to config/darwin.h
+       UNLIKELY_EXECUTED_TEXT_SECTION_NAME: Likewise.
+       (FUNCTION_PROFILER): Correct over-length line.
+       (SUBTARGET_OVERRIDE_OPTIONS): New.
+       (MACHOPIC_NL_SYMBOL_PTR_SECTION): New.
+       * config/i386/i386.c (config/i386/i386.c): Darwin has no PLT.
+       (legitimate_constant_p): Handle mdynamic-no-pic.
+       (ix86_legitimate_address_p): Likewise.
+       (ix86_legitimize_address): Likewise.
+       (ix86_expand_move): Likewise.
+       (machopic_output_stub): Update for ATT-style stubs and
+       mdynamic-no-pic.
+       * config/darwin-protos.h (machopic_symbol_defined_p): New.
+       * config/rs6000/darwin.h (DARWIN_PPC): Define to 1.
+       TARGET_DYNAMIC_NO_PIC: Remove.
+       Move HOT_TEXT_SECTION_NAME: move to config/darwin.h
+       UNLIKELY_EXECUTED_TEXT_SECTION_NAME: Likewise.
+       * config/rs6000/rs6000.c (darwin_rs6000_override_options):
+       Remove handling of mdynamic-no-pic.
+       * config/darwin.c (HAVE_lo_sum, gen_macho_high, gen_macho_low):
+       Define if required.
+       (machopic_symbol_defined_p): Do not try to use current_function_decl
+       when generating _get_pc thunks within stubs.
+       (machopic_indirect_data_reference): Rework for direct conditionals 
+       rather than #ifdefs, add x86 mdynamic-no-pic
+       (machopic_legitimize_pic_address): Update to use HAVE_lo_sum with a
+       defined value.
+       (darwin_override_options): Handle mdynamic-no-pic here.
+       * config/darwin-sections.def (machopic_lazy_symbol_ptr2_section): New.
+       (machopic_lazy_symbol_ptr3_section): New.
+       (machopic_picsymbol_stub2_section): New.
+       (machopic_picsymbol_stub3_section): New.
+       * config/darwin.h (DARWIN_X86, DARWIN_PPC): Define to 0.
+       (MACHOPIC_NL_SYMBOL_PTR_SECTION): New.
+       (HOT_TEXT_SECTION_NAME, UNLIKELY_EXECUTED_TEXT_SECTION_NAME):
+       Moved common definition from x86 and rs6000.
+       (MACHO_DYNAMIC_NO_PIC_P): Override value.
+       (MACHOPIC_INDIRECT): Likewise.
+       (MACHOPIC_PURE): Likewise.
+       * config.gcc (x86-darwin-*): Remove darwin.opt.
+
 2010-11-02  Jakub Jelinek  <jakub@redhat.com>
 
        PR debug/46255
index 64eaaefa3d2b3c62cb39af8278bbcc8d186f453e..8dce3d55a85a0fd318e21bcf894e19ff20295536 100644 (file)
@@ -1160,14 +1160,12 @@ i[34567]86-*-darwin*)
        # support.
        with_cpu=${with_cpu:-generic}
        tmake_file="${tmake_file} t-slibgcc-darwin i386/t-crtpc i386/t-crtfm"
-       extra_options="${extra_options} i386/darwin.opt"
        lto_binary_reader=lto-macho
        ;;
 x86_64-*-darwin*)
        with_cpu=${with_cpu:-generic}
        tmake_file="${tmake_file} ${cpu_type}/t-darwin64 t-slibgcc-darwin i386/t-crtpc i386/t-crtfm"
        tm_file="${tm_file} ${cpu_type}/darwin64.h"
-       extra_options="${extra_options} i386/darwin.opt"
        lto_binary_reader=lto-macho
        ;;
 i[34567]86-*-elf*)
index 75cf249990060cf69c380f42eac3da677d04ddcf..30b3f822c98978facb991d5b8c664358ef13b235 100644 (file)
@@ -1,5 +1,5 @@
 /* Prototypes.
-   Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007, 2008
+   Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2010
    Free Software Foundation, Inc.
 
 This file is part of GCC.
@@ -31,6 +31,7 @@ extern const char *machopic_mcount_stub_name (void);
 
 extern rtx machopic_gen_offset (rtx);
 extern int machopic_operand_p (rtx);
+extern int machopic_symbol_defined_p (rtx sym_ref);
 extern enum machopic_addr_class machopic_classify_symbol (rtx);
 
 extern rtx machopic_indirect_data_reference (rtx, rtx);
index a7fa968279a722aacbfc344d1b953301de38c748..476d9aa018cabe5bec005374d20a79c6131d4977 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2005, 2006, 2010 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -66,17 +66,30 @@ DEF_SECTION (objc_class_names_section, 0, ".objc_class_names", 1)
 DEF_SECTION (objc_meth_var_names_section, 0, ".objc_meth_var_names", 1)
 DEF_SECTION (objc_meth_var_types_section, 0, ".objc_meth_var_types", 1)
 DEF_SECTION (objc_cls_refs_section, SECTION_MERGE, ".objc_cls_refs", 1)
-
+/* lazy symbol pointers.  */
 DEF_SECTION (machopic_lazy_symbol_ptr_section, 0, ".lazy_symbol_pointer", 0)
-DEF_SECTION (machopic_nl_symbol_ptr_section, 0, ".non_lazy_symbol_pointer", 0)
+DEF_SECTION (machopic_lazy_symbol_ptr2_section,        0,
+            ".section __DATA, __la_sym_ptr2,lazy_symbol_pointers", 0)
+DEF_SECTION (machopic_lazy_symbol_ptr3_section, 0,
+            ".section __DATA, __la_sym_ptr3,lazy_symbol_pointers", 0)
+/* non-lazy symbol pointers.  */
+DEF_SECTION (machopic_nl_symbol_ptr_section, 0,
+            MACHOPIC_NL_SYMBOL_PTR_SECTION, 0)
+/* Symbol stubs.  */
 DEF_SECTION (machopic_symbol_stub_section, 0, ".symbol_stub", 0)
 DEF_SECTION (machopic_symbol_stub1_section, 0,
             ".section __TEXT,__symbol_stub1,symbol_stubs,"
             "pure_instructions,16", 0)
+/* PIC symbol stubs.  */
 DEF_SECTION (machopic_picsymbol_stub_section, 0, ".picsymbol_stub", 0)
 DEF_SECTION (machopic_picsymbol_stub1_section, 0,
             ".section __TEXT,__picsymbolstub1,symbol_stubs,"
             "pure_instructions,32", 0)
+DEF_SECTION (machopic_picsymbol_stub2_section, 0,
+            ".section __TEXT,__picsymbolstub2,symbol_stubs,pure_instructions,25", 0)
+DEF_SECTION (machopic_picsymbol_stub3_section, 0,
+            ".section __IMPORT,__jump_table,symbol_stubs,self_modifying_code+pure_instructions,5", 0)
+/* Exception-related.  */
 DEF_SECTION (darwin_exception_section, 0,
             ".section __DATA,__gcc_except_tab", 0)
 DEF_SECTION (darwin_eh_frame_section, 0,
index 210421cd2a78f95e8d5f6b86259c4f2da9152274..79b42725f488d45b114ca12ce4859c2294ba0d39 100644 (file)
@@ -95,6 +95,13 @@ int darwin_running_cxx;
 /* Section names.  */
 section * darwin_sections[NUM_DARWIN_SECTIONS];
 
+/* While we transition to using in-tests instead of ifdef'd code.  */
+#ifndef HAVE_lo_sum
+#define HAVE_lo_sum 0
+#define gen_macho_high(a,b) (a)
+#define gen_macho_low(a,b,c) (a)
+#endif
+
 /* True if we're setting __attribute__ ((ms_struct)).  */
 int darwin_ms_struct = false;
 
@@ -179,7 +186,7 @@ name_needs_quotes (const char *name)
 }
 
 /* Return true if SYM_REF can be used without an indirection.  */
-static int
+int
 machopic_symbol_defined_p (rtx sym_ref)
 {
   if (SYMBOL_REF_FLAGS (sym_ref) & MACHO_SYMBOL_FLAG_DEFINED)
@@ -319,12 +326,22 @@ machopic_output_function_base_name (FILE *file)
 
   /* If dynamic-no-pic is on, we should not get here.  */
   gcc_assert (!MACHO_DYNAMIC_NO_PIC_P);
-  current_name =
-    IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl));
-  if (function_base_func_name != current_name)
+  /* When we are generating _get_pc thunks within stubs, there is no current
+     function.  */
+  if (current_function_decl)
+    {
+      current_name =
+       IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl));
+      if (function_base_func_name != current_name)
+       {
+         ++current_pic_label_num;
+         function_base_func_name = current_name;
+       }
+    }
+  else
     {
       ++current_pic_label_num;
-      function_base_func_name = current_name;
+      function_base_func_name = "L_machopic_stub_dummy";
     }
   fprintf (file, "L%011d$pb", current_pic_label_num);
 }
@@ -514,24 +531,28 @@ machopic_indirect_data_reference (rtx orig, rtx reg)
 
       if (defined && MACHO_DYNAMIC_NO_PIC_P)
        {
-#if defined (TARGET_TOC)
+         if (DARWIN_PPC)
+           {
          /* Create a new register for CSE opportunities.  */
          rtx hi_reg = (!can_create_pseudo_p () ? reg : gen_reg_rtx (Pmode));
          emit_insn (gen_macho_high (hi_reg, orig));
          emit_insn (gen_macho_low (reg, hi_reg, orig));
-#else
+             return reg;
+           }
+         else if (DARWIN_X86)
+           return orig;
+         else
           /* some other cpu -- writeme!  */
           gcc_unreachable ();
-#endif
-          return reg;
        }
       else if (defined)
        {
-#if defined (TARGET_TOC) || defined (HAVE_lo_sum)
-         rtx offset = machopic_gen_offset (orig);
-#endif
+         rtx offset = NULL;
+         if (DARWIN_PPC || HAVE_lo_sum)
+           offset = machopic_gen_offset (orig);
 
-#if defined (TARGET_TOC) /* i.e., PowerPC */
+         if (DARWIN_PPC)
+           {
          rtx hi_sum_reg = (!can_create_pseudo_p ()
                            ? reg
                            : gen_reg_rtx (Pmode));
@@ -546,8 +567,9 @@ machopic_indirect_data_reference (rtx orig, rtx reg)
                                                  copy_rtx (offset))));
 
          orig = reg;
-#else
-#if defined (HAVE_lo_sum)
+           }
+         else if (HAVE_lo_sum)
+           {
          gcc_assert (reg);
 
          emit_insn (gen_rtx_SET (VOIDmode, reg,
@@ -558,8 +580,7 @@ machopic_indirect_data_reference (rtx orig, rtx reg)
          emit_use (pic_offset_table_rtx);
 
          orig = gen_rtx_PLUS (Pmode, pic_offset_table_rtx, reg);
-#endif
-#endif
+           }
          return orig;
        }
 
@@ -572,24 +593,56 @@ machopic_indirect_data_reference (rtx orig, rtx reg)
       ptr_ref = gen_const_mem (Pmode, ptr_ref);
       machopic_define_symbol (ptr_ref);
 
+      if (DARWIN_X86 
+          && reg 
+          && MACHO_DYNAMIC_NO_PIC_P)
+       {
+           emit_insn (gen_rtx_SET (Pmode, reg, ptr_ref));
+           ptr_ref = reg;
+       }
+
       return ptr_ref;
     }
   else if (GET_CODE (orig) == CONST)
     {
-      rtx base, result;
-
-      /* legitimize both operands of the PLUS */
+      /* If "(const (plus ...", walk the PLUS and return that result.
+        PLUS processing (below) will restore the "(const ..." if
+        appropriate.  */
       if (GET_CODE (XEXP (orig, 0)) == PLUS)
+       return machopic_indirect_data_reference (XEXP (orig, 0), reg);
+      else 
+       return orig;
+    }
+  else if (GET_CODE (orig) == MEM)
+    {
+      XEXP (ptr_ref, 0) = 
+               machopic_indirect_data_reference (XEXP (orig, 0), reg);
+      return ptr_ref;
+    }
+  else if (GET_CODE (orig) == PLUS)
+    {
+      rtx base, result;
+      /* When the target is i386, this code prevents crashes due to the
+       compiler's ignorance on how to move the PIC base register to
+       other registers.  (The reload phase sometimes introduces such
+       insns.)  */
+      if (GET_CODE (XEXP (orig, 0)) == REG
+          && REGNO (XEXP (orig, 0)) == PIC_OFFSET_TABLE_REGNUM
+          /* Prevent the same register from being erroneously used
+             as both the base and index registers.  */
+          && (DARWIN_X86 && (GET_CODE (XEXP (orig, 1)) == CONST))
+          && reg)
        {
-         base = machopic_indirect_data_reference (XEXP (XEXP (orig, 0), 0),
-                                                  reg);
-         orig = machopic_indirect_data_reference (XEXP (XEXP (orig, 0), 1),
-                                                  (base == reg ? 0 : reg));
+         emit_move_insn (reg, XEXP (orig, 0));
+         XEXP (ptr_ref, 0) = reg;
+         return ptr_ref;
        }
-      else
-       return orig;
 
-      if (MACHOPIC_PURE && GET_CODE (orig) == CONST_INT)
+      /* Legitimize both operands of the PLUS.  */
+      base = machopic_indirect_data_reference (XEXP (orig, 0), reg);
+      orig = machopic_indirect_data_reference (XEXP (orig, 1),
+                                              (base == reg ? 0 : reg));
+      if (MACHOPIC_INDIRECT && (GET_CODE (orig) == CONST_INT))
        result = plus_constant (base, INTVAL (orig));
       else
        result = gen_rtx_PLUS (Pmode, base, orig);
@@ -608,26 +661,6 @@ machopic_indirect_data_reference (rtx orig, rtx reg)
        }
 
       return result;
-
-    }
-  else if (GET_CODE (orig) == MEM)
-    XEXP (ptr_ref, 0) = machopic_indirect_data_reference (XEXP (orig, 0), reg);
-  /* When the target is i386, this code prevents crashes due to the
-     compiler's ignorance on how to move the PIC base register to
-     other registers.  (The reload phase sometimes introduces such
-     insns.)  */
-  else if (GET_CODE (orig) == PLUS
-          && GET_CODE (XEXP (orig, 0)) == REG
-          && REGNO (XEXP (orig, 0)) == PIC_OFFSET_TABLE_REGNUM
-#ifdef I386
-          /* Prevent the same register from being erroneously used
-             as both the base and index registers.  */
-          && GET_CODE (XEXP (orig, 1)) == CONST
-#endif
-          && reg)
-    {
-      emit_move_insn (reg, XEXP (orig, 0));
-      XEXP (ptr_ref, 0) = reg;
     }
   return ptr_ref;
 }
@@ -697,7 +730,7 @@ machopic_legitimize_pic_address (rtx orig, enum machine_mode mode, rtx reg)
              reg = gen_reg_rtx (Pmode);
            }
 
-#ifdef HAVE_lo_sum
+#if HAVE_lo_sum
          if (MACHO_DYNAMIC_NO_PIC_P
              && (GET_CODE (XEXP (orig, 0)) == SYMBOL_REF
                  || GET_CODE (XEXP (orig, 0)) == LABEL_REF))
@@ -792,7 +825,7 @@ machopic_legitimize_pic_address (rtx orig, enum machine_mode mode, rtx reg)
       else
        {
 
-#ifdef HAVE_lo_sum
+#if HAVE_lo_sum
          if (GET_CODE (orig) == SYMBOL_REF
              || GET_CODE (orig) == LABEL_REF)
            {
@@ -1963,6 +1996,18 @@ darwin_override_options (void)
       && debug_hooks->var_location != do_nothing_debug_hooks.var_location)
     flag_var_tracking_uninit = 1;
 
+  if (MACHO_DYNAMIC_NO_PIC_P)
+    {
+      if (flag_pic)
+       warning (0, "-mdynamic-no-pic overrides -fpic or -fPIC");
+      flag_pic = 0;
+    }
+  else if (flag_pic == 1)
+    {
+      /* Darwin's -fpic is -fPIC.  */
+      flag_pic = 2;
+    }
+
   /* It is assumed that branch island stubs are needed for earlier systems.  */
   if (darwin_macosx_version_min
       && strverscmp (darwin_macosx_version_min, "10.5") < 0)
index c488db221030848974b9a6328f98dde87ffb9ff5..438b7e03c4cccde99978d25378ae6070677b2ca1 100644 (file)
@@ -42,7 +42,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    like a.out and partly like COFF, with additional features like
    multi-architecture binary support.  */
 
-#define OBJECT_FORMAT_MACHO
+#define DARWIN_X86 0
+#define DARWIN_PPC 0
 
 /* Don't assume anything about the header files.  */
 #define NO_IMPLICIT_EXTERN_C
@@ -720,6 +721,14 @@ int darwin_label_is_anonymous_local_objc_name (const char *name);
 #undef MAX_OFILE_ALIGNMENT
 #define MAX_OFILE_ALIGNMENT (0x8000 * 8)
 
+/* The generic version, archs should over-ride where required.  */
+#define MACHOPIC_NL_SYMBOL_PTR_SECTION ".non_lazy_symbol_pointer"
+
+/* These are used by -fbranch-probabilities */
+#define HOT_TEXT_SECTION_NAME "__TEXT,__text,regular,pure_instructions"
+#define UNLIKELY_EXECUTED_TEXT_SECTION_NAME \
+                              "__TEXT,__unlikely,regular,pure_instructions"
+
 /* Declare the section variables.  */
 #ifndef USED_FOR_TARGET
 enum darwin_section_enum {
@@ -820,9 +829,12 @@ enum machopic_addr_class {
 
 /* Macros defining the various PIC cases.  */
 
-#define MACHO_DYNAMIC_NO_PIC_P (TARGET_DYNAMIC_NO_PIC)
+#undef  MACHO_DYNAMIC_NO_PIC_P
+#define MACHO_DYNAMIC_NO_PIC_P (TARGET_MACHO_DYNAMIC_NO_PIC)
+#undef  MACHOPIC_INDIRECT
 #define MACHOPIC_INDIRECT      (flag_pic || MACHO_DYNAMIC_NO_PIC_P)
 #define MACHOPIC_JUST_INDIRECT (MACHO_DYNAMIC_NO_PIC_P)
+#undef  MACHOPIC_PURE
 #define MACHOPIC_PURE          (flag_pic && ! MACHO_DYNAMIC_NO_PIC_P)
 
 #undef TARGET_ENCODE_SECTION_INFO
index 4435fea09870cd1a56403147fd5083ec88c06a6a..fac30bbd2bd46b8f5aea25f9d47aad40e02ac9b6 100644 (file)
@@ -26,6 +26,15 @@ Wnonportable-cfstrings
 Target Report Var(darwin_warn_nonportable_cfstrings) Init(1) Warning
 Warn if constant CFString objects contain non-portable characters
 
+; Use new-style pic stubs if this is true, x86 only so far.
+matt-stubs
+Target Report Var(darwin_macho_att_stub) Init(1)
+Generate AT&T-style stubs for Mach-O
+
+mdynamic-no-pic
+Target Common Report Mask(MACHO_DYNAMIC_NO_PIC)
+Generate code suitable for executables (NOT shared libs)
+
 mfix-and-continue
 Target Report Var(darwin_fix_and_continue)
 Generate code suitable for fast turn around debugging
index 6f0b23ec81501776373e9bc22c94f0efa47f914c..7c4ed633b181812b84bdc89bb823c806939808e2 100644 (file)
@@ -23,6 +23,9 @@ along with GCC; see the file COPYING3.  If not see
 #undef TARGET_MACHO
 #define TARGET_MACHO 1
 
+#undef DARWIN_X86
+#define DARWIN_X86 1
+
 #define TARGET_VERSION fprintf (stderr, " (i686 Darwin)");
 
 #undef  TARGET_64BIT
@@ -66,6 +69,11 @@ extern int darwin_emit_branch_islands;
 #undef TARGET_MACHO_BRANCH_ISLANDS
 #define TARGET_MACHO_BRANCH_ISLANDS darwin_emit_branch_islands
 
+/* For compatibility with OSX system tools, use the new style of pic stub
+   if this is set.  */
+#undef  MACHOPIC_ATT_STUB
+#define MACHOPIC_ATT_STUB (darwin_macho_att_stub)
+
 #undef MAX_BITS_PER_WORD
 #define MAX_BITS_PER_WORD 64
 
@@ -100,7 +108,6 @@ extern int darwin_emit_branch_islands;
 
 #undef CC1_SPEC
 #define CC1_SPEC "%(cc1_cpu) \
-  %<mdynamic-no-pic " /* For now, we just ignore this flag */ " \
   %{!mkernel:%{!static:%{!mdynamic-no-pic:-fPIC}}} \
   %{!mmacosx-version-min=*:-mmacosx-version-min=%(darwin_minversion)} \
   %{g: %{!fno-eliminate-unused-debug-symbols: -feliminate-unused-debug-symbols }}"
@@ -182,11 +189,6 @@ extern int darwin_emit_branch_islands;
 #undef TARGET_SUBTARGET64_ISA_DEFAULT
 #define TARGET_SUBTARGET64_ISA_DEFAULT TARGET_SUBTARGET32_ISA_DEFAULT
 
-/* For now, disable dynamic-no-pic.  We'll need to go through i386.c
-   with a fine-tooth comb looking for refs to flag_pic!  */
-#define MASK_MACHO_DYNAMIC_NO_PIC 0
-#define TARGET_DYNAMIC_NO_PIC    (target_flags & MASK_MACHO_DYNAMIC_NO_PIC)
-
 #undef GOT_SYMBOL_NAME
 #define GOT_SYMBOL_NAME MACHOPIC_FUNCTION_BASE_NAME
 
@@ -194,11 +196,6 @@ extern int darwin_emit_branch_islands;
 
 #define LPREFIX "L"
 
-/* These are used by -fbranch-probabilities */
-#define HOT_TEXT_SECTION_NAME "__TEXT,__text,regular,pure_instructions"
-#define UNLIKELY_EXECUTED_TEXT_SECTION_NAME \
-                              "__TEXT,__unlikely,regular,pure_instructions"
-
 /* Assembler pseudos to introduce constants of various size.  */
 
 #define ASM_BYTE "\t.byte\t"
@@ -239,7 +236,8 @@ extern int darwin_emit_branch_islands;
 #undef FUNCTION_PROFILER
 #define FUNCTION_PROFILER(FILE, LABELNO)                               \
     do {                                                               \
-      if (TARGET_MACHO_BRANCH_ISLANDS && MACHOPIC_INDIRECT && !TARGET_64BIT)           \
+      if (TARGET_MACHO_BRANCH_ISLANDS                                  \
+          && MACHOPIC_INDIRECT && !TARGET_64BIT)                       \
        {                                                               \
          const char *name = machopic_mcount_stub_name ();              \
          fprintf (FILE, "\tcall %s\n", name+1);  /*  skip '&'  */      \
@@ -253,6 +251,13 @@ extern int darwin_emit_branch_islands;
     SUBTARGET_C_COMMON_OVERRIDE_OPTIONS;                               \
   } while (0)
 
+#undef SUBTARGET_OVERRIDE_OPTIONS
+#define SUBTARGET_OVERRIDE_OPTIONS \
+do {                                                                   \
+  if (TARGET_64BIT && MACHO_DYNAMIC_NO_PIC_P)                          \
+    target_flags &= ~MASK_MACHO_DYNAMIC_NO_PIC;                                \
+} while (0)
+
 /* Darwin on x86_64 uses dwarf-2 by default.  Pre-darwin9 32-bit
    compiles default to stabs+.  darwin9+ defaults to dwarf-2.  */
 #ifndef DARWIN_PREFER_DWARF
@@ -313,6 +318,10 @@ extern int darwin_emit_branch_islands;
 #undef MACHO_SYMBOL_FLAG_VARIABLE
 #define MACHO_SYMBOL_FLAG_VARIABLE ((SYMBOL_FLAG_MACH_DEP) << 3)
 
+#undef MACHOPIC_NL_SYMBOL_PTR_SECTION
+#define MACHOPIC_NL_SYMBOL_PTR_SECTION \
+               ".section __IMPORT,__pointers,non_lazy_symbol_pointers"
+
 #define SUBTARGET32_DEFAULT_CPU "i686"
 
 #undef  SUBTARGET_INIT_BUILTINS
diff --git a/gcc/config/i386/darwin.opt b/gcc/config/i386/darwin.opt
deleted file mode 100644 (file)
index 89726d8..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-; Darwin options for IA32 port.
-;
-; Copyright (C) 2010 Free Software Foundation, Inc.
-;
-; This file is part of GCC.
-;
-; GCC is free software; you can redistribute it and/or modify it under
-; the terms of the GNU General Public License as published by the Free
-; Software Foundation; either version 3, or (at your option) any later
-; version.
-;
-; GCC is distributed in the hope that it will be useful, but WITHOUT
-; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-; or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
-; License for more details.
-;
-; You should have received a copy of the GNU General Public License
-; along with GCC; see the file COPYING3.  If not see
-; <http://www.gnu.org/licenses/>.
-
-mdynamic-no-pic
-Target RejectNegative Ignore
index e38f2cc155684f3c85549037d195afd49beec74b..eb3e623925db9e1716f3a82c07d47b5660dd8c88 100644 (file)
@@ -4974,8 +4974,11 @@ ix86_function_ok_for_sibcall (tree decl, tree exp)
 
   /* If we are generating position-independent code, we cannot sibcall
      optimize any indirect call, or a direct call to a global function,
-     as the PLT requires %ebx be live.  */
-  if (!TARGET_64BIT && flag_pic && (!decl || !targetm.binds_local_p (decl)))
+     as the PLT requires %ebx be live. (Darwin does not have a PLT.)  */
+  if (!TARGET_MACHO
+      && !TARGET_64BIT 
+      && flag_pic 
+      && (!decl || !targetm.binds_local_p (decl)))
     return false;
 
   /* If we need to align the outgoing stack, then sibcalling would
@@ -11607,6 +11610,12 @@ legitimate_constant_p (rtx x)
       if (TARGET_DLLIMPORT_DECL_ATTRIBUTES
          && SYMBOL_REF_DLLIMPORT_P (x))
        return false;
+
+#if TARGET_MACHO
+      /* mdynamic-no-pic */
+      if (MACHO_DYNAMIC_NO_PIC_P)
+       return machopic_symbol_defined_p (x);
+#endif
       break;
 
     case CONST_DOUBLE:
@@ -11977,9 +11986,15 @@ ix86_legitimate_address_p (enum machine_mode mode ATTRIBUTE_UNUSED,
                /* Non-constant pic memory reference.  */
                return false;
            }
-         else if (! legitimate_pic_address_disp_p (disp))
+         else if ((!TARGET_MACHO || flag_pic)
+                   && ! legitimate_pic_address_disp_p (disp))
            /* Displacement is an invalid pic construct.  */
            return false;
+#if TARGET_MACHO
+         else if (MACHO_DYNAMIC_NO_PIC_P && !legitimate_constant_p (disp))
+           /* displacment must be referenced via non_lazy_pointer */
+           return false;
+#endif
 
           /* This code used to verify that a symbolic pic displacement
             includes the pic_offset_table_rtx register.
@@ -12588,6 +12603,11 @@ ix86_legitimize_address (rtx x, rtx oldx ATTRIBUTE_UNUSED,
   if (flag_pic && SYMBOLIC_CONST (x))
     return legitimize_pic_address (x, 0);
 
+#if TARGET_MACHO
+  if (MACHO_DYNAMIC_NO_PIC_P && SYMBOLIC_CONST (x))
+    return machopic_indirect_data_reference (x, 0);
+#endif
+
   /* Canonicalize shifts by 0, 1, 2, 3 into multiply */
   if (GET_CODE (x) == ASHIFT
       && CONST_INT_P (XEXP (x, 1))
@@ -14085,7 +14105,7 @@ ix86_print_operand (FILE *file, rtx x, int code)
        }
       if (CONST_INT_P (x))
        fprintf (file, HOST_WIDE_INT_PRINT_DEC, INTVAL (x));
-      else if (flag_pic)
+      else if (flag_pic || MACHOPIC_INDIRECT)
        output_pic_addr_const (file, x, code);
       else
        output_addr_const (file, x);
@@ -15066,25 +15086,43 @@ ix86_expand_move (enum machine_mode mode, rtx operands[])
        }
     }
 
-  if (flag_pic && mode == Pmode && symbolic_operand (op1, Pmode))
+  if ((flag_pic || MACHOPIC_INDIRECT) 
+       && mode == Pmode && symbolic_operand (op1, Pmode))
     {
       if (TARGET_MACHO && !TARGET_64BIT)
        {
 #if TARGET_MACHO
-         if (MACHOPIC_PURE)
+         /* dynamic-no-pic */
+         if (MACHOPIC_INDIRECT)
            {
              rtx temp = ((reload_in_progress
                           || ((op0 && REG_P (op0))
                               && mode == Pmode))
                          ? op0 : gen_reg_rtx (Pmode));
              op1 = machopic_indirect_data_reference (op1, temp);
-             op1 = machopic_legitimize_pic_address (op1, mode,
-                                                    temp == op1 ? 0 : temp);
+             if (MACHOPIC_PURE)
+               op1 = machopic_legitimize_pic_address (op1, mode,
+                                                      temp == op1 ? 0 : temp);
            }
-         else if (MACHOPIC_INDIRECT)
-           op1 = machopic_indirect_data_reference (op1, 0);
-         if (op0 == op1)
+         if (op0 != op1 && GET_CODE (op0) != MEM)
+           {
+             rtx insn = gen_rtx_SET (VOIDmode, op0, op1);
+             emit_insn (insn);
+             return;
+           }
+         if (GET_CODE (op0) == MEM)
+           op1 = force_reg (Pmode, op1);
+         else
+           {
+             rtx temp = op0;
+             if (GET_CODE (temp) != REG)
+               temp = gen_reg_rtx (Pmode);
+             temp = legitimize_pic_address (op1, temp);
+             if (temp == op0)
            return;
+             op1 = temp;
+           }
+      /* dynamic-no-pic */
 #endif
        }
       else
@@ -28421,36 +28459,81 @@ machopic_output_stub (FILE *file, const char *symb, const char *stub)
 
   sprintf (lazy_ptr_name, "L%d$lz", label);
 
-  if (MACHOPIC_PURE)
+  if (MACHOPIC_ATT_STUB)
+    switch_to_section (darwin_sections[machopic_picsymbol_stub3_section]);
+  else if (MACHOPIC_PURE)
+    {
+      if (TARGET_DEEP_BRANCH_PREDICTION)
+       switch_to_section (darwin_sections[machopic_picsymbol_stub2_section]);
+      else
     switch_to_section (darwin_sections[machopic_picsymbol_stub_section]);
+    }
   else
     switch_to_section (darwin_sections[machopic_symbol_stub_section]);
 
   fprintf (file, "%s:\n", stub);
   fprintf (file, "\t.indirect_symbol %s\n", symbol_name);
 
-  if (MACHOPIC_PURE)
+  if (MACHOPIC_ATT_STUB)
+    {
+      fprintf (file, "\thlt ; hlt ; hlt ; hlt ; hlt\n");
+    }
+  else if (MACHOPIC_PURE)
     {
-      fprintf (file, "\tcall\tLPC$%d\nLPC$%d:\tpopl\t%%eax\n", label, label);
-      fprintf (file, "\tmovl\t%s-LPC$%d(%%eax),%%edx\n", lazy_ptr_name, label);
-      fprintf (file, "\tjmp\t*%%edx\n");
+      /* PIC stub.  */
+      if (TARGET_DEEP_BRANCH_PREDICTION)
+       {
+         /* 25-byte PIC stub using "CALL get_pc_thunk".  */
+         rtx tmp = gen_rtx_REG (SImode, 2 /* ECX */);
+         output_set_got (tmp, NULL_RTX);       /* "CALL ___<cpu>.get_pc_thunk.cx".  */
+         fprintf (file, "LPC$%d:\tmovl\t%s-LPC$%d(%%ecx),%%ecx\n", label, lazy_ptr_name, label);
+       }
+      else
+       {
+         /* 26-byte PIC stub using inline picbase: "CALL L42 ! L42: pop %eax".  */
+         fprintf (file, "\tcall LPC$%d\nLPC$%d:\tpopl %%ecx\n", label, label);
+         fprintf (file, "\tmovl %s-LPC$%d(%%ecx),%%ecx\n", lazy_ptr_name, label);
+       }
+      fprintf (file, "\tjmp\t*%%ecx\n");
     }
   else
     fprintf (file, "\tjmp\t*%s\n", lazy_ptr_name);
 
+  /* The AT&T-style ("self-modifying") stub is not lazily bound, thus
+     it needs no stub-binding-helper.  */
+  if (MACHOPIC_ATT_STUB)
+    return;
+
   fprintf (file, "%s:\n", binder_name);
 
   if (MACHOPIC_PURE)
     {
-      fprintf (file, "\tlea\t%s-LPC$%d(%%eax),%%eax\n", lazy_ptr_name, label);
-      fputs ("\tpushl\t%eax\n", file);
+      fprintf (file, "\tlea\t%s-%s(%%ecx),%%ecx\n", lazy_ptr_name, binder_name);
+      fprintf (file, "\tpushl\t%%ecx\n");
     }
   else
     fprintf (file, "\tpushl\t$%s\n", lazy_ptr_name);
 
   fputs ("\tjmp\tdyld_stub_binding_helper\n", file);
 
+  /* N.B. Keep the correspondence of these
+     'symbol_ptr/symbol_ptr2/symbol_ptr3' sections consistent with the
+     old-pic/new-pic/non-pic stubs; altering this will break
+     compatibility with existing dylibs.  */
+  if (MACHOPIC_PURE)
+    {
+      /* PIC stubs.  */
+      if (TARGET_DEEP_BRANCH_PREDICTION)
+       /* 25-byte PIC stub using "CALL get_pc_thunk".  */
+       switch_to_section (darwin_sections[machopic_lazy_symbol_ptr2_section]);
+      else
+       /* 26-byte PIC stub using inline picbase: "CALL L42 ! L42: pop %ebx".  */
   switch_to_section (darwin_sections[machopic_lazy_symbol_ptr_section]);
+    }
+  else
+    /* 16-byte -mdynamic-no-pic stub.  */
+    switch_to_section(darwin_sections[machopic_lazy_symbol_ptr3_section]);
+
   fprintf (file, "%s:\n", lazy_ptr_name);
   fprintf (file, "\t.indirect_symbol %s\n", symbol_name);
   fprintf (file, ASM_LONG "%s\n", binder_name);
index 89ee0fa2c07c0d2c0a495ebb5f334227761da74a..0257dbbe4e9b946b8ec3ff476fe02cb6c6ab836d 100644 (file)
@@ -479,16 +479,15 @@ extern tree x86_mfence;
 #define TARGET_SUBTARGET64_DEFAULT 0
 #define TARGET_SUBTARGET64_ISA_DEFAULT 0
 
-/* This is not really a target flag, but is done this way so that
-   it's analogous to similar code for Mach-O on PowerPC.  darwin.h
-   redefines this to 1.  */
+/* Replace MACH-O, ifdefs by in-line tests, where possible. 
+   (a) Macros defined in config/i386/darwin.h  */
 #define TARGET_MACHO 0
-
-/* Branch island 'stubs' are emitted for earlier versions of darwin.
-   This provides a default (over-ridden in darwin.h.)  */
-#ifndef TARGET_MACHO_BRANCH_ISLANDS
 #define TARGET_MACHO_BRANCH_ISLANDS 0
-#endif
+#define MACHOPIC_ATT_STUB 0
+/* (b) Macros defined in config/darwin.h  */
+#define MACHO_DYNAMIC_NO_PIC_P 0
+#define MACHOPIC_INDIRECT 0
+#define MACHOPIC_PURE 0
 
 /* For the Windows 64-bit ABI.  */
 #define TARGET_64BIT_MS_ABI (TARGET_64BIT && ix86_cfun_abi () == MS_ABI)
index 2e0db78c7b55f8ab20cc281dd0878fcdfb91ab16..cc982e75958453e9d4358b4410b5670795e01268 100644 (file)
@@ -1,5 +1,5 @@
 /* Target definitions for PowerPC running Darwin (Mac OS X).
-   Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008
+   Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2010
    Free Software Foundation, Inc.
    Contributed by Apple Computer Inc.
 
@@ -19,6 +19,9 @@
    along with GCC; see the file COPYING3.  If not see
    <http://www.gnu.org/licenses/>.  */
 
+#undef DARWIN_PPC
+#define DARWIN_PPC 1
+
 #undef  TARGET_VERSION
 #define TARGET_VERSION fprintf (stderr, " (Darwin/PowerPC)");
 
@@ -51,9 +54,6 @@
 #undef  PTRDIFF_TYPE
 #define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int")
 
-/* Translate config/rs6000/darwin.opt to config/darwin.h.  */
-#define TARGET_DYNAMIC_NO_PIC (TARGET_MACHO_DYNAMIC_NO_PIC)
-
 #define TARGET_OS_CPP_BUILTINS()                       \
   do                                                   \
     {                                                  \
@@ -184,11 +184,6 @@ extern int darwin_emit_branch_islands;
   (RS6000_ALIGN (crtl->outgoing_args_size, 16)         \
    + (STACK_POINTER_OFFSET))
 
-/* These are used by -fbranch-probabilities */
-#define HOT_TEXT_SECTION_NAME "__TEXT,__text,regular,pure_instructions"
-#define UNLIKELY_EXECUTED_TEXT_SECTION_NAME \
-                              "__TEXT,__unlikely,regular,pure_instructions"
-
 /* Define cutoff for using external functions to save floating point.
    Currently on Darwin, always use inline stores.  */
 
index ff9be36eef829e8e86dcc86eaf42de41f6c204f0..de76c4dc1ad2d376646bbb6bc4ba8bd30895914c 100644 (file)
@@ -1,6 +1,6 @@
 ; Darwin options for PPC port.
 ;
-; Copyright (C) 2005, 2007 Free Software Foundation, Inc.
+; Copyright (C) 2005, 2007, 2010 Free Software Foundation, Inc.
 ; Contributed by Aldy Hernandez <aldy@quesejoda.com>.
 ;
 ; This file is part of GCC.
@@ -26,7 +26,3 @@ Generate 64-bit code
 m32
 Target RejectNegative Negative(m64) InverseMask(64BIT)
 Generate 32-bit code
-
-mdynamic-no-pic
-Target Report Mask(MACHO_DYNAMIC_NO_PIC)
-Generate code suitable for executables (NOT shared libs)
index 6f7636bb2984cc2b705abaf55e88924eff217583..78f0a14e2f17742b89def1ea134f06fef5399df3 100644 (file)
@@ -2367,21 +2367,11 @@ darwin_rs6000_override_options (void)
      off.  */
   rs6000_altivec_abi = 1;
   TARGET_ALTIVEC_VRSAVE = 1;
-  if (DEFAULT_ABI == ABI_DARWIN)
-  {
-    if (MACHO_DYNAMIC_NO_PIC_P)
-      {
-        if (flag_pic)
-            warning (0, "-mdynamic-no-pic overrides -fpic or -fPIC");
-        flag_pic = 0;
-      }
-    else if (flag_pic == 1)
-      {
-        flag_pic = 2;
-      }
-    if (TARGET_64BIT)
+
+  if (DEFAULT_ABI == ABI_DARWIN
+      && TARGET_64BIT)
       darwin_one_byte_bool = 1;
-  }
+
   if (TARGET_64BIT && ! TARGET_POWERPC64)
     {
       target_flags |= MASK_POWERPC64;
This page took 0.157427 seconds and 5 git commands to generate.