/* Plugin control for the GNU linker.
- Copyright (C) 2010-2016 Free Software Foundation, Inc.
+ Copyright (C) 2010-2018 Free Software Foundation, Inc.
This file is part of the GNU Binutils.
newplug->name = plugin;
newplug->dlhandle = dlopen (plugin, RTLD_NOW);
if (!newplug->dlhandle)
- einfo (_("%P%F: %s: error loading plugin: %s\n"), plugin, dlerror ());
+ einfo (_("%F%P: %s: error loading plugin: %s\n"), plugin, dlerror ());
/* Check if plugin has been loaded already. */
while (curplug)
}
}
report_error:
- einfo (_("could not create dummy IR bfd: %F%E\n"));
+ einfo (_("%F%P: could not create dummy IR bfd: %E\n"));
return NULL;
}
unsigned char visibility;
if (!elfsym)
- einfo (_("%P%F: %s: non-ELF symbol in ELF BFD!\n"), asym->name);
+ einfo (_("%F%P: %s: non-ELF symbol in ELF BFD!\n"), asym->name);
switch (ldsym->visibility)
{
default:
- einfo (_("%P%F: unknown ELF symbol visibility: %d!\n"),
+ einfo (_("%F%P: unknown ELF symbol visibility: %d!\n"),
ldsym->visibility);
+ return LDPS_ERR;
+
case LDPV_DEFAULT:
visibility = STV_DEFAULT;
break;
/* FIXME: einfo should support %lld. */
if ((off_t) size != input->filesize)
- einfo (_("%P%F: unsupported input file size: %s (%ld bytes)\n"),
+ einfo (_("%F%P: unsupported input file size: %s (%ld bytes)\n"),
input->name, (long) input->filesize);
/* Check the cached view buffer. */
is_visible_from_outside (struct ld_plugin_symbol *lsym,
struct bfd_link_hash_entry *blhe)
{
- struct bfd_sym_chain *sym;
-
if (bfd_link_relocatable (&link_info))
return TRUE;
- if (link_info.export_dynamic || bfd_link_dll (&link_info))
+ if (blhe->non_ir_ref_dynamic
+ || link_info.export_dynamic
+ || bfd_link_dll (&link_info))
{
/* Check if symbol is hidden by version script. */
if (bfd_hide_sym_by_version (link_info.version_info,
|| lsym->visibility == LDPV_PROTECTED);
}
- for (sym = &entry_symbol; sym != NULL; sym = sym->next)
- if (sym->name
- && strcmp (sym->name, blhe->root.string) == 0)
- return TRUE;
-
return FALSE;
}
&& blhe->type != bfd_link_hash_common)
{
/* We should not have a new, indirect or warning symbol here. */
- einfo ("%P%F: %s: plugin symbol table corrupt (sym type %d)\n",
+ einfo (_("%F%P: %s: plugin symbol table corrupt (sym type %d)\n"),
called_plugin->name, blhe->type);
}
even potentially-referenced, perhaps in a future final link if
this is a partial one, perhaps dynamically at load-time if the
symbol is externally visible. */
- if (blhe->non_ir_ref)
+ if (blhe->non_ir_ref_regular)
res = LDPR_PREVAILING_DEF;
else if (is_visible_from_outside (&syms[n], blhe))
res = def_ironly_exp;
report_symbol:
syms[n].resolution = res;
if (report_plugin_symbols)
- einfo (_("%P: %B: symbol `%s' "
+ einfo (_("%P: %pB: symbol `%s' "
"definition: %d, visibility: %d, resolution: %d\n"),
abfd, syms[n].name,
syms[n].def, syms[n].visibility, res);
break;
case LDPL_WARNING:
{
- char *newfmt = concat ("%P: warning: ", format, "\n",
+ char *newfmt = concat (_("%P: warning: "), format, "\n",
(const char *) NULL);
vfinfo (stdout, newfmt, args, TRUE);
free (newfmt);
case LDPL_ERROR:
default:
{
- char *newfmt = concat (level == LDPL_FATAL ? "%P%F" : "%P%X",
- ": error: ", format, "\n",
+ char *newfmt = concat (level == LDPL_FATAL ? "%F" : "%X",
+ _("%P: error: "), format, "\n",
(const char *) NULL);
fflush (stdout);
vfinfo (stderr, newfmt, args, TRUE);
if (!onloadfn)
onloadfn = (ld_plugin_onload) dlsym (curplug->dlhandle, "_onload");
if (!onloadfn)
- einfo (_("%P%F: %s: error loading plugin: %s\n"),
+ einfo (_("%F%P: %s: error loading plugin: %s\n"),
curplug->name, dlerror ());
set_tv_plugin_args (curplug, &my_tv[tv_header_size]);
called_plugin = curplug;
rv = (*onloadfn) (my_tv);
called_plugin = NULL;
if (rv != LDPS_OK)
- einfo (_("%P%F: %s: plugin error: %d\n"), curplug->name, rv);
+ einfo (_("%F%P: %s: plugin error: %d\n"), curplug->name, rv);
curplug = curplug->next;
}
if (curplug->claim_file_handler)
{
enum ld_plugin_status rv;
+
called_plugin = curplug;
rv = (*curplug->claim_file_handler) (file, claimed);
called_plugin = NULL;
strlength = strlen (str) + 1;
copy = bfd_alloc (abfd, strlength);
if (copy == NULL)
- einfo (_("%P%F: plugin_strdup failed to allocate memory: %s\n"),
+ einfo (_("%F%P: plugin_strdup failed to allocate memory: %s\n"),
bfd_get_error ());
memcpy (copy, str, strlength);
return copy;
input = bfd_alloc (abfd, sizeof (*input));
if (input == NULL)
- einfo (_("%P%F: plugin failed to allocate memory for input: %s\n"),
+ einfo (_("%F%P: plugin failed to allocate memory for input: %s\n"),
bfd_get_error ());
if (!bfd_plugin_open_input (ibfd, &file))
}
file.handle = input;
- /* The plugin API expects that the file descriptor won't be closed
- and reused as done by the bfd file cache. So dup one. */
- file.fd = dup (file.fd);
- if (file.fd < 0)
- return NULL;
-
input->abfd = abfd;
input->view_buffer.addr = NULL;
input->view_buffer.filesize = 0;
claimed = 0;
if (plugin_call_claim_file (&file, &claimed))
- einfo (_("%P%F: %s: plugin reported error claiming file\n"),
+ einfo (_("%F%P: %s: plugin reported error claiming file\n"),
plugin_error_plugin ());
if (input->fd != -1 && !bfd_plugin_target_p (ibfd->xvec))
void
plugin_maybe_claim (lang_input_statement_type *entry)
{
+ ASSERT (entry->header.type == lang_input_statement_enum);
if (plugin_object_p (entry->the_bfd))
{
bfd *abfd = entry->the_bfd->plugin_dummy_bfd;
/* To determine which symbols should be resolved LDPR_PREVAILING_DEF
and which LDPR_PREVAILING_DEF_IRONLY, we notice all the symbols as
the linker adds them to the linker hash table. Mark those
- referenced from a non-IR file with non_ir_ref. We have to
- notice_all symbols, because we won't necessarily know until later
- which ones will be contributed by IR files. */
+ referenced from a non-IR file with non_ir_ref_regular or
+ non_ir_ref_dynamic as appropriate. We have to notice_all symbols,
+ because we won't necessarily know until later which ones will be
+ contributed by IR files. */
static bfd_boolean
plugin_notice (struct bfd_link_info *info,
struct bfd_link_hash_entry *h,
if (h != NULL)
{
bfd *sym_bfd;
+ bfd_boolean ref = FALSE;
if (h->type == bfd_link_hash_warning)
h = h->u.i.link;
{
/* ??? Some of this is questionable. See comments in
_bfd_generic_link_add_one_symbol for case IND. */
- if (h->type != bfd_link_hash_new)
+ if (h->type != bfd_link_hash_new
+ || inh->type == bfd_link_hash_new)
{
- h->non_ir_ref = TRUE;
- inh->non_ir_ref = TRUE;
+ if ((abfd->flags & DYNAMIC) == 0)
+ inh->non_ir_ref_regular = TRUE;
+ else
+ inh->non_ir_ref_dynamic = TRUE;
}
- else if (inh->type == bfd_link_hash_new)
- inh->non_ir_ref = TRUE;
+
+ if (h->type != bfd_link_hash_new)
+ ref = TRUE;
}
/* Nothing to do here for warning symbols. */
else if (bfd_is_und_section (section))
{
/* Replace the undefined dummy bfd with the real one. */
- if ((h->type == bfd_link_hash_undefined
- || h->type == bfd_link_hash_undefweak)
- && (h->u.undef.abfd == NULL
- || (h->u.undef.abfd->flags & BFD_PLUGIN) != 0))
- h->u.undef.abfd = abfd;
- h->non_ir_ref = TRUE;
+ if ((h->type == bfd_link_hash_undefined
+ || h->type == bfd_link_hash_undefweak)
+ && (h->u.undef.abfd == NULL
+ || (h->u.undef.abfd->flags & BFD_PLUGIN) != 0))
+ h->u.undef.abfd = abfd;
+ ref = TRUE;
}
/* Otherwise, it must be a new def. */
else
{
- /* A common symbol should be merged with other commons or
- defs with the same name. In particular, a common ought
- to be overridden by a def in a -flto object. In that
- sense a common is also a ref. */
- if (bfd_is_com_section (section))
- h->non_ir_ref = TRUE;
-
/* Ensure any symbol defined in an IR dummy BFD takes on a
new value from a real BFD. Weak symbols are not normally
overridden by a new weak definition, and strong symbols
h->type = bfd_link_hash_undefweak;
h->u.undef.abfd = sym_bfd;
}
+
+ /* A common symbol should be merged with other commons or
+ defs with the same name. In particular, a common ought
+ to be overridden by a def in a -flto object. In that
+ sense a common is also a ref. */
+ if (bfd_is_com_section (section))
+ ref = TRUE;
+ }
+
+ if (ref)
+ {
+ if ((abfd->flags & DYNAMIC) == 0)
+ h->non_ir_ref_regular = TRUE;
+ else
+ h->non_ir_ref_dynamic = TRUE;
}
}