summaryrefslogtreecommitdiffstats
path: root/gnu/usr.bin
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1996-05-28 16:17:48 +0000
committerphk <phk@FreeBSD.org>1996-05-28 16:17:48 +0000
commit066017bb9c8c34540ca1969ee849cc49b0713353 (patch)
tree4cd050cab9b760f5c6ce399007839df538e53d30 /gnu/usr.bin
parentfdde2d1009ee45ea90d242b3395a17bdc71fd70d (diff)
downloadFreeBSD-src-066017bb9c8c34540ca1969ee849cc49b0713353.zip
FreeBSD-src-066017bb9c8c34540ca1969ee849cc49b0713353.tar.gz
Add an option -O <filename> to ld. From the manpage:
-O filename Specifies the name of the output file. The file is created as filename.tmp and when output is complete renamed to filename. This allows us to: ld -O ${.TARGET} -x -r ${.TARGET}
Diffstat (limited to 'gnu/usr.bin')
-rw-r--r--gnu/usr.bin/ld/ld.19
-rw-r--r--gnu/usr.bin/ld/ld.1aout9
-rw-r--r--gnu/usr.bin/ld/ld.c15
3 files changed, 30 insertions, 3 deletions
diff --git a/gnu/usr.bin/ld/ld.1 b/gnu/usr.bin/ld/ld.1
index f3a12c4..0c9545a 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: ld.1,v 1.8 1994/12/11 21:39:31 ats Exp $
+.\" $Id: ld.1,v 1.9 1994/12/23 22:30:33 nate Exp $
.\"
.Dd October 14, 1993
.Dt LD 1
@@ -49,6 +49,7 @@
.Op Fl l Ar library-specifier
.Op Fl L Ar library-search-path
.Op Fl nostdlib
+.Op Fl O Ar filename
.Op Fl o Ar filename
.Op Fl T Ar address
.Op Fl u Ar symbol
@@ -154,6 +155,12 @@ usually
for
.Ar -l
specified libraries.
+.It Fl O Ar filename
+Specifies the name of the output file.
+The file is created as
+.Ar filename .tmp
+and when output is complete renamed to
+.Ar filename .
.It Fl o Ar filename
Specifies the name of the output file. Defaults to
.Dq a.out.
diff --git a/gnu/usr.bin/ld/ld.1aout b/gnu/usr.bin/ld/ld.1aout
index f3a12c4..0c9545a 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: ld.1,v 1.8 1994/12/11 21:39:31 ats Exp $
+.\" $Id: ld.1,v 1.9 1994/12/23 22:30:33 nate Exp $
.\"
.Dd October 14, 1993
.Dt LD 1
@@ -49,6 +49,7 @@
.Op Fl l Ar library-specifier
.Op Fl L Ar library-search-path
.Op Fl nostdlib
+.Op Fl O Ar filename
.Op Fl o Ar filename
.Op Fl T Ar address
.Op Fl u Ar symbol
@@ -154,6 +155,12 @@ usually
for
.Ar -l
specified libraries.
+.It Fl O Ar filename
+Specifies the name of the output file.
+The file is created as
+.Ar filename .tmp
+and when output is complete renamed to
+.Ar filename .
.It Fl o Ar filename
Specifies the name of the output file. Defaults to
.Dq a.out.
diff --git a/gnu/usr.bin/ld/ld.c b/gnu/usr.bin/ld/ld.c
index 49384f2..a0d8ee1 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: ld.c,v 1.31 1995/10/24 06:47:57 ache Exp $
+ * $Id: ld.c,v 1.32 1996/04/24 23:31:08 jdp Exp $
*/
/* Define how to initialize system-dependent header fields. */
@@ -135,6 +135,7 @@ int input_desc;
/* The name of the file to write; "a.out" by default. */
char *output_filename; /* Output file name. */
+char *real_output_filename; /* Output file name. */
FILE *outstream; /* Output file descriptor. */
struct exec outheader; /* Output file header. */
int magic; /* Output file magic. */
@@ -424,6 +425,7 @@ classify_arg(arg)
case 'e':
case 'L':
case 'l':
+ case 'O':
case 'o':
case 'u':
case 'V':
@@ -697,6 +699,13 @@ decode_option(swt, arg)
magic = NMAGIC;
return;
+ case 'O':
+ output_filename = malloc(strlen(arg)+4);
+ strcpy(output_filename, arg);
+ strcat(output_filename, ".tmp");
+ real_output_filename = arg;
+ return;
+
case 'o':
output_filename = arg;
return;
@@ -2514,6 +2523,10 @@ write_output()
if (ferror(outstream) || fclose(outstream) != 0)
err(1, "write_output: %s", output_filename);
outstream = 0;
+ if (real_output_filename)
+ if (rename(output_filename, real_output_filename))
+ err(1, "rename output: %s to %s",
+ output_filename, real_output_filename);
}
/* Total number of symbols to be written in the output file. */
OpenPOWER on IntegriCloud