SCCS-vsn: old/ld/ld.c 5.13
off_t offset = sizeof (off_t);
int ofilfnd; /* -o given; otherwise move l.out to a.out */
off_t offset = sizeof (off_t);
int ofilfnd; /* -o given; otherwise move l.out to a.out */
-char *ofilename = "l.out";
+char *defaultname; /* l.out */
+char *ofilename; /* name given to -o */
int ofilemode; /* respect umask even for unsucessful ld's */
int infil; /* current input file descriptor */
char *filname; /* and its name */
int ofilemode; /* respect umask even for unsucessful ld's */
int infil; /* current input file descriptor */
char *filname; /* and its name */
}
if (argc == 1)
exit(4);
}
if (argc == 1)
exit(4);
+ ofilename = defaultname = (char *)genbuildname("l.out");
pagesize = getpagesize();
/*
pagesize = getpagesize();
/*
case 'o':
if (++c >= argc)
error(1, "-o where?");
case 'o':
if (++c >= argc)
error(1, "-o where?");
+ ofilename = (char *)genbuildname(*p++);
ofilfnd++;
continue;
case 'u':
ofilfnd++;
continue;
case 'u':
/*
* We have to insure that the last block of the data segment
* is allocated a full pagesize block. If the underlying
/*
* We have to insure that the last block of the data segment
* is allocated a full pagesize block. If the underlying
finishout()
{
register int i;
finishout()
{
register int i;
int nsymt;
if (sflag==0) {
int nsymt;
if (sflag==0) {
bwrite(&offset, sizeof offset, sout);
}
if (!ofilfnd) {
bwrite(&offset, sizeof offset, sout);
}
if (!ofilfnd) {
- unlink("a.out");
- if (link("l.out", "a.out") < 0)
+ newname = (char *)genbuildname("a.out");
+ unlink(newname);
+ if (link(defaultname, newname) < 0)
error(1, "cannot move l.out to a.out");
error(1, "cannot move l.out to a.out");
}
delarg = errlev;
delexit();
}
delarg = errlev;
delexit();
if (filname[0] == '-' && filname[1] == 'l')
infil = libopen(filname + 2, O_RDONLY);
else
if (filname[0] == '-' && filname[1] == 'l')
infil = libopen(filname + 2, O_RDONLY);
else
- infil = open(filname, O_RDONLY);
+ infil = open((char *)genbuildname(filname), O_RDONLY);
if (infil < 0)
error(1, "cannot open");
fstat(infil, &stb);
if (infil < 0)
error(1, "cannot open");
fstat(infil, &stb);