X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=ld%2Fplugin.c;h=fad8bc0e38ba5bcba9a42231bb520f083ddb169a;hb=61367c61574e4d1f422e0f560672c4e63116fd7a;hp=164b5db5d6d23a3daa527a49a88510796a75e78f;hpb=59fa66c53823dc695f78669f40ec2eebab3aec42;p=deliverable%2Fbinutils-gdb.git diff --git a/ld/plugin.c b/ld/plugin.c index 164b5db5d6..fad8bc0e38 100644 --- a/ld/plugin.c +++ b/ld/plugin.c @@ -1,5 +1,5 @@ /* Plugin control for the GNU linker. - Copyright (C) 2010-2017 Free Software Foundation, Inc. + Copyright (C) 2010-2018 Free Software Foundation, Inc. This file is part of the GNU Binutils. @@ -243,7 +243,7 @@ plugin_opt_plugin (const char *plugin) 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) @@ -336,7 +336,7 @@ plugin_get_ir_dummy_bfd (const char *name, bfd *srctemplate) } } 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; } @@ -424,11 +424,11 @@ asymbol_from_plugin_symbol (bfd *abfd, asymbol *asym, 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; @@ -539,7 +539,7 @@ get_view (const void *handle, const void **viewp) /* 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. */ @@ -629,7 +629,7 @@ is_visible_from_outside (struct ld_plugin_symbol *lsym, if (bfd_link_relocatable (&link_info)) return TRUE; - if (blhe->dynamic_ref_after_ir_def + if (blhe->non_ir_ref_dynamic || link_info.export_dynamic || bfd_link_dll (&link_info)) { @@ -723,7 +723,7 @@ get_symbols (const void *handle, int nsyms, struct ld_plugin_symbol *syms, && 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); } @@ -774,7 +774,7 @@ get_symbols (const void *handle, int nsyms, struct ld_plugin_symbol *syms, 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; @@ -783,7 +783,7 @@ get_symbols (const void *handle, int nsyms, struct ld_plugin_symbol *syms, 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); @@ -858,7 +858,7 @@ message (int level, const char *format, ...) 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); @@ -868,8 +868,8 @@ message (int level, const char *format, ...) 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); @@ -1014,14 +1014,14 @@ plugin_load_plugins (void) 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; } @@ -1080,7 +1080,7 @@ plugin_strdup (bfd *abfd, const char *str) 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; @@ -1112,7 +1112,7 @@ plugin_object_p (bfd *ibfd) 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)) @@ -1145,7 +1145,7 @@ plugin_object_p (bfd *ibfd) 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)) @@ -1266,9 +1266,10 @@ plugin_call_cleanup (void) /* 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, @@ -1283,6 +1284,7 @@ plugin_notice (struct bfd_link_info *info, if (h != NULL) { bfd *sym_bfd; + bfd_boolean ref = FALSE; if (h->type == bfd_link_hash_warning) h = h->u.i.link; @@ -1298,13 +1300,17 @@ plugin_notice (struct bfd_link_info *info, { /* ??? 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. */ @@ -1318,34 +1324,18 @@ plugin_notice (struct bfd_link_info *info, /* If this is a ref, set non_ir_ref. */ else if (bfd_is_und_section (section)) { - if (h->type == bfd_link_hash_defweak - || h->type == bfd_link_hash_defined) - { - /* Check if the symbol is referenced in a dynamic object - after it has been defined in an IR object. */ - if ((abfd->flags & DYNAMIC) != 0 - && is_ir_dummy_bfd (h->u.def.section->owner)) - h->dynamic_ref_after_ir_def = TRUE; - } /* Replace the undefined dummy bfd with the real one. */ - else 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)) + 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; + 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 @@ -1360,6 +1350,21 @@ plugin_notice (struct bfd_link_info *info, 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; } }