Add a new "-f" option to the linker, to print the resolved paths

of all the files and libraries in the command line.

Submitted by:	bde (Bruce Evans)
This commit is contained in:
John Polstra 1997-03-22 02:59:40 +00:00
parent 7677efc6a4
commit 32d41c2b07
3 changed files with 43 additions and 5 deletions

View File

@ -27,7 +27,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\" $Id$
.\" $Id: ld.1,v 1.15 1997/02/22 15:46:19 peter Exp $
.\"
.Dd October 14, 1993
.Dt LD 1
@ -37,7 +37,7 @@
.Nd link editor
.Sh SYNOPSIS
.Nm ld
.Op Fl MNnrSstXxz
.Op Fl fMNnrSstXxz
.Bk -words
.Op Fl A Ar symbol-file
.Op Fl assert Ar keyword
@ -131,6 +131,9 @@ calls will be re-directed through the Procedure Linkage Table (see
.Xr link 5)
.It Fl e Ar entry-symbol
Specifies the entry symbol for an executable.
.It Fl f
List the resolved paths of all the object files and libraries on the
standard output, and exit.
.It Fl L Ns Ar path
Add
.Ar path

View File

@ -27,7 +27,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\" $Id$
.\" $Id: ld.1,v 1.15 1997/02/22 15:46:19 peter Exp $
.\"
.Dd October 14, 1993
.Dt LD 1
@ -37,7 +37,7 @@
.Nd link editor
.Sh SYNOPSIS
.Nm ld
.Op Fl MNnrSstXxz
.Op Fl fMNnrSstXxz
.Bk -words
.Op Fl A Ar symbol-file
.Op Fl assert Ar keyword
@ -131,6 +131,9 @@ calls will be re-directed through the Procedure Linkage Table (see
.Xr link 5)
.It Fl e Ar entry-symbol
Specifies the entry symbol for an executable.
.It Fl f
List the resolved paths of all the object files and libraries on the
standard output, and exit.
.It Fl L Ns Ar path
Add
.Ar path

View File

@ -32,7 +32,7 @@ static char sccsid[] = "@(#)ld.c 6.10 (Berkeley) 5/22/91";
Set, indirect, and warning symbol features added by Randy Smith. */
/*
* $Id$
* $Id: ld.c,v 1.41 1997/02/22 15:46:20 peter Exp $
*/
/* Define how to initialize system-dependent header fields. */
@ -200,6 +200,7 @@ int global_alias_count; /* # of aliased symbols */
int set_symbol_count; /* # of N_SET* symbols. */
int set_vector_count; /* # of set vectors in output. */
int warn_sym_count; /* # of warning symbols encountered. */
int flag_list_files; /* 1 => print pathnames of files, don't link */
int list_warning_symbols; /* 1 => warning symbols referenced */
struct string_list_element *set_element_prefixes;
@ -263,6 +264,7 @@ static void write_syms __P((void));
static void assign_symbolnums __P((struct file_entry *, int *));
static void cleanup __P((void));
static int parse __P((char *, char *, char *));
static void list_files __P((void));
int
@ -344,6 +346,9 @@ main(argc, argv)
/* Completely decode ARGV. */
decode_command(argc, argv);
if (flag_list_files)
list_files();
building_shared_object =
(!relocatable_output && (link_mode & SHAREABLE));
@ -684,6 +689,10 @@ decode_option(swt, arg)
add_cmdline_ref(entry_symbol);
return;
case 'f':
flag_list_files = 1;
return;
case 'l':
return;
@ -3770,3 +3779,26 @@ padfile(padding, fd)
bzero(buf, padding);
mywrite(buf, padding, 1, fd);
}
static void
list_files()
{
int error, i;
error = 0;
for (i = 0; i < number_of_files; i++) {
register struct file_entry *entry = &file_table[i];
int fd;
if (entry->flags & E_SEARCH_DIRS)
fd = findlib(entry);
else
fd = open(entry->filename, O_RDONLY, 0);
if (fd < 0)
error = 1;
else
close(fd);
printf("%s\n", entry->filename);
}
exit(error);
}