This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Update Mach-O PIC stubs for Darwin
- To: gcc-patches at gcc dot gnu dot org
- Subject: Update Mach-O PIC stubs for Darwin
- From: Stan Shebs <shebs at apple dot com>
- Date: Wed, 01 Aug 2001 18:49:26 -0700
This fixes obscure combinations of symbol defines and references
that can affect linking of C++ programs on Darwin. Bootstraps
on powerpc-apple-darwin1.3, and makes much more of the C++ testsuite
work, although it's still not all there yet. Committed to the trunk.
Stan
2001-08-01 Stan Shebs <shebs@apple.com>
* config/darwin.c (machopic_stub_name): Try matching by name.
(update_stubs): New function.
(darwin_encode_section_info): Call it and update_non_lazy_ptrs
unconditionally.
Index: config/darwin.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/darwin.c,v
retrieving revision 1.6
diff -c -3 -p -r1.6 darwin.c
*** darwin.c 2001/07/10 00:49:45 1.6
--- darwin.c 2001/08/02 01:26:51
*************** extern void machopic_output_stub PARAMS
*** 45,50 ****
--- 45,51 ----
static int machopic_data_defined_p PARAMS ((const char *));
static int func_name_maybe_scoped PARAMS ((const char *));
static void update_non_lazy_ptrs PARAMS ((const char *));
+ static void update_stubs PARAMS ((const char *));
int
name_needs_quotes (name)
*************** machopic_stub_name (name)
*** 330,335 ****
--- 331,338 ----
{
if (ident == TREE_VALUE (temp))
return IDENTIFIER_POINTER (TREE_PURPOSE (temp));
+ if (strcmp (name, IDENTIFIER_POINTER (TREE_VALUE (temp))) == 0)
+ return IDENTIFIER_POINTER (TREE_PURPOSE (temp));
}
STRIP_NAME_ENCODING (name, name);
*************** darwin_encode_section_info (decl)
*** 1025,1033 ****
memcpy (new_str, orig_str, len);
new_str[1] = code;
XSTR (sym_ref, 0) = ggc_alloc_string (new_str, len);
- /* The non-lazy pointer list may have captured references to the
- old encoded name, change them. */
- update_non_lazy_ptrs (XSTR (sym_ref, 0));
}
else
{
--- 1028,1033 ----
*************** darwin_encode_section_info (decl)
*** 1041,1046 ****
--- 1041,1050 ----
memcpy (new_str + 4, orig_str, len);
XSTR (sym_ref, 0) = ggc_alloc_string (new_str, new_len);
}
+ /* The non-lazy pointer list may have captured references to the
+ old encoded name, change them. */
+ update_non_lazy_ptrs (XSTR (sym_ref, 0));
+ update_stubs (XSTR (sym_ref, 0));
}
/* Scan the list of non-lazy pointers and update any recorded names whose
*************** update_non_lazy_ptrs (name)
*** 1056,1061 ****
--- 1060,1096 ----
STRIP_NAME_ENCODING (name1, name);
for (temp = machopic_non_lazy_pointers;
+ temp != NULL_TREE;
+ temp = TREE_CHAIN (temp))
+ {
+ char *sym_name = IDENTIFIER_POINTER (TREE_VALUE (temp));
+
+ if (*sym_name == '!')
+ {
+ STRIP_NAME_ENCODING (name2, sym_name);
+ if (strcmp (name1, name2) == 0)
+ {
+ IDENTIFIER_POINTER (TREE_VALUE (temp)) = name;
+ break;
+ }
+ }
+ }
+ }
+
+
+ /* Scan the list of stubs and update any recorded names whose
+ stripped name matches the argument. */
+
+ static void
+ update_stubs (name)
+ const char *name;
+ {
+ char *name1, *name2;
+ tree temp;
+
+ STRIP_NAME_ENCODING (name1, name);
+
+ for (temp = machopic_stubs;
temp != NULL_TREE;
temp = TREE_CHAIN (temp))
{