Report scripts and libraries searched for ld --trace

The idea of this change is to make -t output useful for users wanting
to package all the object files involved in linking for a bug report.

Something like the following should do the trick.
gcc hello.c -save-temps -Wl,-t | xargs realpath | sort | uniq > files
tar cJf test.tar.xz `cat files`

	* ldlang.c (load_symbols): When -t, print file names for script
	files and archives.
	* ldmain.c (trace_files): Make an int.
	(add_archive_element): Print archive elements only with multiple
	-t options, or when archive is thin.
	* ldmain.h (trace_files): Update.
	* ldmisc.c (vfinfo): Don't print both original path and path in
	sysroot.
	* lexsup.c (parse_args <t>): Increment trace_files.
This commit is contained in:
Alan Modra
2018-10-29 18:10:06 +10:30
parent 5c87f94bb8
commit 727a29badd
6 changed files with 27 additions and 14 deletions

View File

@@ -476,15 +476,13 @@ vfinfo (FILE *fp, const char *fmt, va_list ap, bfd_boolean is_warning)
fmt++;
i = (lang_input_statement_type *) args[arg_no].p;
++arg_count;
if (i->the_bfd->my_archive != NULL
if (i->the_bfd != NULL
&& i->the_bfd->my_archive != NULL
&& !bfd_is_thin_archive (i->the_bfd->my_archive))
fprintf (fp, "(%s)",
bfd_get_filename (i->the_bfd->my_archive));
fprintf (fp, "%s", i->local_sym_name);
if ((i->the_bfd->my_archive == NULL
|| bfd_is_thin_archive (i->the_bfd->my_archive))
&& filename_cmp (i->local_sym_name, i->filename) != 0)
fprintf (fp, " (%s)", i->filename);
fprintf (fp, "(%s)%s", i->the_bfd->my_archive->filename,
i->local_sym_name);
else
fprintf (fp, "%s", i->filename);
}
else if (*fmt == 'R')
{