+2015-02-14 Alan Modra <amodra@gmail.com>
+
+ PR ld/17973
+ * bfd.c (struct bfd): Add lto_output.
+ * linker.c (_bfd_handle_already_linked): Explicitly test for
+ objects added by the lto plugin.
+ * opncls.c (_bfd_new_bfd_contained_in): Copy lto_output and
+ no_export flags from archive.
+ * archive.c (open_nested_file): New function, setting lto_output
+ and no_export, extracted from..
+ (find_nested_archive): ..here. Flip params. Rename from
+ _bfd_find_nested_archive.
+ (_bfd_get_elt_at_filepos): Correct var typo. Use open_nested_file.
+ (_bfd_look_for_bfd_in_cache): Copy no_export.
+ * elflink.c (elf_link_add_object_symbols): Remove now unnecessary
+ my_archive->no_export test.
+ (elf_link_input_bfd): Drop existing lto_output STT_FILE syms.
+ Don't use the file name when adding lto_output STT_FILE sym.
+ * bfd-in2.h: Regenerate.
+
2015-02-13 Alan Modra <amodra@gmail.com>
PR binutils/17512
struct ar_cache *entry = (struct ar_cache *) htab_find (hash_table, &m);
if (!entry)
return NULL;
- else
- return entry->arbfd;
+
+ /* Unfortunately this flag is set after checking that we have
+ an archive, and checking for an archive means one element has
+ sneaked into the cache. */
+ entry->arbfd->no_export = arch_bfd->no_export;
+ return entry->arbfd;
}
else
return NULL;
}
\f
static bfd *
-_bfd_find_nested_archive (bfd *arch_bfd, const char *filename)
+open_nested_file (const char *filename, bfd *archive)
{
- bfd *abfd;
const char *target;
+ bfd *n_bfd;
+
+ target = NULL;
+ if (!archive->target_defaulted)
+ target = archive->xvec->name;
+ n_bfd = bfd_openr (filename, target);
+ if (n_bfd != NULL)
+ {
+ n_bfd->lto_output = archive->lto_output;
+ n_bfd->no_export = archive->no_export;
+ }
+ return n_bfd;
+}
+
+static bfd *
+find_nested_archive (const char *filename, bfd *arch_bfd)
+{
+ bfd *abfd;
/* PR 15140: Don't allow a nested archive pointing to itself. */
if (filename_cmp (filename, arch_bfd->filename) == 0)
if (filename_cmp (filename, abfd->filename) == 0)
return abfd;
}
- target = NULL;
- if (!arch_bfd->target_defaulted)
- target = arch_bfd->xvec->name;
- abfd = bfd_openr (filename, target);
+ abfd = open_nested_file (filename, arch_bfd);
if (abfd)
{
abfd->archive_next = arch_bfd->nested_archives;
_bfd_get_elt_at_filepos (bfd *archive, file_ptr filepos)
{
struct areltdata *new_areldata;
- bfd *n_nfd;
+ bfd *n_bfd;
char *filename;
- n_nfd = _bfd_look_for_bfd_in_cache (archive, filepos);
- if (n_nfd)
- return n_nfd;
+ n_bfd = _bfd_look_for_bfd_in_cache (archive, filepos);
+ if (n_bfd)
+ return n_bfd;
if (0 > bfd_seek (archive, filepos, SEEK_SET))
return NULL;
if (bfd_is_thin_archive (archive))
{
- const char *target;
-
/* This is a proxy entry for an external file. */
if (! IS_ABSOLUTE_PATH (filename))
{
{
/* This proxy entry refers to an element of a nested archive.
Locate the member of that archive and return a bfd for it. */
- bfd *ext_arch = _bfd_find_nested_archive (archive, filename);
+ bfd *ext_arch = find_nested_archive (filename, archive);
if (ext_arch == NULL
|| ! bfd_check_format (ext_arch, bfd_archive))
free (new_areldata);
return NULL;
}
- n_nfd = _bfd_get_elt_at_filepos (ext_arch, new_areldata->origin);
- if (n_nfd == NULL)
+ n_bfd = _bfd_get_elt_at_filepos (ext_arch, new_areldata->origin);
+ if (n_bfd == NULL)
{
free (new_areldata);
return NULL;
}
- n_nfd->proxy_origin = bfd_tell (archive);
- return n_nfd;
+ n_bfd->proxy_origin = bfd_tell (archive);
+ return n_bfd;
}
+
/* It's not an element of a nested archive;
open the external file as a bfd. */
- target = NULL;
- if (!archive->target_defaulted)
- target = archive->xvec->name;
- n_nfd = bfd_openr (filename, target);
- if (n_nfd == NULL)
+ n_bfd = open_nested_file (filename, archive);
+ if (n_bfd == NULL)
bfd_set_error (bfd_error_malformed_archive);
}
else
{
- n_nfd = _bfd_create_empty_archive_element_shell (archive);
+ n_bfd = _bfd_create_empty_archive_element_shell (archive);
}
- if (n_nfd == NULL)
+ if (n_bfd == NULL)
{
free (new_areldata);
return NULL;
}
- n_nfd->proxy_origin = bfd_tell (archive);
+ n_bfd->proxy_origin = bfd_tell (archive);
if (bfd_is_thin_archive (archive))
{
- n_nfd->origin = 0;
+ n_bfd->origin = 0;
}
else
{
- n_nfd->origin = n_nfd->proxy_origin;
- n_nfd->filename = xstrdup (filename);
+ n_bfd->origin = n_bfd->proxy_origin;
+ n_bfd->filename = xstrdup (filename);
}
- n_nfd->arelt_data = new_areldata;
+ n_bfd->arelt_data = new_areldata;
/* Copy BFD_COMPRESS and BFD_DECOMPRESS flags. */
- n_nfd->flags |= archive->flags & (BFD_COMPRESS | BFD_DECOMPRESS);
+ n_bfd->flags |= archive->flags & (BFD_COMPRESS | BFD_DECOMPRESS);
- if (_bfd_add_bfd_to_archive_cache (archive, filepos, n_nfd))
- return n_nfd;
+ if (_bfd_add_bfd_to_archive_cache (archive, filepos, n_bfd))
+ return n_bfd;
free (new_areldata);
- n_nfd->arelt_data = NULL;
+ n_bfd->arelt_data = NULL;
return NULL;
}
/* If this is an input for a compiler plug-in library. */
ENUM_BITFIELD (bfd_plugin_format) plugin_format : 2;
+ /* Set if this is a plugin output file. */
+ unsigned int lto_output : 1;
+
/* Set to dummy BFD created when claimed by a compiler plug-in
library. */
bfd *plugin_dummy_bfd;
. {* If this is an input for a compiler plug-in library. *}
. ENUM_BITFIELD (bfd_plugin_format) plugin_format : 2;
.
+. {* Set if this is a plugin output file. *}
+. unsigned int lto_output : 1;
+.
. {* Set to dummy BFD created when claimed by a compiler plug-in
. library. *}
. bfd *plugin_dummy_bfd;
requested we not re-export it, then mark it as hidden. */
if (definition
&& !dynamic
- && (abfd->no_export
- || (abfd->my_archive && abfd->my_archive->no_export))
+ && abfd->no_export
&& ELF_ST_VISIBILITY (isym->st_other) != STV_INTERNAL)
isym->st_other = (STV_HIDDEN
| (isym->st_other & ~ELF_ST_VISIBILITY (-1)));
if (ELF_ST_TYPE (isym->st_info) == STT_FILE)
{
+ if (input_bfd->lto_output)
+ /* -flto puts a temp file name here. This means builds
+ are not reproducible. Discard the symbol. */
+ continue;
have_file_sym = TRUE;
flinfo->filesym_count += 1;
}
memset (&osym, 0, sizeof (osym));
osym.st_info = ELF_ST_INFO (STB_LOCAL, STT_FILE);
osym.st_shndx = SHN_ABS;
- if (!elf_link_output_sym (flinfo, input_bfd->filename, &osym,
- bfd_abs_section_ptr, NULL))
+ if (!elf_link_output_sym (flinfo,
+ (input_bfd->lto_output ? NULL
+ : input_bfd->filename),
+ &osym, bfd_abs_section_ptr, NULL))
return FALSE;
}
files over IR because the first pass may contain a
mix of LTO and normal objects and we must keep the
first match, be it IR or real. */
- if (info->loading_lto_outputs
+ if (sec->owner->lto_output
&& (l->sec->owner->flags & BFD_PLUGIN) != 0)
{
l->sec = sec;
nbfd->my_archive = obfd;
nbfd->direction = read_direction;
nbfd->target_defaulted = obfd->target_defaulted;
+ nbfd->lto_output = obfd->lto_output;
+ nbfd->no_export = obfd->no_export;
return nbfd;
}
+2015-02-14 Alan Modra <amodra@gmail.com>
+
+ PR ld/17973
+ * bfdlink.h (struct bfd_link_info): Delete loading_lto_outputs.
+
2015-02-09 Mark Wielaard <mjw@redhat.com>
* dwarf2.h: Add DW_LANG_Fortran03 and DW_LANG_Fortran08.
/* TRUE if the LTO plugin is active. */
unsigned int lto_plugin_active: 1;
- /* TRUE if we are loading LTO outputs. */
- unsigned int loading_lto_outputs: 1;
-
/* TRUE if global symbols in discarded sections should be stripped. */
unsigned int strip_discarded: 1;
+2015-02-14 Alan Modra <amodra@gmail.com>
+
+ PR ld/17973
+ * ldlang.h (struct lang_input_statement_flags): Add lto_output.
+ * ldlang.c (lang_process): Don't set loading_lto_outputs.
+ * ldfile.c (ldfile_try_open_bfd): Transfer entry flags.lto_output
+ to bfd.
+ * plugin.c (add_input_file, add_input_library): Set flags.lto_output.
+
2015-02-13 H.J. Lu <hongjiu.lu@intel.com>
* NEWS: Mention support for LLVM plugin.
/* Linker needs to decompress sections. */
entry->the_bfd->flags |= BFD_DECOMPRESS;
+#ifdef ENABLE_PLUGINS
+ if (entry->flags.lto_output)
+ entry->the_bfd->lto_output = 1;
+#endif
+
/* If we are searching for this file, see if the architecture is
compatible with the output file. If it isn't, keep searching.
If we can't open the file as an object file, stop the search
einfo (_("%P%F: %s: plugin reported error after all symbols read\n"),
plugin_error_plugin ());
/* Open any newly added files, updating the file chains. */
- link_info.loading_lto_outputs = TRUE;
open_input_bfds (*added.tail, OPEN_BFD_NORMAL);
/* Restore the global list pointer now they have all been added. */
lang_list_remove_tail (stat_ptr, &added);
/* Set if the file was claimed from an archive. */
unsigned int claim_archive : 1;
+
+ /* Set if added by the lto plugin add_input_file callback. */
+ unsigned int lto_output : 1;
#endif /* ENABLE_PLUGINS */
/* Head of list of pushed flags. */
static enum ld_plugin_status
add_input_file (const char *pathname)
{
+ lang_input_statement_type *is;
+
ASSERT (called_plugin);
- if (!lang_add_input_file (xstrdup (pathname), lang_input_file_is_file_enum,
- NULL))
+ is = lang_add_input_file (xstrdup (pathname), lang_input_file_is_file_enum,
+ NULL);
+ if (!is)
return LDPS_ERR;
+ is->flags.lto_output = 1;
return LDPS_OK;
}
static enum ld_plugin_status
add_input_library (const char *pathname)
{
+ lang_input_statement_type *is;
+
ASSERT (called_plugin);
- if (!lang_add_input_file (xstrdup (pathname), lang_input_file_is_l_enum,
- NULL))
+ is = lang_add_input_file (xstrdup (pathname), lang_input_file_is_l_enum,
+ NULL);
+ if (!is)
return LDPS_ERR;
+ is->flags.lto_output = 1;
return LDPS_OK;
}