Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
riscv-gcc-1
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
riscv-gcc-1
Commits
1fab8e81
Commit
1fab8e81
authored
Apr 01, 1992
by
Richard Stallman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
*** empty log message ***
From-SVN: r656
parent
ef137e0a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
103 deletions
+35
-103
gcc/collect2.c
+35
-103
No files found.
gcc/collect2.c
View file @
1fab8e81
...
...
@@ -45,12 +45,10 @@ extern int errno;
#include "config.h"
#ifndef __STDC__
#include "gvarargs.h"
#define generic char
#define const
#else
#include "gstdarg.h"
#define generic void
#endif
...
...
@@ -198,11 +196,8 @@ static void choose_temp_base ();
generic
*
xcalloc
();
generic
*
xmalloc
();
#if !defined(HAVE_STRERROR) && !defined(_OSF_SOURCE)
char
*
strerror
(
e
)
my_
strerror
(
e
)
int
e
;
{
extern
char
*
sys_errlist
[];
...
...
@@ -218,9 +213,6 @@ strerror (e)
sprintf
(
buffer
,
"Unknown error %d"
,
e
);
return
buffer
;
}
#endif
/* Delete tempfiles and exit function. */
...
...
@@ -238,109 +230,43 @@ my_exit (status)
}
#ifndef __STDC__
/* Die when sys call fails. */
/*VARARGS*/
static
void
fatal_perror
(
va_alist
)
fatal_perror
(
string
,
arg1
,
arg2
,
arg3
)
char
*
string
;
{
char
*
string
;
va_list
vptr
;
int
e
=
errno
;
va_start
(
vptr
);
string
=
va_arg
(
vptr
,
char
*
);
fprintf
(
stderr
,
"collect: "
);
vfprintf
(
stderr
,
string
,
vptr
);
fprintf
(
stderr
,
": %s
\n
"
,
strerror
(
e
));
va_end
(
vptr
);
fprintf
(
stderr
,
string
,
arg1
,
arg2
,
arg3
);
fprintf
(
stderr
,
": %s
\n
"
,
my_strerror
(
e
));
my_exit
(
1
);
}
/* Just die. */
/*VARARGS*/
static
void
fatal
(
va_alist
)
fatal
(
string
,
arg1
,
arg2
,
arg3
)
char
*
string
;
{
char
*
string
;
va_list
vptr
;
va_start
(
vptr
);
string
=
va_arg
(
vptr
,
char
*
);
fprintf
(
stderr
,
"collect: "
);
vfprintf
(
stderr
,
string
,
vptr
);
fprintf
(
stderr
,
string
,
arg1
,
arg2
,
arg3
);
fprintf
(
stderr
,
"
\n
"
);
va_end
(
vptr
);
my_exit
(
1
);
}
/* Write error message. */
/*VARARGS*/
static
void
error
(
va_alist
)
error
(
string
,
arg1
,
arg2
,
arg3
,
arg4
)
char
*
string
;
{
char
*
string
;
va_list
vptr
;
va_start
(
vptr
);
string
=
va_arg
(
vptr
,
char
*
);
fprintf
(
stderr
,
"collect: "
);
vfprintf
(
stderr
,
string
,
vptr
);
fprintf
(
stderr
,
string
,
arg1
,
arg2
,
arg3
,
arg4
);
fprintf
(
stderr
,
"
\n
"
);
va_end
(
vptr
);
}
#else
static
void
fatal_perror
(
char
*
string
,
...)
{
va_list
vptr
;
int
e
=
errno
;
va_start
(
vptr
,
string
);
fprintf
(
stderr
,
"collect: "
);
vfprintf
(
stderr
,
string
,
vptr
);
fprintf
(
stderr
,
": %s
\n
"
,
strerror
(
e
));
va_end
(
vptr
);
my_exit
(
1
);
}
/* Just die. */
static
void
fatal
(
char
*
string
,
...)
{
va_list
vptr
;
va_start
(
vptr
,
string
);
fprintf
(
stderr
,
"collect: "
);
vfprintf
(
stderr
,
string
,
vptr
);
fprintf
(
stderr
,
"
\n
"
);
va_end
(
vptr
);
my_exit
(
1
);
}
/* Write error message. */
static
void
error
(
char
*
string
,
...)
{
va_list
vptr
;
va_start
(
vptr
,
string
);
fprintf
(
stderr
,
"collect: "
);
vfprintf
(
stderr
,
string
,
vptr
);
fprintf
(
stderr
,
"
\n
"
);
va_end
(
vptr
);
}
#endif
/* In case obstack is linked in, and abort is defined to fancy_abort,
provide a default entry. */
...
...
@@ -374,7 +300,7 @@ xcalloc (size1, size2)
if
(
ptr
)
return
ptr
;
fatal
(
"
Out of memory.
"
);
fatal
(
"
out of memory
"
);
return
(
generic
*
)
0
;
}
...
...
@@ -386,7 +312,7 @@ xmalloc (size)
if
(
ptr
)
return
ptr
;
fatal
(
"
Out of memory.
"
);
fatal
(
"
out of memory
"
);
return
(
generic
*
)
0
;
}
...
...
@@ -398,7 +324,8 @@ savestring (input, size)
int
size
;
{
char
*
output
=
(
char
*
)
xmalloc
(
size
+
1
);
strcpy
(
output
,
input
);
bcopy
(
input
,
output
,
size
);
output
[
size
]
=
0
;
return
output
;
}
...
...
@@ -792,12 +719,12 @@ main (argc, argv)
outf
=
fopen
(
c_file
,
"w"
);
if
(
outf
==
(
FILE
*
)
0
)
fatal_perror
(
"
Can't write
%s"
,
c_file
);
fatal_perror
(
"%s"
,
c_file
);
write_c_file
(
outf
,
c_file
);
if
(
fclose
(
outf
))
fatal_perror
(
"
Can't close
%s"
,
c_file
);
fatal_perror
(
"
closing
%s"
,
c_file
);
if
(
debug
)
{
...
...
@@ -897,7 +824,7 @@ fork_execute (prog, argv)
if
(
pid
==
0
)
/* child context */
{
execvp
(
prog
,
argv
);
fatal_perror
(
"
Execute
%s"
,
prog
);
fatal_perror
(
"
executing
%s"
,
prog
);
}
int_handler
=
(
void
(
*
)
())
signal
(
SIGINT
,
SIG_IGN
);
...
...
@@ -1070,16 +997,16 @@ scan_prog_file (prog_name, which_pass)
{
/* setup stdout */
if
(
dup2
(
pipe_fd
[
1
],
1
)
<
0
)
fatal_perror
(
"
D
up2 (%d, 1)"
,
pipe_fd
[
1
]);
fatal_perror
(
"
d
up2 (%d, 1)"
,
pipe_fd
[
1
]);
if
(
close
(
pipe_fd
[
0
])
<
0
)
fatal_perror
(
"
C
lose (%d)"
,
pipe_fd
[
0
]);
fatal_perror
(
"
c
lose (%d)"
,
pipe_fd
[
0
]);
if
(
close
(
pipe_fd
[
1
])
<
0
)
fatal_perror
(
"
C
lose (%d)"
,
pipe_fd
[
1
]);
fatal_perror
(
"
c
lose (%d)"
,
pipe_fd
[
1
]);
execv
(
nm_file_name
,
nm_argv
);
fatal_perror
(
"
Execute
%s"
,
nm_file_name
);
fatal_perror
(
"
executing
%s"
,
nm_file_name
);
}
/* Parent context from here on. */
...
...
@@ -1087,7 +1014,7 @@ scan_prog_file (prog_name, which_pass)
quit_handler
=
(
void
(
*
)
())
signal
(
SIGQUIT
,
SIG_IGN
);
if
(
close
(
pipe_fd
[
1
])
<
0
)
fatal_perror
(
"
C
lose (%d)"
,
pipe_fd
[
1
]);
fatal_perror
(
"
c
lose (%d)"
,
pipe_fd
[
1
]);
if
(
debug
)
fprintf
(
stderr
,
"
\n
nm output with constructors/destructors.
\n
"
);
...
...
@@ -1351,7 +1278,7 @@ scan_prog_file (prog_name, which_pass)
prog_fd
=
open
(
prog_name
,
(
rw
)
?
O_RDWR
:
O_RDONLY
);
if
(
prog_fd
<
0
)
fatal_perror
(
"
C
an't read %s"
,
prog_name
);
fatal_perror
(
"
c
an't read %s"
,
prog_name
);
obj_file
=
read_file
(
prog_name
,
prog_fd
,
rw
);
obj
=
obj_file
->
start
;
...
...
@@ -1374,7 +1301,7 @@ scan_prog_file (prog_name, which_pass)
||
hdr
.
moh_cpu_subtype
!=
OUR_CPU_SUBTYPE
||
hdr
.
moh_vendor_type
!=
OUR_VENDOR_TYPE
)
{
fatal
(
"incompatibilities
exist between object file & expected values.
"
);
fatal
(
"incompatibilities
between object file & expected values
"
);
}
#endif
...
...
@@ -1505,7 +1432,7 @@ scan_prog_file (prog_name, which_pass)
}
if
(
symbol_load_cmds
==
0
)
fatal
(
"no symbol table found
.
"
);
fatal
(
"no symbol table found"
);
/* Update the program file now, rewrite header and load commands. At present,
we assume that there is enough space after the last load command to insert
...
...
@@ -1518,10 +1445,15 @@ scan_prog_file (prog_name, which_pass)
size_t
size
;
if
(
cmd_strings
==
-
1
)
fatal
(
"no cmd_strings found."
);
fatal
(
"no cmd_strings found"
);
/* Add __main to initializer list.
If we are building a program instead of a shared library, don't
do anything, since in the current version, you cannot do mallocs
and such in the constructors. */
/* Add __main to initializer list. */
if
(
main_sym
!=
(
symbol_info_t
*
)
0
)
if
(
main_sym
!=
(
symbol_info_t
*
)
0
&&
((
hdr
.
moh_flags
&
MOH_EXECABLE_F
)
==
0
)
)
add_func_table
(
&
hdr
,
load_array
,
main_sym
,
FNTC_INITIALIZATION
);
if
(
debug
)
...
...
@@ -1583,7 +1515,7 @@ scan_prog_file (prog_name, which_pass)
end_file
(
obj_file
);
if
(
close
(
prog_fd
))
fatal_perror
(
"
Can't close
%s"
,
prog_name
);
fatal_perror
(
"
closing
%s"
,
prog_name
);
if
(
debug
)
fprintf
(
stderr
,
"
\n
"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment