On Feb 19, 2006, at 4:26 AM, Richard Sandiford wrote:

Have you thought about overriding the output_anchor hook for Darwin?
It sounds simpler than what you did in the patch, and the hook was
there specifically for cases where the ASM_OUTPUT_DEF thing wouldn't
work.

That is a good idea, thanks.  Forcing ASM_OUTPUT_DEF to be defined
was wrong for Darwin anyways as more failures come in.

Right.  This is handled for ELF by:

  /* Don't use anchors for mergeable sections.  The linker might move
     the objects around.  */
  sect = SYMBOL_REF_BLOCK (symbol)->sect;
  if (sect->common.flags & SECTION_MERGE)
    return false;

in default_use_anchor_for_symbol_p.  If .cstring contains mergeable
data, it sounds like you should either (a) set SECTION_MERGE for it
or (b) override use_anchor_for_symbol_p for Darwin and check whether
SYMBOL_REF_BLOCK (symbol)->sect == cstring_section.

Oh, that is how to fix the issue and it works.

Now I run into another problem:
/Users/pinskia/src/gcc/local/gcc/objdir.objc/./prev-gcc/xgcc -B/Users/pinskia/src/gcc/local/gcc/objdir.objc/./prev-gcc/ -B/Volumes/temp/gcc/local.objc/powerpc-apple-darwin7.9.0/bin/ -c -g -O2 -mdynamic-no-pic -DIN_GCC -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Wold-style-definition -Wmissing-format-attribute -Werror -fno-common -DHAVE_CONFIG_H -I. -I. -I/Users/pinskia/src/gcc/local/gcc/gcc -I/Users/pinskia/src/gcc/local/gcc/gcc/. -I/Users/pinskia/src/gcc/local/gcc/gcc/../include -I./../intl -I/Users/pinskia/src/gcc/local/gcc/gcc/../libcpp/include -I/Users/pinskia/src/gcc/local/gcc/gcc/../libdecnumber -I../libdecnumber -I. -I. -I/Users/pinskia/src/gcc/local/gcc/gcc -I/Users/pinskia/src/gcc/local/gcc/gcc/. -I/Users/pinskia/src/gcc/local/gcc/gcc/../include -I./../intl -I/Users/pinskia/src/gcc/local/gcc/gcc/../libcpp/include -I/Users/pinskia/src/gcc/local/gcc/gcc/../libdecnumber -I../libdecnumber /Users/pinskia/src/gcc/local/gcc/gcc/config/host-darwin.c /var/tmp//ccBWaqmT.s:130:Fixup of 1073745640 too large for field width of 26 bits /var/tmp//ccBWaqmT.s:119:Fixup of 1073745636 too large for field width of 26 bits /var/tmp//ccBWaqmT.s:104:Fixup of 1073745704 too large for field width of 26 bits /var/tmp//ccBWaqmT.s:94:Fixup of 1073745720 too large for field width of 26 bits /var/tmp//ccBWaqmT.s:73:Fixup of 1073745832 too large for field width of 26 bits /var/tmp//ccBWaqmT.s:42:Fixup of 1073745860 too large for field width of 26 bits


Thanks,
Andrew Pinski

PS Attached is my current patch:
Index: config/darwin-protos.h
===================================================================
--- config/darwin-protos.h      (revision 111255)
+++ config/darwin-protos.h      (working copy)
@@ -80,3 +80,4 @@ extern void darwin_asm_output_dwarf_delt
                                           const char *);
 extern bool darwin_binds_local_p (tree);
 extern void darwin_cpp_builtins (struct cpp_reader *);
+extern void darwin_asm_output_anchor (rtx symbol);
Index: config/darwin-sections.def
===================================================================
--- config/darwin-sections.def  (revision 111255)
+++ config/darwin-sections.def  (working copy)
@@ -11,9 +11,9 @@ DEF_SECTION (const_data_coal_section, 0,
             ".section __DATA,__const_coal,coalesced", 0)
 DEF_SECTION (data_coal_section, SECTION_WRITE,
             ".section __DATA,__datacoal_nt,coalesced", 0)
-DEF_SECTION (cstring_section, 0, ".cstring", 0)
-DEF_SECTION (literal4_section, 0, ".literal4", 0)
-DEF_SECTION (literal8_section, 0, ".literal8", 0)
+DEF_SECTION (cstring_section, SECTION_MERGE, ".cstring", 0)
+DEF_SECTION (literal4_section, SECTION_MERGE, ".literal4", 0)
+DEF_SECTION (literal8_section, SECTION_MERGE, ".literal8", 0)
 DEF_SECTION (constructor_section, 0, ".constructor", 0)
 DEF_SECTION (mod_init_section, 0, ".mod_init_func", 0)
 DEF_SECTION (mod_term_section, 0, ".mod_term_func", 0)
Index: config/darwin.c
===================================================================
--- config/darwin.c     (revision 111255)
+++ config/darwin.c     (working copy)
@@ -1479,4 +1479,17 @@ darwin_binds_local_p (tree decl)
   return default_binds_local_p_1 (decl, 0);
 }
 
+/* The Darwin's implementation of TARGET_ASM_OUTPUT_ANCHOR.  Define the
+   anchor relative to ".", the current section position.  We cannot use
+   the default one because ASM_OUTPUT_DEF is wrong for Darwin.  */
+
+void
+darwin_asm_output_anchor (rtx symbol)
+{
+  fprintf (asm_out_file, "\t.set\t");
+  assemble_name (asm_out_file, XSTR (symbol, 0));
+  fprintf (asm_out_file, ", . + " HOST_WIDE_INT_PRINT_DEC "\n",
+          SYMBOL_REF_BLOCK_OFFSET (symbol));
+}
+
 #include "gt-darwin.h"
Index: config/darwin.h
===================================================================
--- config/darwin.h     (revision 111255)
+++ config/darwin.h     (working copy)
@@ -792,6 +796,8 @@ enum machopic_addr_class {
        darwin_non_lazy_pcrel (ASM_OUT_FILE, ADDR);                             
        \
        goto DONE;                                                              
        \
       }
+
+#define TARGET_ASM_OUTPUT_ANCHOR darwin_asm_output_anchor
 
 /* Experimentally, putting jump tables in text is faster on SPEC.
    Also this is needed for correctness for coalesced functions.  */

Reply via email to