* elf64-ppc.c (dec_dynrel_count): Don't error when elf_gc_sweep_symbol
[external/binutils.git] / ld / emultempl / sunos.em
index 00d949f..d7cd3e8 100644 (file)
@@ -10,7 +10,8 @@ fragment <<EOF
 
 /* SunOS emulation code for ${EMULATION_NAME}
    Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
-   2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+   2002, 2003, 2004, 2005, 2006, 2007, 2008, 2012
+   Free Software Foundation, Inc.
    Written by Steve Chamberlain <sac@cygnus.com>
    SunOS shared library support by Ian Lance Taylor <ian@cygnus.com>
 
@@ -85,7 +86,7 @@ static void
 gld${EMULATION_NAME}_before_parse (void)
 {
   ldfile_set_output_arch ("${OUTPUT_ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`);
-  config.dynamic_link = TRUE;
+  input_flags.dynamic = TRUE;
   config.has_shared = TRUE;
 }
 
@@ -156,9 +157,9 @@ gld${EMULATION_NAME}_find_so (lang_input_statement_type *inp)
   char *alc;
   struct stat st;
 
-  if (! inp->search_dirs_flag
-      || ! inp->is_archive
-      || ! inp->dynamic)
+  if (! inp->flags.search_dirs
+      || ! inp->flags.maybe_archive
+      || ! inp->flags.dynamic)
     return;
 
   ASSERT (CONST_STRNEQ (inp->local_sym_name, "-l"));
@@ -188,7 +189,7 @@ gld${EMULATION_NAME}_find_so (lang_input_statement_type *inp)
 
   /* Turn off the search_dirs_flag to prevent ldfile_open_file from
      searching for this file again.  */
-  inp->search_dirs_flag = FALSE;
+  inp->flags.search_dirs = FALSE;
 
   free (found);
 
@@ -366,6 +367,8 @@ gld${EMULATION_NAME}_after_open (void)
 {
   struct bfd_link_needed_list *needed, *l;
 
+  after_open_default ();
+
   /* We only need to worry about this when doing a final link.  */
   if (link_info.relocatable || link_info.shared)
     return;
@@ -378,7 +381,7 @@ gld${EMULATION_NAME}_after_open (void)
      include another without requiring special action by the person
      doing the link.  Note that the needed list can actually grow
      while we are stepping through this loop.  */
-  needed = bfd_sunos_get_needed_list (output_bfd, &link_info);
+  needed = bfd_sunos_get_needed_list (link_info.output_bfd, &link_info);
   for (l = needed; l != NULL; l = l->next)
     {
       struct bfd_link_needed_list *ll;
@@ -405,7 +408,7 @@ gld${EMULATION_NAME}_after_open (void)
        {
          bfd *abfd;
 
-         abfd = bfd_openr (lname, bfd_get_target (output_bfd));
+         abfd = bfd_openr (lname, bfd_get_target (link_info.output_bfd));
          if (abfd != NULL)
            {
              if (! bfd_check_format (abfd, bfd_object))
@@ -555,7 +558,7 @@ gld${EMULATION_NAME}_try_needed (const char *dir, const char *name)
   alc = (char *) xmalloc (strlen (dir) + strlen (file) + 2);
   sprintf (alc, "%s/%s", dir, file);
   free (file);
-  abfd = bfd_openr (alc, bfd_get_target (output_bfd));
+  abfd = bfd_openr (alc, bfd_get_target (link_info.output_bfd));
   if (abfd == NULL)
     return FALSE;
   if (! bfd_check_format (abfd, bfd_object))
@@ -698,7 +701,7 @@ gld${EMULATION_NAME}_before_allocation (void)
 
       /* Set the .text section to start at 0x20, not 0x2020.  FIXME:
         This is too magical.  */
-      os = lang_output_section_statement_lookup (".text");
+      os = lang_output_section_statement_lookup (".text", 0, TRUE);
       if (os->addr_tree == NULL)
        os->addr_tree = exp_intop (0x20);
     }
@@ -715,7 +718,7 @@ gld${EMULATION_NAME}_before_allocation (void)
                                   FALSE);
       if (hdyn == NULL)
        einfo ("%P%F: bfd_link_hash_lookup: %E\n");
-      if (! bfd_sunos_record_link_assignment (output_bfd, &link_info,
+      if (! bfd_sunos_record_link_assignment (link_info.output_bfd, &link_info,
                                              "__DYNAMIC"))
        einfo ("%P%F: failed to record assignment to __DYNAMIC: %E\n");
     }
@@ -727,8 +730,8 @@ gld${EMULATION_NAME}_before_allocation (void)
 
   /* Let the backend linker work out the sizes of any sections
      required by dynamic linking.  */
-  if (! bfd_sunos_size_dynamic_sections (output_bfd, &link_info, &sdyn,
-                                        &sneed, &srules))
+  if (! bfd_sunos_size_dynamic_sections (link_info.output_bfd, &link_info,
+                                        &sdyn, &sneed, &srules))
     einfo ("%P%F: failed to set dynamic section sizes: %E\n");
 
   if (sneed != NULL)
@@ -847,7 +850,8 @@ gld${EMULATION_NAME}_find_exp_assignment (etree_type *exp)
 
       if (strcmp (exp->assign.dst, ".") != 0)
        {
-         if (! bfd_sunos_record_link_assignment (output_bfd, &link_info,
+         if (! bfd_sunos_record_link_assignment (link_info.output_bfd,
+                                                 &link_info,
                                                  exp->assign.dst))
            einfo ("%P%F: failed to record assignment to %s: %E\n",
                   exp->assign.dst);
@@ -888,7 +892,7 @@ gld${EMULATION_NAME}_count_need (lang_input_statement_type *inp)
     {
       ++need_entries;
       need_size += NEED_ENTRY_SIZE;
-      if (! inp->is_archive)
+      if (! inp->flags.maybe_archive)
        need_size += strlen (inp->filename) + 1;
       else
        {
@@ -914,12 +918,13 @@ gld${EMULATION_NAME}_set_need (lang_input_statement_type *inp)
         Instead, we use offsets, and rely on the BFD backend to
         finish the section up correctly.  FIXME: Talk about lack of
         referential locality.  */
-      bfd_put_32 (output_bfd, need_pnames - need_contents, need_pinfo);
-      if (! inp->is_archive)
+      bfd_put_32 (link_info.output_bfd, need_pnames - need_contents,
+                 need_pinfo);
+      if (! inp->flags.maybe_archive)
        {
-         bfd_put_32 (output_bfd, (bfd_vma) 0, need_pinfo + 4);
-         bfd_put_16 (output_bfd, (bfd_vma) 0, need_pinfo + 8);
-         bfd_put_16 (output_bfd, (bfd_vma) 0, need_pinfo + 10);
+         bfd_put_32 (link_info.output_bfd, (bfd_vma) 0, need_pinfo + 4);
+         bfd_put_16 (link_info.output_bfd, (bfd_vma) 0, need_pinfo + 8);
+         bfd_put_16 (link_info.output_bfd, (bfd_vma) 0, need_pinfo + 10);
          strcpy ((char *) need_pnames, inp->filename);
        }
       else
@@ -927,22 +932,23 @@ gld${EMULATION_NAME}_set_need (lang_input_statement_type *inp)
          char *verstr;
          int maj, min;
 
-         bfd_put_32 (output_bfd, (bfd_vma) 0x80000000, need_pinfo + 4);
+         bfd_put_32 (link_info.output_bfd, (bfd_vma) 0x80000000,
+                     need_pinfo + 4);
          maj = 0;
          min = 0;
          verstr = strstr (inp->filename, ".so.");
          if (verstr != NULL)
            sscanf (verstr, ".so.%d.%d", &maj, &min);
-         bfd_put_16 (output_bfd, (bfd_vma) maj, need_pinfo + 8);
-         bfd_put_16 (output_bfd, (bfd_vma) min, need_pinfo + 10);
+         bfd_put_16 (link_info.output_bfd, (bfd_vma) maj, need_pinfo + 8);
+         bfd_put_16 (link_info.output_bfd, (bfd_vma) min, need_pinfo + 10);
          strcpy ((char *) need_pnames, inp->local_sym_name + 2);
        }
 
       c = (need_pinfo - need_contents) / NEED_ENTRY_SIZE;
       if (c + 1 >= need_entries)
-       bfd_put_32 (output_bfd, (bfd_vma) 0, need_pinfo + 12);
+       bfd_put_32 (link_info.output_bfd, (bfd_vma) 0, need_pinfo + 12);
       else
-       bfd_put_32 (output_bfd, (bfd_vma) (c + 1) * NEED_ENTRY_SIZE,
+       bfd_put_32 (link_info.output_bfd, (bfd_vma) (c + 1) * NEED_ENTRY_SIZE,
                    need_pinfo + 12);
 
       need_pinfo += NEED_ENTRY_SIZE;