diff --git a/gnu/usr.bin/ld/ld.1 b/gnu/usr.bin/ld/ld.1 index f3a12c448c2d..0c9545a45bd0 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 f3a12c448c2d..0c9545a45bd0 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 49384f2cd9e2..a0d8ee1d7ef4 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. */