bfd/
[deliverable/binutils-gdb.git] / ld / emultempl / ppc64elf.em
index 9a49fa5a34174cc1f92babbdc832e2da303c3bdf..a11f300cea350d7258cb9737ea5a8fb5dcdbebe3 100644 (file)
@@ -1,5 +1,5 @@
 # This shell script emits a C file. -*- C -*-
-# Copyright 2002, 2003, 2004, 2005, 2007, 2008
+# Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
 # Free Software Foundation, Inc.
 #
 # This file is part of the GNU Binutils.
@@ -47,6 +47,7 @@ static int dotsyms = 1;
 
 /* Whether to run tls optimization.  */
 static int no_tls_opt = 0;
+static int no_tls_get_addr_opt = 0;
 
 /* Whether to run opd optimization.  */
 static int no_opd_opt = 0;
@@ -58,7 +59,7 @@ static int no_toc_opt = 0;
 static int no_multi_toc = 0;
 
 /* Whether to emit symbols for stubs.  */
-static int emit_stub_syms = 0;
+static int emit_stub_syms = -1;
 
 static asection *toc_section = 0;
 
@@ -106,7 +107,8 @@ ppc_before_allocation (void)
                                  non_overlapping_opd))
        einfo ("%X%P: can not edit %s %E\n", "opd");
 
-      if (ppc64_elf_tls_setup (link_info.output_bfd, &link_info)
+      if (ppc64_elf_tls_setup (link_info.output_bfd, &link_info,
+                              no_tls_get_addr_opt)
          && !no_tls_opt)
        {
          /* Size the sections.  This is premature, but we want to know the
@@ -258,18 +260,12 @@ ppc_layout_sections_again (void)
      to recalculate all the section offsets.  This may mean we need to
      add even more stubs.  */
   gld${EMULATION_NAME}_map_segments (TRUE);
-  need_laying_out = -1;
-}
 
-
-/* Call the back-end function to set TOC base after we have placed all
-   the sections.  */
-static void
-gld${EMULATION_NAME}_after_allocation (void)
-{
   if (!link_info.relocatable)
     _bfd_set_gp_value (link_info.output_bfd,
                       ppc64_elf_toc (link_info.output_bfd));
+
+  need_laying_out = -1;
 }
 
 
@@ -283,7 +279,10 @@ build_toc_list (lang_statement_union_type *statement)
       if (!((lang_input_statement_type *) i->owner->usrdata)->just_syms_flag
          && (i->flags & SEC_EXCLUDE) == 0
          && i->output_section == toc_section)
-       ppc64_elf_next_toc_section (&link_info, i);
+       {
+         if (!ppc64_elf_next_toc_section (&link_info, i))
+           einfo ("%X%P: linker script separates .got and .toc\n");
+       }
     }
 }
 
@@ -307,18 +306,13 @@ build_section_lists (lang_statement_union_type *statement)
 }
 
 
-/* Final emulation specific call.  */
-
+/* Call the back-end function to set TOC base after we have placed all
+   the sections.  */
 static void
-gld${EMULATION_NAME}_finish (void)
+gld${EMULATION_NAME}_after_allocation (void)
 {
-  /* e_entry on PowerPC64 points to the function descriptor for
-     _start.  If _start is missing, default to the first function
-     descriptor in the .opd section.  */
-  entry_section = ".opd";
-
-  /* bfd_elf_discard_info just plays with debugging sections,
-     ie. doesn't affect any code, so we can delay resizing the
+  /* bfd_elf_discard_info just plays with data and debugging sections,
+     ie. doesn't affect code size, so we can delay resizing the
      sections.  It's likely we'll resize everything in the process of
      adding stubs.  */
   if (bfd_elf_discard_info (link_info.output_bfd, &link_info))
@@ -328,33 +322,58 @@ gld${EMULATION_NAME}_finish (void)
      stubs.  */
   if (stub_file != NULL && !link_info.relocatable)
     {
-      int ret = ppc64_elf_setup_section_lists (link_info.output_bfd,
-                                              &link_info,
-                                              no_multi_toc);
+      int ret = ppc64_elf_setup_section_lists (&link_info,
+                                              &ppc_add_stub_section,
+                                              &ppc_layout_sections_again);
       if (ret < 0)
        einfo ("%X%P: can not size stub section: %E\n");
       else if (ret > 0)
        {
-         toc_section = bfd_get_section_by_name (link_info.output_bfd, ".got");
-         if (toc_section != NULL)
+         ppc64_elf_start_multitoc_partition (&link_info);
+
+         if (!no_multi_toc)
+           {
+             toc_section = bfd_get_section_by_name (link_info.output_bfd,
+                                                    ".got");
+             if (toc_section != NULL)
+               lang_for_each_statement (build_toc_list);
+           }
+
+         if (ppc64_elf_layout_multitoc (&link_info)
+             && !no_multi_toc
+             && toc_section != NULL)
            lang_for_each_statement (build_toc_list);
 
-         ppc64_elf_reinit_toc (link_info.output_bfd, &link_info);
+         ppc64_elf_finish_multitoc_partition (&link_info);
 
          lang_for_each_statement (build_section_lists);
 
          /* Call into the BFD backend to do the real work.  */
-         if (!ppc64_elf_size_stubs (link_info.output_bfd,
-                                    &link_info,
-                                    group_size,
-                                    &ppc_add_stub_section,
-                                    &ppc_layout_sections_again))
+         if (!ppc64_elf_size_stubs (&link_info, group_size))
            einfo ("%X%P: can not size stub section: %E\n");
        }
     }
 
   if (need_laying_out != -1)
-    gld${EMULATION_NAME}_map_segments (need_laying_out);
+    {
+      gld${EMULATION_NAME}_map_segments (need_laying_out);
+
+      if (!link_info.relocatable)
+       _bfd_set_gp_value (link_info.output_bfd,
+                          ppc64_elf_toc (link_info.output_bfd));
+    }
+}
+
+
+/* Final emulation specific call.  */
+
+static void
+gld${EMULATION_NAME}_finish (void)
+{
+  /* e_entry on PowerPC64 points to the function descriptor for
+     _start.  If _start is missing, default to the first function
+     descriptor in the .opd section.  */
+  entry_section = ".opd";
 
   if (link_info.relocatable)
     {
@@ -369,7 +388,8 @@ gld${EMULATION_NAME}_finish (void)
       char *msg = NULL;
       char *line, *endline;
 
-      emit_stub_syms |= link_info.emitrelocations;
+      if (emit_stub_syms < 0)
+       emit_stub_syms = 1;
       if (!ppc64_elf_build_stubs (emit_stub_syms, &link_info,
                                  config.stats ? &msg : NULL))
        einfo ("%X%P: can not build stubs: %E\n");
@@ -416,29 +436,18 @@ gld${EMULATION_NAME}_new_vers_pattern (struct bfd_elf_version_expr *entry)
   char *dot_pat;
 
   if (!dotsyms
-      || (entry->pattern != NULL
-         && (entry->pattern[0] == '*' || entry->pattern[0] == '.')))
+      || entry->pattern[0] == '.'
+      || (!entry->literal && entry->pattern[0] == '*'))
     return entry;
 
   dot_entry = xmalloc (sizeof *dot_entry);
   *dot_entry = *entry;
   dot_entry->next = entry;
-  if (entry->pattern != NULL)
-    {
-      len = strlen (entry->pattern) + 2;
-      dot_pat = xmalloc (len);
-      dot_pat[0] = '.';
-      memcpy (dot_pat + 1, entry->pattern, len - 1);
-      dot_entry->pattern = dot_pat;
-    }
-  if (entry->symbol != NULL)
-    {
-      len = strlen (entry->symbol) + 2;
-      dot_pat = xmalloc (len);
-      dot_pat[0] = '.';
-      memcpy (dot_pat + 1, entry->symbol, len - 1);
-      dot_entry->symbol = dot_pat;
-    }
+  len = strlen (entry->pattern) + 2;
+  dot_pat = xmalloc (len);
+  dot_pat[0] = '.';
+  memcpy (dot_pat + 1, entry->pattern, len - 1);
+  dot_entry->pattern = dot_pat;
   return dot_entry;
 }
 
@@ -489,10 +498,12 @@ fi
 PARSE_AND_LIST_PROLOGUE='
 #define OPTION_STUBGROUP_SIZE          301
 #define OPTION_STUBSYMS                        (OPTION_STUBGROUP_SIZE + 1)
-#define OPTION_DOTSYMS                 (OPTION_STUBSYMS + 1)
+#define OPTION_NO_STUBSYMS             (OPTION_STUBSYMS + 1)
+#define OPTION_DOTSYMS                 (OPTION_NO_STUBSYMS + 1)
 #define OPTION_NO_DOTSYMS              (OPTION_DOTSYMS + 1)
 #define OPTION_NO_TLS_OPT              (OPTION_NO_DOTSYMS + 1)
-#define OPTION_NO_OPD_OPT              (OPTION_NO_TLS_OPT + 1)
+#define OPTION_NO_TLS_GET_ADDR_OPT     (OPTION_NO_TLS_OPT + 1)
+#define OPTION_NO_OPD_OPT              (OPTION_NO_TLS_GET_ADDR_OPT + 1)
 #define OPTION_NO_TOC_OPT              (OPTION_NO_OPD_OPT + 1)
 #define OPTION_NO_MULTI_TOC            (OPTION_NO_TOC_OPT + 1)
 #define OPTION_NON_OVERLAPPING_OPD     (OPTION_NO_MULTI_TOC + 1)
@@ -501,9 +512,11 @@ PARSE_AND_LIST_PROLOGUE='
 PARSE_AND_LIST_LONGOPTS='
   { "stub-group-size", required_argument, NULL, OPTION_STUBGROUP_SIZE },
   { "emit-stub-syms", no_argument, NULL, OPTION_STUBSYMS },
+  { "no-emit-stub-syms", no_argument, NULL, OPTION_NO_STUBSYMS },
   { "dotsyms", no_argument, NULL, OPTION_DOTSYMS },
   { "no-dotsyms", no_argument, NULL, OPTION_NO_DOTSYMS },
   { "no-tls-optimize", no_argument, NULL, OPTION_NO_TLS_OPT },
+  { "no-tls-get-addr-optimize", no_argument, NULL, OPTION_NO_TLS_GET_ADDR_OPT },
   { "no-opd-optimize", no_argument, NULL, OPTION_NO_OPD_OPT },
   { "no-toc-optimize", no_argument, NULL, OPTION_NO_TOC_OPT },
   { "no-multi-toc", no_argument, NULL, OPTION_NO_MULTI_TOC },
@@ -525,6 +538,9 @@ PARSE_AND_LIST_OPTIONS='
   --emit-stub-syms            Label linker stubs with a symbol.\n"
                   ));
   fprintf (file, _("\
+  --no-emit-stub-syms         Don'\''t label linker stubs with a symbol.\n"
+                  ));
+  fprintf (file, _("\
   --dotsyms                   For every version pattern \"foo\" in a version\n\
                                 script, add \".foo\" so that function code\n\
                                 symbols are treated the same as function\n\
@@ -537,6 +553,9 @@ PARSE_AND_LIST_OPTIONS='
   --no-tls-optimize           Don'\''t try to optimize TLS accesses.\n"
                   ));
   fprintf (file, _("\
+  --no-tls-get-addr-optimize  Don'\''t use a special __tls_get_addr call.\n"
+                  ));
+  fprintf (file, _("\
   --no-opd-optimize           Don'\''t optimize the OPD section.\n"
                   ));
   fprintf (file, _("\
@@ -565,6 +584,10 @@ PARSE_AND_LIST_ARGS_CASES='
       emit_stub_syms = 1;
       break;
 
+    case OPTION_NO_STUBSYMS:
+      emit_stub_syms = 0;
+      break;
+
     case OPTION_DOTSYMS:
       dotsyms = 1;
       break;
@@ -577,6 +600,10 @@ PARSE_AND_LIST_ARGS_CASES='
       no_tls_opt = 1;
       break;
 
+    case OPTION_NO_TLS_GET_ADDR_OPT:
+      no_tls_get_addr_opt = 1;
+      break;
+
     case OPTION_NO_OPD_OPT:
       no_opd_opt = 1;
       break;
This page took 0.026573 seconds and 4 git commands to generate.