/* 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.
/* 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,
if (arsym->name == NULL)
goto error_return;
-
+
h = bfd_link_hash_lookup (info->hash, arsym->name,
FALSE, FALSE, TRUE);
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;
}
}
- /* 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)
{
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)
/* 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;
}