From d25562909d350a2ede1af20506d2de39eadcbf30 Mon Sep 17 00:00:00 2001 From: jdp Date: Sat, 22 Mar 1997 02:59:40 +0000 Subject: 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) --- gnu/usr.bin/ld/ld.1 | 7 +++++-- gnu/usr.bin/ld/ld.1aout | 7 +++++-- gnu/usr.bin/ld/ld.c | 34 +++++++++++++++++++++++++++++++++- 3 files changed, 43 insertions(+), 5 deletions(-) (limited to 'gnu/usr.bin') diff --git a/gnu/usr.bin/ld/ld.1 b/gnu/usr.bin/ld/ld.1 index dab8bbf..837778c 100644 --- a/gnu/usr.bin/ld/ld.1 +++ b/gnu/usr.bin/ld/ld.1 @@ -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 diff --git a/gnu/usr.bin/ld/ld.1aout b/gnu/usr.bin/ld/ld.1aout index dab8bbf..837778c 100644 --- a/gnu/usr.bin/ld/ld.1aout +++ b/gnu/usr.bin/ld/ld.1aout @@ -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 diff --git a/gnu/usr.bin/ld/ld.c b/gnu/usr.bin/ld/ld.c index 9f8f94b..fb2baac 100644 --- a/gnu/usr.bin/ld/ld.c +++ b/gnu/usr.bin/ld/ld.c @@ -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); +} -- cgit v1.1