PR24623, DWARF errors
[deliverable/binutils-gdb.git] / bfd / linker.c
index 6b4c8e57e1186a4a4682b89b72415829437dbf97..edbd0a7df46901e016f43659ed6b6bdf588c560e 100644 (file)
@@ -1,5 +1,5 @@
 /* linker.c -- BFD linker routines
-   Copyright (C) 1993-2018 Free Software Foundation, Inc.
+   Copyright (C) 1993-2019 Free Software Foundation, Inc.
    Written by Steve Chamberlain and Ian Lance Taylor, Cygnus Support
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -484,7 +484,20 @@ _bfd_link_hash_table_init
 
 /* Look up a symbol in a link hash table.  If follow is TRUE, we
    follow bfd_link_hash_indirect and bfd_link_hash_warning links to
-   the real symbol.  */
+   the real symbol.
+
+.{* Return TRUE if the symbol described by a linker hash entry H
+.   is going to be absolute.  Linker-script defined symbols can be
+.   converted from absolute to section-relative ones late in the
+.   link.  Use this macro to correctly determine whether the symbol
+.   will actually end up absolute in output.  *}
+.#define bfd_is_abs_symbol(H) \
+.  (((H)->type == bfd_link_hash_defined \
+.    || (H)->type == bfd_link_hash_defweak) \
+.   && bfd_is_abs_section ((H)->u.def.section) \
+.   && !(H)->rel_from_abs)
+.
+*/
 
 struct bfd_link_hash_entry *
 bfd_link_hash_lookup (struct bfd_link_hash_table *table,
@@ -946,7 +959,7 @@ _bfd_generic_link_add_archive_symbols
 
          if (arsym->name == NULL)
            goto error_return;
-                                 
+
          h = bfd_link_hash_lookup (info->hash, arsym->name,
                                    FALSE, FALSE, TRUE);
 
@@ -1408,12 +1421,24 @@ _bfd_generic_link_add_one_symbol (struct bfd_link_info *info,
   else if (bfd_is_com_section (section))
     {
       row = COMMON_ROW;
-      if (!bfd_link_relocatable (info)
-         && name[0] == '_'
-         && name[1] == '_'
-         && strcmp (name + (name[2] == '_'), "__gnu_lto_slim") == 0)
-       _bfd_error_handler
-         (_("%pB: plugin needed to handle lto object"), abfd);
+      static bfd_boolean report_plugin_err = TRUE;
+      if (!bfd_link_relocatable (info) && report_plugin_err)
+       {
+         if (abfd->lto_slim_object)
+           {
+             report_plugin_err = FALSE;
+             _bfd_error_handler
+               (_("%pB: plugin needed to handle lto object"), abfd);
+           }
+         else if (name[0] == '_'
+                  && name[1] == '_'
+                  && strcmp (name + (name[2] == '_'), "__gnu_lto_slim") == 0)
+           {
+             report_plugin_err = FALSE;
+             _bfd_error_handler
+               (_("%pB: plugin needed to handle lto object"), abfd);
+           }
+       }
     }
   else
     row = DEF_ROW;
@@ -2099,12 +2124,11 @@ _bfd_generic_link_output_symbols (bfd *output_bfd,
            }
        }
 
-      /* This switch is straight from the old code in
-        write_file_locals in ldsym.c.  */
-      if (info->strip == strip_all
-         || (info->strip == strip_some
-             && bfd_hash_lookup (info->keep_hash, bfd_asymbol_name (sym),
-                                 FALSE, FALSE) == NULL))
+      if ((sym->flags & BSF_KEEP) == 0
+         && (info->strip == strip_all
+             || (info->strip == strip_some
+                 && bfd_hash_lookup (info->keep_hash, bfd_asymbol_name (sym),
+                                     FALSE, FALSE) == NULL)))
        output = FALSE;
       else if ((sym->flags & (BSF_GLOBAL | BSF_WEAK | BSF_GNU_UNIQUE)) != 0)
        {
@@ -2118,6 +2142,8 @@ _bfd_generic_link_output_symbols (bfd *output_bfd,
          else
            output = FALSE;
        }
+      else if ((sym->flags & BSF_KEEP) != 0)
+       output = TRUE;
       else if (bfd_is_ind_section (sym->section))
        output = FALSE;
       else if ((sym->flags & BSF_DEBUGGING) != 0)
@@ -3106,7 +3132,7 @@ bfd_generic_define_common_symbol (bfd *output_bfd,
   /* Make sure the section is allocated in memory, and make sure that
      it is no longer a common section.  */
   section->flags |= SEC_ALLOC;
-  section->flags &= ~SEC_IS_COMMON;
+  section->flags &= ~(SEC_IS_COMMON | SEC_HAS_CONTENTS);
   return TRUE;
 }
 
This page took 0.036122 seconds and 4 git commands to generate.