/* Main program of GNU linker.
- Copyright (C) 1991-2020 Free Software Foundation, Inc.
+ Copyright (C) 1991-2021 Free Software Foundation, Inc.
Written by Steve Chamberlain steve@cygnus.com
This file is part of the GNU Binutils.
info_msg,
minfo,
ldlang_override_segment_assignment,
- ldlang_ctf_apply_strsym,
+ ldlang_ctf_acquire_strings,
+ NULL,
+ ldlang_ctf_new_dynsym,
ldlang_write_ctf_late
};
struct bfd_link_info link_info;
\f
+struct dependency_file
+{
+ struct dependency_file *next;
+ char *name;
+};
+
+static struct dependency_file *dependency_files, *dependency_files_tail;
+
+void
+track_dependency_files (const char *filename)
+{
+ struct dependency_file *dep
+ = (struct dependency_file *) xmalloc (sizeof (*dep));
+ dep->name = xstrdup (filename);
+ dep->next = NULL;
+ if (dependency_files == NULL)
+ dependency_files = dep;
+ else
+ dependency_files_tail->next = dep;
+ dependency_files_tail = dep;
+}
+
+static void
+write_dependency_file (void)
+{
+ FILE *out;
+ struct dependency_file *dep;
+
+ out = fopen (config.dependency_file, FOPEN_WT);
+ if (out == NULL)
+ {
+ einfo (_("%F%P: cannot open dependency file %s: %E\n"),
+ config.dependency_file);
+ }
+
+ fprintf (out, "%s:", output_filename);
+
+ for (dep = dependency_files; dep != NULL; dep = dep->next)
+ fprintf (out, " \\\n %s", dep->name);
+
+ fprintf (out, "\n");
+ for (dep = dependency_files; dep != NULL; dep = dep->next)
+ fprintf (out, "\n%s:\n", dep->name);
+
+ fclose (out);
+}
+\f
static void
ld_cleanup (void)
{
/* is_sysrooted_pathname() relies on no trailing dirsep. */
if (ld_canon_sysroot_len > 0
&& IS_DIR_SEPARATOR (ld_canon_sysroot [ld_canon_sysroot_len - 1]))
- ld_canon_sysroot [--ld_canon_sysroot_len] = '\0';
+ ld_canon_sysroot [--ld_canon_sysroot_len] = '\0';
}
else
ld_canon_sysroot_len = -1;
#ifdef DEFAULT_NEW_DTAGS
link_info.new_dtags = DEFAULT_NEW_DTAGS;
#endif
+ link_info.start_stop_gc = FALSE;
link_info.start_stop_visibility = STV_PROTECTED;
ldfile_add_arch ("");
ldexp_finish ();
lang_finish ();
+ if (config.dependency_file != NULL)
+ write_dependency_file ();
+
/* Even if we're producing relocatable output, some non-fatal errors should
be reported in the exit status. (What non-fatal errors, if any, do we
want to ignore for relocatable output?) */
|| strcmp (argv[i], "-mips5") == 0
|| strcmp (argv[i], "-mips32") == 0
|| strcmp (argv[i], "-mips32r2") == 0
+ || strcmp (argv[i], "-mips32r3") == 0
+ || strcmp (argv[i], "-mips32r5") == 0
|| strcmp (argv[i], "-mips32r6") == 0
|| strcmp (argv[i], "-mips64") == 0
|| strcmp (argv[i], "-mips64r2") == 0
+ || strcmp (argv[i], "-mips64r3") == 0
+ || strcmp (argv[i], "-mips64r5") == 0
|| strcmp (argv[i], "-mips64r6") == 0)
{
/* FIXME: The arguments -mips1, -mips2, -mips3, etc. are
input->local_sym_name = bfd_get_filename (abfd);
input->the_bfd = abfd;
- parent = bfd_usrdata (abfd->my_archive);
- if (parent != NULL && !parent->flags.reload)
- parent->next = input;
-
/* Save the original data for trace files/tries below, as plugins
(if enabled) may possibly alter it to point to a replacement
BFD, but we still want to output the original BFD filename. */
}
#endif /* BFD_SUPPORTS_PLUGINS */
+ if (link_info.input_bfds_tail == &input->the_bfd->link.next
+ || input->the_bfd->link.next != NULL)
+ {
+ /* We have already loaded this element, and are attempting to
+ load it again. This can happen when the archive map doesn't
+ match actual symbols defined by the element. */
+ free (input);
+ bfd_set_error (bfd_error_malformed_archive);
+ return FALSE;
+ }
+
+ /* Set the file_chain pointer of archives to the last element loaded
+ from the archive. See ldlang.c:find_rescan_insertion. */
+ parent = bfd_usrdata (abfd->my_archive);
+ if (parent != NULL && !parent->flags.reload)
+ parent->next = input;
+
ldlang_add_file (input);
if (config.map_file != NULL)
nval = oval;
obfd = NULL;
}
- einfo (_("%X%P: %C: multiple definition of `%pT'"),
+ if (!info->warn_multiple_definition)
+ einfo ("%X");
+ einfo (_("%P: %C: multiple definition of `%pT'"),
nbfd, nsec, nval, name);
if (obfd != NULL)
einfo (_("; %D: first defined here"), obfd, osec, oval);
free (relpp);
}
+#if SUPPORT_ERROR_HANDLING_SCRIPT
+char * error_handling_script = NULL;
+#endif
+
/* This is called when an undefined symbol is found. */
static void
error_name = xstrdup (name);
}
+#if SUPPORT_ERROR_HANDLING_SCRIPT
+ if (error_handling_script != NULL
+ && error_count < MAX_ERRORS_IN_A_ROW)
+ {
+ char * argv[4];
+ const char * res;
+ int status, err;
+
+ argv[0] = error_handling_script;
+ argv[1] = "undefined-symbol";
+ argv[2] = (char *) name;
+ argv[3] = NULL;
+
+ if (verbose)
+ einfo (_("%P: About to run error handling script '%s' with arguments: '%s' '%s'\n"),
+ argv[0], argv[1], argv[2]);
+
+ res = pex_one (PEX_SEARCH, error_handling_script, argv,
+ N_("error handling script"),
+ NULL /* Send stdout to random, temp file. */,
+ NULL /* Write to stderr. */,
+ &status, &err);
+ if (res != NULL)
+ {
+ einfo (_("%P: Failed to run error handling script '%s', reason: "),
+ error_handling_script);
+ /* FIXME: We assume here that errrno == err. */
+ perror (res);
+ }
+ /* We ignore the return status of the script and
+ carry on to issue the normal error message. */
+ }
+#endif /* SUPPORT_ERROR_HANDLING_SCRIPT */
+
if (section != NULL)
{
if (error_count < MAX_ERRORS_IN_A_ROW)