aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStuart Hastings <stuart@apple.com>2005-10-29 18:43:21 +0000
committerStuart Hastings <stuart@apple.com>2005-10-29 18:43:21 +0000
commit87e14d516bddbd8f30ba97b91710c4f9e936ca9f (patch)
tree368af9aa52d83114a1b2a49d780acfd467be0dd2
parentaeacae669e984046f99653e2e65ebee8b7f3f7eb (diff)
2005-10-28 Stuart Hastings <stuart@apple.com>
Radar 4164563 * config/darwin.c (darwin_macho_att_stub, darwin_macho_att_stub_switch): New. * config/darwin.h (-matt-stubs): New flag. (machopic_picsymbol_stub3_section): New __IMPORT section. (MACHOPIC_NL_SYMBOL_PTR_SECTION): New. (machopic_nl_symbol_ptr_section): Move non-lazy pointers to __IMPORT section. * config/i386/darwin.h (-matt-stubs): New flag. (SUBTARGET_OVERRIDE_OPTIONS): Handle -matt-stubs. * config/i386/i386.c (macho_output_stub): Generate AT&T style (self-modifying) stubs. * config/i386/i386.h (MACHOPIC_NL_SYMBOL_PTR_SECTION): Override machopic_nl_symbol_ptr_section with new __IMPORT section. 2005-10-28 Stuart Hastings <stuart@apple.com> Radar 4164563 gcc.apple/i386-att-stub-1.c: New. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/apple-200511-release-branch@105994 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog.apple-ppc17
-rw-r--r--gcc/config/darwin-protos.h2
-rw-r--r--gcc/config/darwin.c8
-rw-r--r--gcc/config/darwin.h31
-rw-r--r--gcc/config/i386/darwin.h12
-rw-r--r--gcc/config/i386/i386.c23
-rw-r--r--gcc/config/i386/i386.h3
-rw-r--r--gcc/testsuite/ChangeLog.apple-ppc5
8 files changed, 96 insertions, 5 deletions
diff --git a/gcc/ChangeLog.apple-ppc b/gcc/ChangeLog.apple-ppc
index b0fe6cf9e65..749f2dfd439 100644
--- a/gcc/ChangeLog.apple-ppc
+++ b/gcc/ChangeLog.apple-ppc
@@ -1,3 +1,20 @@
+2005-10-28 Stuart Hastings <stuart@apple.com>
+
+ Radar 4164563
+ * config/darwin.c (darwin_macho_att_stub,
+ darwin_macho_att_stub_switch): New.
+ * config/darwin.h (-matt-stubs): New
+ flag. (machopic_picsymbol_stub3_section): New __IMPORT
+ section. (MACHOPIC_NL_SYMBOL_PTR_SECTION):
+ New. (machopic_nl_symbol_ptr_section): Move non-lazy pointers to
+ __IMPORT section.
+ * config/i386/darwin.h (-matt-stubs): New
+ flag. (SUBTARGET_OVERRIDE_OPTIONS): Handle -matt-stubs.
+ * config/i386/i386.c (macho_output_stub): Generate AT&T style
+ (self-modifying) stubs.
+ * config/i386/i386.h (MACHOPIC_NL_SYMBOL_PTR_SECTION): Override
+ machopic_nl_symbol_ptr_section with new __IMPORT section.
+
2005-10-28 Dale Johannesen <dalej@apple.com>
Radar 4318818
diff --git a/gcc/config/darwin-protos.h b/gcc/config/darwin-protos.h
index b10e123e4bb..a425614a4d9 100644
--- a/gcc/config/darwin-protos.h
+++ b/gcc/config/darwin-protos.h
@@ -36,6 +36,8 @@ extern void machopic_symbol_stub_section (void);
extern void machopic_symbol_stub1_section (void);
/* APPLE LOCAL deep branch prediction */
extern void machopic_symbol_stub2_section (void);
+/* APPLE LOCAL AT&T-style stub 4164563 */
+extern void machopic_picsymbol_stub3_section (void);
extern void machopic_lazy_symbol_ptr_section (void);
/* APPLE LOCAL begin -mdynamic-no-pic */
extern void machopic_lazy_symbol_ptr2_section (void);
diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c
index ad065211ad3..4e2d419940f 100644
--- a/gcc/config/darwin.c
+++ b/gcc/config/darwin.c
@@ -100,6 +100,14 @@ const char *darwin_one_byte_bool = 0;
int darwin_reverse_bitfields = 0;
/* APPLE LOCAL end pragma reverse_bitfields */
+/* APPLE LOCAL begin AT&T-style stub 4164563 */
+/* This is an i386-only option, but the i386 target_flags bitset is full.
+ This should resolve itself in 4.1; these decls, and their flags,
+ should move to i386/i386.c. */
+int darwin_macho_att_stub = 1; /* Defaults on. */
+const char *darwin_macho_att_stub_switch;
+/* APPLE LOCAL end AT&T-style stub 4164563 */
+
int
name_needs_quotes (const char *name)
{
diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index 6632986c3e1..87e06e618f4 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -192,6 +192,12 @@ extern const char *darwin_fix_and_continue_switch;
/* APPLE LOCAL mainline 2005-09-01 3449986 */
extern const char *darwin_macosx_version_min;
+/* APPLE LOCAL begin AT&T-style stub 4164563 */
+extern int darwin_macho_att_stub;
+extern const char *darwin_macho_att_stub_switch;
+#define MACHOPIC_ATT_STUB (darwin_macho_att_stub)
+/* APPLE LOCAL end AT&T-style stub 4164563 */
+
#undef SUBTARGET_OPTIONS
#define SUBTARGET_OPTIONS \
{"one-byte-bool", &darwin_one_byte_bool, N_("Set sizeof(bool) to 1"), 0 }, \
@@ -203,8 +209,14 @@ extern const char *darwin_macosx_version_min;
0 }, \
/* APPLE LOCAL end mainline 2005-09-01 3449986 */ \
{"no-fix-and-continue", &darwin_fix_and_continue_switch, \
-/* APPLE LOCAL begin constant cfstrings */ \
N_("Don't generate code suitable for fast turn around debugging"), 0}, \
+ /* APPLE LOCAL begin AT&T-style stub 4164563 */ \
+ {"att-stubs", &darwin_macho_att_stub_switch, \
+ N_("Generate AT&T-style stubs for Mach-O"), 0}, \
+ {"no-att-stubs", &darwin_macho_att_stub_switch, \
+ N_("Generate traditional Mach-O stubs"), 0}, \
+ /* APPLE LOCAL end AT&T-style stub 4164563 */ \
+ /* APPLE LOCAL begin constant cfstrings */ \
{"constant-cfstrings", &darwin_constant_cfstrings_switch, \
N_("Generate compile-time CFString objects"), 0}, \
{"no-constant-cfstrings", &darwin_constant_cfstrings_switch, "", 0}, \
@@ -826,9 +838,17 @@ FUNCTION (void) \
in_machopic_picsymbol_stub1, \
/* APPLE LOCAL dynamic-no-pic */ \
in_machopic_picsymbol_stub2, \
+ /* APPLE LOCAL AT&T-style stub 4164563 */ \
+ in_machopic_picsymbol_stub3, \
in_darwin_exception, in_darwin_eh_frame, \
num_sections
+/* APPLE LOCAL begin AT&T-style stub 4164563 */
+#ifndef MACHOPIC_NL_SYMBOL_PTR_SECTION
+#define MACHOPIC_NL_SYMBOL_PTR_SECTION ".non_lazy_symbol_pointer"
+#endif
+/* APPLE LOCAL end AT&T-style stub 4164563 */ \
+
#undef EXTRA_SECTION_FUNCTIONS
#define EXTRA_SECTION_FUNCTIONS \
static void objc_section_init (void); \
@@ -964,9 +984,11 @@ SECTION_FUNCTION (machopic_lazy_symbol_ptr3_section, \
in_machopic_lazy_symbol_ptr3, \
".section __DATA, __la_sym_ptr3,lazy_symbol_pointers", 0) \
/* APPLE LOCAL end dynamic-no-pic */ \
+/* APPLE LOCAL begin AT&T-style stub 4164563 */ \
SECTION_FUNCTION (machopic_nl_symbol_ptr_section, \
in_machopic_nl_symbol_ptr, \
- ".non_lazy_symbol_pointer", 0) \
+ MACHOPIC_NL_SYMBOL_PTR_SECTION, 0) \
+/* APPLE LOCAL end AT&T-style stub 4164563 */ \
SECTION_FUNCTION (machopic_symbol_stub_section, \
in_machopic_symbol_stub, \
".symbol_stub", 0) \
@@ -986,6 +1008,11 @@ SECTION_FUNCTION (machopic_picsymbol_stub2_section, \
in_machopic_picsymbol_stub2, \
".section __TEXT,__picsymbolstub2,symbol_stubs,pure_instructions,25", 0) \
/* APPLE LOCAL end dynamic-no-pic */ \
+/* APPLE LOCAL begin AT&T-style stub 4164563 */ \
+SECTION_FUNCTION (machopic_picsymbol_stub3_section, \
+ in_machopic_picsymbol_stub3, \
+ ".section __IMPORT,__jump_table,symbol_stubs,self_modifying_code+pure_instructions,5", 0) \
+/* APPLE LOCAL end AT&T-style stub 4164563 */ \
SECTION_FUNCTION (darwin_exception_section, \
in_darwin_exception, \
".section __DATA,__gcc_except_tab", 0) \
diff --git a/gcc/config/i386/darwin.h b/gcc/config/i386/darwin.h
index 81502b128f8..28e905ca85a 100644
--- a/gcc/config/i386/darwin.h
+++ b/gcc/config/i386/darwin.h
@@ -223,6 +223,18 @@ extern int flag_cw_asm_blocks;
error ("invalid option %qs", base); \
darwin_fix_and_continue = (base[0] != 'n'); \
} \
+ /* APPLE LOCAL begin AT&T-style stub 4164563 */ \
+ /* Handle -matt-stubs. */ \
+ if (darwin_macho_att_stub_switch) \
+ { \
+ const char *base = darwin_macho_att_stub_switch; \
+ while (base[-1] != 'm') base--; \
+ \
+ if (*darwin_macho_att_stub_switch != '\0') \
+ error ("invalid option %qs", base); \
+ darwin_macho_att_stub = (base[0] != 'n'); \
+ } \
+ /* APPLE LOCAL end AT&T-style stub 4164563 */ \
/* APPLE LOCAL begin CW asm blocks */ \
if (flag_cw_asm_blocks) \
flag_ms_asms = 1; \
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 6e5ed1dca4a..6539d83bd97 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -16236,8 +16236,12 @@ machopic_output_stub (FILE *file, const char *symb, const char *stub)
sprintf (lazy_ptr_name, "L%d$lz", label);
/* APPLE LOCAL begin deep branch prediction pic-base */
- /* Choose one of three possible sections for this stub. */
- if (MACHOPIC_PURE)
+ /* APPLE LOCAL begin AT&T-style stub 4164563 */
+ /* Choose one of four possible sections for this stub. */
+ if (MACHOPIC_ATT_STUB)
+ machopic_picsymbol_stub3_section (); /* 5 byte PIC stub. */
+ else if (MACHOPIC_PURE)
+ /* APPLE LOCAL end AT&T-style stub 4164563 */
{
if (TARGET_DEEP_BRANCH_PREDICTION)
machopic_picsymbol_stub2_section (); /* 25 byte PIC stub. */
@@ -16253,7 +16257,13 @@ machopic_output_stub (FILE *file, const char *symb, const char *stub)
/* APPLE LOCAL begin use %ecx in stubs 4146993 */
/* APPLE LOCAL begin deep branch prediction pic-base */
- if (MACHOPIC_PURE)
+ /* APPLE LOCAL begin AT&T-style stub 4164563 */
+ if (MACHOPIC_ATT_STUB)
+ {
+ fprintf (file, "\thlt ; hlt ; hlt ; hlt ; hlt\n");
+ }
+ else if (MACHOPIC_PURE)
+ /* APPLE LOCAL end AT&T-style stub 4164563 */
{
/* PIC stub. */
if (TARGET_DEEP_BRANCH_PREDICTION)
@@ -16274,6 +16284,13 @@ machopic_output_stub (FILE *file, const char *symb, const char *stub)
else /* 16-byte -mdynamic-no-pic stub. */
fprintf (file, "\tjmp\t*%s\n", lazy_ptr_name);
+ /* APPLE LOCAL begin AT&T-style stub 4164563 */
+ /* The AT&T-style ("self-modifying") stub is not lazily bound, thus
+ it needs no stub-binding-helper. */
+ if (MACHOPIC_ATT_STUB)
+ return;
+ /* APPLE LOCAL end AT&T-style stub 4164563 */
+
/* The "stub_binding_helper" is a fragment that gets executed only
once, the first time this stub is invoked (then it becomes "dead
code"). It asks the dynamic linker to set the
diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
index ac554c6a712..a118560fe09 100644
--- a/gcc/config/i386/i386.h
+++ b/gcc/config/i386/i386.h
@@ -143,6 +143,9 @@ extern int target_flags;
/* APPLE LOCAL dynamic-no-pic */
/* Unused: 0x02000000 */
+/* APPLE LOCAL AT&T-style stub 4164563 */
+#define MACHOPIC_NL_SYMBOL_PTR_SECTION ".section __IMPORT,__pointers,non_lazy_symbol_pointers"
+
/* ... overlap with subtarget options starts by 0x04000000. */
#define MASK_NO_RED_ZONE 0x04000000 /* Do not use red zone */
diff --git a/gcc/testsuite/ChangeLog.apple-ppc b/gcc/testsuite/ChangeLog.apple-ppc
index 6f913cf9f2a..92f89df3ed8 100644
--- a/gcc/testsuite/ChangeLog.apple-ppc
+++ b/gcc/testsuite/ChangeLog.apple-ppc
@@ -1,3 +1,8 @@
+2005-10-28 Stuart Hastings <stuart@apple.com>
+
+ Radar 4164563
+ gcc.apple/i386-att-stub-1.c: New.
+
2005-10-21 Devang Patel <dpatel@apple.com>
* g++.dg/stab-types.C: New.