Commit d4058195 by Kaveh R. Ghazi Committed by Kaveh Ghazi

Makefile.in (tlink.o): Don't depend on toplev.h.

	* Makefile.in (tlink.o): Don't depend on toplev.h.

	* collect2.c (c_file, o_file, export_file, import_file, ldout,
	output_file, nm_file_name, ldd_file_name, strip_file_name,
	c_file_name, prefix_list, libexts, is_ctor_dtor, find_a_file,
	add_prefix, prefix_from_env, prefix_from_string, do_wait,
	fork_execute, maybe_unlink, add_to_list,
	extract_init_priority, write_list, dump_list,
	dump_prefix_list, write_list_with_asm, write_c_file,
	write_c_file_stat, write_c_file_glob, scan_prog_file,
	scan_libraries, is_in_list, resolve_lib_name, use_import_list,
	ignore_library, extract_string, notice, dump_file, target_machine,
	collect_wait, collect_execute, libname, locatelib, aix_std_libs,
	read_file, print_load_command): Constify a char*.
	(fdopen, error, fatal, fatal_perror): Don't prototype.
	(my_strerror): Remove.  All callers use xstrerror instead.
	(xcalloc, xmalloc, xrealloc, xstrdup, putenv): Remove definitions.
	(main): Add prototype.  Constify lots of char* ptrs.  Change calls
	to xcalloc/strcpy/strcat/...  to one call to concat.
	(main, scan_prog_file, scan_libraries): Use an intermediate
	`const char **' to build an argv array.
	(mapfile, libselect, libcompare, locatelib): Add prototypes.

	* collect2.h (collect_execute, collect_wait, dump_file,
	file_exists): Constify a char*.
	(ldout, c_file_name, temporary_obstack, permanent_obstack,
	temporary_firstobj, vflag, debug): Add extern declarations.
	(fancy_abort, error, notice, fatal, fatal_perror): Add prototypes.

	* tlink.c: Don't include toplev.h.
	(vflag, debug, ldout, c_file_name, temporary_obstack,
	permanent_obstack, temporary_firstobj): Don't declare.
	(tlink_execute, frob_extension, symbol_hash_lookup,
	file_hash_lookup, demangled_hash_lookup, tlink_init, freadsym,
	recompile_files, read_repo_files, demangle_new_symbols,
	scan_linker_output): Constify a char*.
	(symbol_hash_newfunc, file_hash_newfunc, demangled_hash_newfunc,
	do_tlink): Mark parameters with ATTRIBUTE_UNUSED.

From-SVN: r29087
parent 2f11d407
No preview for this file type
...@@ -1356,7 +1356,7 @@ collect2.o : collect2.c $(CONFIG_H) system.h gstab.h intl.h \ ...@@ -1356,7 +1356,7 @@ collect2.o : collect2.c $(CONFIG_H) system.h gstab.h intl.h \
-DTARGET_MACHINE=\"$(target_alias)\" $(MAYBE_USE_COLLECT2) \ -DTARGET_MACHINE=\"$(target_alias)\" $(MAYBE_USE_COLLECT2) \
-c `echo $(srcdir)/collect2.c | sed 's,^\./,,'` -c `echo $(srcdir)/collect2.c | sed 's,^\./,,'`
tlink.o: tlink.c $(DEMANGLE_H) hash.h $(CONFIG_H) system.h toplev.h collect2.h tlink.o: tlink.c $(DEMANGLE_H) hash.h $(CONFIG_H) system.h collect2.h
hash.o: hash.c hash.h system.h toplev.h hash.o: hash.c hash.h system.h toplev.h
vfprintf.o: $(srcdir)/../libiberty/vfprintf.c $(CONFIG_H) system.h vfprintf.o: $(srcdir)/../libiberty/vfprintf.c $(CONFIG_H) system.h
......
...@@ -53,7 +53,7 @@ Boston, MA 02111-1307, USA. */ ...@@ -53,7 +53,7 @@ Boston, MA 02111-1307, USA. */
#define obstack_chunk_alloc xmalloc #define obstack_chunk_alloc xmalloc
#define obstack_chunk_free free #define obstack_chunk_free free
extern char *make_temp_file PROTO ((char *)); extern char *make_temp_file PROTO ((const char *));
/* On certain systems, we have code that works by scanning the object file /* On certain systems, we have code that works by scanning the object file
directly. But this code uses system-specific header files and library directly. But this code uses system-specific header files and library
...@@ -196,20 +196,20 @@ int debug; /* true if -debug */ ...@@ -196,20 +196,20 @@ int debug; /* true if -debug */
static int shared_obj; /* true if -shared */ static int shared_obj; /* true if -shared */
static char *c_file; /* <xxx>.c for constructor/destructor list. */ static const char *c_file; /* <xxx>.c for constructor/destructor list. */
static char *o_file; /* <xxx>.o for constructor/destructor list. */ static const char *o_file; /* <xxx>.o for constructor/destructor list. */
#ifdef COLLECT_EXPORT_LIST #ifdef COLLECT_EXPORT_LIST
static char *export_file; /* <xxx>.x for AIX export list. */ static const char *export_file; /* <xxx>.x for AIX export list. */
static char *import_file; /* <xxx>.p for AIX import list. */ static const char *import_file; /* <xxx>.p for AIX import list. */
#endif #endif
char *ldout; /* File for ld errors. */ const char *ldout; /* File for ld errors. */
static char *output_file; /* Output file for ld. */ static const char *output_file; /* Output file for ld. */
static char *nm_file_name; /* pathname of nm */ static const char *nm_file_name; /* pathname of nm */
#ifdef LDD_SUFFIX #ifdef LDD_SUFFIX
static char *ldd_file_name; /* pathname of ldd (or equivalent) */ static const char *ldd_file_name; /* pathname of ldd (or equivalent) */
#endif #endif
static char *strip_file_name; /* pathname of strip */ static const char *strip_file_name; /* pathname of strip */
char *c_file_name; /* pathname of gcc */ const char *c_file_name; /* pathname of gcc */
static char *initname, *fininame; /* names of init and fini funcs */ static char *initname, *fininame; /* names of init and fini funcs */
static struct head constructors; /* list of constructors found */ static struct head constructors; /* list of constructors found */
...@@ -231,8 +231,6 @@ int pexecute_pid; ...@@ -231,8 +231,6 @@ int pexecute_pid;
/* Defined in the automatically-generated underscore.c. */ /* Defined in the automatically-generated underscore.c. */
extern int prepends_underscore; extern int prepends_underscore;
extern FILE *fdopen ();
#ifndef GET_ENV_PATH_LIST #ifndef GET_ENV_PATH_LIST
#define GET_ENV_PATH_LIST(VAR,NAME) do { (VAR) = getenv (NAME); } while (0) #define GET_ENV_PATH_LIST(VAR,NAME) do { (VAR) = getenv (NAME); } while (0)
#endif #endif
...@@ -242,7 +240,7 @@ extern FILE *fdopen (); ...@@ -242,7 +240,7 @@ extern FILE *fdopen ();
struct prefix_list struct prefix_list
{ {
char *prefix; /* String to prepend to the path. */ const char *prefix; /* String to prepend to the path. */
struct prefix_list *next; /* Next in linked list. */ struct prefix_list *next; /* Next in linked list. */
}; };
...@@ -250,7 +248,7 @@ struct path_prefix ...@@ -250,7 +248,7 @@ struct path_prefix
{ {
struct prefix_list *plist; /* List of prefixes to try */ struct prefix_list *plist; /* List of prefixes to try */
int max_len; /* Max length of a prefix in PLIST */ int max_len; /* Max length of a prefix in PLIST */
char *name; /* Name of this list (used in config stuff) */ const char *name; /* Name of this list (used in config stuff) */
}; };
#ifdef COLLECT_EXPORT_LIST #ifdef COLLECT_EXPORT_LIST
...@@ -260,48 +258,47 @@ static struct path_prefix cmdline_lib_dirs; /* directories specified with -L */ ...@@ -260,48 +258,47 @@ static struct path_prefix cmdline_lib_dirs; /* directories specified with -L */
static struct path_prefix libpath_lib_dirs; /* directories in LIBPATH */ static struct path_prefix libpath_lib_dirs; /* directories in LIBPATH */
static struct path_prefix *libpaths[3] = {&cmdline_lib_dirs, static struct path_prefix *libpaths[3] = {&cmdline_lib_dirs,
&libpath_lib_dirs, NULL}; &libpath_lib_dirs, NULL};
static char *libexts[3] = {"a", "so", NULL}; /* possible library extentions */ static const char *libexts[3] = {"a", "so", NULL}; /* possible library extentions */
#endif #endif
void error PVPROTO((const char *, ...)) ATTRIBUTE_PRINTF_1;
void fatal PVPROTO((const char *, ...))
ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN;
void fatal_perror PVPROTO((const char *, ...))
ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN;
static char *my_strerror PROTO((int));
static const char *my_strsignal PROTO((int)); static const char *my_strsignal PROTO((int));
static void handler PROTO((int)); static void handler PROTO((int));
static int is_ctor_dtor PROTO((char *)); static int is_ctor_dtor PROTO((const char *));
static char *find_a_file PROTO((struct path_prefix *, char *)); static char *find_a_file PROTO((struct path_prefix *, const char *));
static void add_prefix PROTO((struct path_prefix *, char *)); static void add_prefix PROTO((struct path_prefix *, const char *));
static void prefix_from_env PROTO((char *, struct path_prefix *)); static void prefix_from_env PROTO((const char *, struct path_prefix *));
static void prefix_from_string PROTO((char *, struct path_prefix *)); static void prefix_from_string PROTO((const char *, struct path_prefix *));
static void do_wait PROTO((char *)); static void do_wait PROTO((const char *));
static void fork_execute PROTO((char *, char **)); static void fork_execute PROTO((const char *, char **));
static void maybe_unlink PROTO((char *)); static void maybe_unlink PROTO((const char *));
static void add_to_list PROTO((struct head *, char *)); static void add_to_list PROTO((struct head *, const char *));
static int extract_init_priority PROTO((char *)); static int extract_init_priority PROTO((const char *));
static void sort_ids PROTO((struct head *)); static void sort_ids PROTO((struct head *));
static void write_list PROTO((FILE *, char *, struct id *)); static void write_list PROTO((FILE *, const char *, struct id *));
#ifdef COLLECT_EXPORT_LIST #ifdef COLLECT_EXPORT_LIST
static void dump_list PROTO((FILE *, char *, struct id *)); static void dump_list PROTO((FILE *, const char *, struct id *));
#endif #endif
#if 0 #if 0
static void dump_prefix_list PROTO((FILE *, char *, struct prefix_list *)); static void dump_prefix_list PROTO((FILE *, const char *, struct prefix_list *));
#endif
static void write_list_with_asm PROTO((FILE *, const char *, struct id *));
static void write_c_file PROTO((FILE *, const char *));
static void write_c_file_stat PROTO((FILE *, const char *));
#ifndef LD_INIT_SWITCH
static void write_c_file_glob PROTO((FILE *, const char *));
#endif #endif
static void write_list_with_asm PROTO((FILE *, char *, struct id *)); static void scan_prog_file PROTO((const char *, enum pass));
static void write_c_file PROTO((FILE *, char *));
static void scan_prog_file PROTO((char *, enum pass));
#ifdef SCAN_LIBRARIES #ifdef SCAN_LIBRARIES
static void scan_libraries PROTO((char *)); static void scan_libraries PROTO((const char *));
#endif #endif
#ifdef COLLECT_EXPORT_LIST #ifdef COLLECT_EXPORT_LIST
static int is_in_list PROTO((char *, struct id *)); static int is_in_list PROTO((const char *, struct id *));
static void write_aix_file PROTO((FILE *, struct id *)); static void write_aix_file PROTO((FILE *, struct id *));
static char *resolve_lib_name PROTO((char *)); static char *resolve_lib_name PROTO((const char *));
static int use_import_list PROTO((char *)); static int use_import_list PROTO((const char *));
static int ignore_library PROTO((char *)); static int ignore_library PROTO((const char *));
#endif #endif
static char *extract_string PROTO((const char **));
#ifdef NO_DUP2 #ifdef NO_DUP2
int int
...@@ -325,26 +322,6 @@ dup2 (oldfd, newfd) ...@@ -325,26 +322,6 @@ dup2 (oldfd, newfd)
} }
#endif #endif
static char *
my_strerror (e)
int e;
{
#ifdef HAVE_STRERROR
return strerror (e);
#else
if (!e)
return "";
if (e > 0 && e < sys_nerr)
return sys_errlist[e];
return "errno = ?";
#endif
}
static const char * static const char *
my_strsignal (s) my_strsignal (s)
int s; int s;
...@@ -403,17 +380,17 @@ collect_exit (status) ...@@ -403,17 +380,17 @@ collect_exit (status)
/* Notify user of a non-error. */ /* Notify user of a non-error. */
void void
notice VPROTO((char *msgid, ...)) notice VPROTO((const char *msgid, ...))
{ {
#ifndef ANSI_PROTOTYPES #ifndef ANSI_PROTOTYPES
char *msgid; const char *msgid;
#endif #endif
va_list ap; va_list ap;
VA_START (ap, msgid); VA_START (ap, msgid);
#ifndef ANSI_PROTOTYPES #ifndef ANSI_PROTOTYPES
msgid = va_arg (ap, char *); msgid = va_arg (ap, const char *);
#endif #endif
vfprintf (stderr, _(msgid), ap); vfprintf (stderr, _(msgid), ap);
...@@ -439,7 +416,7 @@ fatal_perror VPROTO((const char * msgid, ...)) ...@@ -439,7 +416,7 @@ fatal_perror VPROTO((const char * msgid, ...))
fprintf (stderr, "collect2: "); fprintf (stderr, "collect2: ");
vfprintf (stderr, _(msgid), ap); vfprintf (stderr, _(msgid), ap);
fprintf (stderr, ": %s\n", my_strerror (e)); fprintf (stderr, ": %s\n", xstrerror (e));
va_end (ap); va_end (ap);
collect_exit (FATAL_EXIT_CODE); collect_exit (FATAL_EXIT_CODE);
...@@ -526,67 +503,20 @@ handler (signo) ...@@ -526,67 +503,20 @@ handler (signo)
} }
PTR
xcalloc (size1, size2)
size_t size1, size2;
{
PTR ptr = (PTR) calloc (size1, size2);
if (!ptr)
fatal ("out of memory");
return ptr;
}
PTR
xmalloc (size)
size_t size;
{
PTR ptr = (PTR) malloc (size);
if (!ptr)
fatal ("out of memory");
return ptr;
}
PTR
xrealloc (old, size)
PTR old;
size_t size;
{
register PTR ptr;
if (old)
ptr = (PTR) realloc (old, size);
else
ptr = (PTR) malloc (size);
if (ptr == 0)
fatal ("virtual memory exhausted");
return ptr;
}
int int
file_exists (name) file_exists (name)
char *name; const char *name;
{ {
return access (name, R_OK) == 0; return access (name, R_OK) == 0;
} }
/* Make a copy of a string INPUT with size SIZE. */
char *
xstrdup (input)
const char *input;
{
register size_t len = strlen (input) + 1;
register char *output = xmalloc (len);
memcpy (output, input, len);
return output;
}
/* Parse a reasonable subset of shell quoting syntax. */ /* Parse a reasonable subset of shell quoting syntax. */
static char * static char *
extract_string (pp) extract_string (pp)
char **pp; const char **pp;
{ {
char *p = *pp; const char *p = *pp;
int backquote = 0; int backquote = 0;
int inside = 0; int inside = 0;
...@@ -615,7 +545,7 @@ extract_string (pp) ...@@ -615,7 +545,7 @@ extract_string (pp)
void void
dump_file (name) dump_file (name)
char *name; const char *name;
{ {
FILE *stream = fopen (name, "r"); FILE *stream = fopen (name, "r");
int no_demangle = !! getenv ("COLLECT_NO_DEMANGLE"); int no_demangle = !! getenv ("COLLECT_NO_DEMANGLE");
...@@ -630,7 +560,8 @@ dump_file (name) ...@@ -630,7 +560,8 @@ dump_file (name)
obstack_1grow (&temporary_obstack, c); obstack_1grow (&temporary_obstack, c);
if (obstack_object_size (&temporary_obstack) > 0) if (obstack_object_size (&temporary_obstack) > 0)
{ {
char *word, *p, *result; const char *word, *p;
char *result;
obstack_1grow (&temporary_obstack, '\0'); obstack_1grow (&temporary_obstack, '\0');
word = obstack_finish (&temporary_obstack); word = obstack_finish (&temporary_obstack);
...@@ -676,13 +607,13 @@ dump_file (name) ...@@ -676,13 +607,13 @@ dump_file (name)
static int static int
is_ctor_dtor (s) is_ctor_dtor (s)
char *s; const char *s;
{ {
struct names { char *name; int len; int ret; int two_underscores; }; struct names { const char *name; int len; int ret; int two_underscores; };
register struct names *p; register struct names *p;
register int ch; register int ch;
register char *orig_s = s; register const char *orig_s = s;
static struct names special[] = { static struct names special[] = {
#ifdef NO_DOLLAR_IN_LABEL #ifdef NO_DOLLAR_IN_LABEL
...@@ -731,54 +662,6 @@ is_ctor_dtor (s) ...@@ -731,54 +662,6 @@ is_ctor_dtor (s)
return 0; return 0;
} }
/* Routine to add variables to the environment. */
#ifndef HAVE_PUTENV
int
putenv (str)
char *str;
{
#ifndef VMS /* nor about VMS */
extern char **environ;
char **old_environ = environ;
char **envp;
int num_envs = 0;
int name_len = 1;
char *p = str;
int ch;
while ((ch = *p++) != '\0' && ch != '=')
name_len++;
if (!ch)
abort ();
/* Search for replacing an existing environment variable, and
count the number of total environment variables. */
for (envp = old_environ; *envp; envp++)
{
num_envs++;
if (!strncmp (str, *envp, name_len))
{
*envp = str;
return 0;
}
}
/* Add a new environment variable */
environ = (char **) xmalloc (sizeof (char *) * (num_envs+2));
*environ = str;
bcopy ((char *) old_environ, (char *) (environ + 1),
sizeof (char *) * (num_envs+1));
return 0;
#endif /* VMS */
}
#endif /* HAVE_PUTENV */
/* By default, colon separates directories in a path. */ /* By default, colon separates directories in a path. */
#ifndef PATH_SEPARATOR #ifndef PATH_SEPARATOR
#define PATH_SEPARATOR ':' #define PATH_SEPARATOR ':'
...@@ -793,7 +676,7 @@ static struct path_prefix cpath, path; ...@@ -793,7 +676,7 @@ static struct path_prefix cpath, path;
/* This is the name of the target machine. We use it to form the name /* This is the name of the target machine. We use it to form the name
of the files to execute. */ of the files to execute. */
static char *target_machine = TARGET_MACHINE; static const char *const target_machine = TARGET_MACHINE;
#endif #endif
/* Search for NAME using prefix list PPREFIX. We only look for executable /* Search for NAME using prefix list PPREFIX. We only look for executable
...@@ -804,7 +687,7 @@ static char *target_machine = TARGET_MACHINE; ...@@ -804,7 +687,7 @@ static char *target_machine = TARGET_MACHINE;
static char * static char *
find_a_file (pprefix, name) find_a_file (pprefix, name)
struct path_prefix *pprefix; struct path_prefix *pprefix;
char *name; const char *name;
{ {
char *temp; char *temp;
struct prefix_list *pl; struct prefix_list *pl;
...@@ -887,7 +770,7 @@ find_a_file (pprefix, name) ...@@ -887,7 +770,7 @@ find_a_file (pprefix, name)
static void static void
add_prefix (pprefix, prefix) add_prefix (pprefix, prefix)
struct path_prefix *pprefix; struct path_prefix *pprefix;
char *prefix; const char *prefix;
{ {
struct prefix_list *pl, **prev; struct prefix_list *pl, **prev;
int len; int len;
...@@ -922,10 +805,10 @@ add_prefix (pprefix, prefix) ...@@ -922,10 +805,10 @@ add_prefix (pprefix, prefix)
static void static void
prefix_from_env (env, pprefix) prefix_from_env (env, pprefix)
char *env; const char *env;
struct path_prefix *pprefix; struct path_prefix *pprefix;
{ {
char *p; const char *p;
GET_ENV_PATH_LIST (p, env); GET_ENV_PATH_LIST (p, env);
if (p) if (p)
...@@ -934,10 +817,10 @@ prefix_from_env (env, pprefix) ...@@ -934,10 +817,10 @@ prefix_from_env (env, pprefix)
static void static void
prefix_from_string (p, pprefix) prefix_from_string (p, pprefix)
char *p; const char *p;
struct path_prefix *pprefix; struct path_prefix *pprefix;
{ {
char *startp, *endp; const char *startp, *endp;
char *nstore = (char *) xmalloc (strlen (p) + 3); char *nstore = (char *) xmalloc (strlen (p) + 3);
if (debug) if (debug)
...@@ -976,43 +859,44 @@ prefix_from_string (p, pprefix) ...@@ -976,43 +859,44 @@ prefix_from_string (p, pprefix)
/* Main program. */ /* Main program. */
int main PROTO ((int, char *[]));
int int
main (argc, argv) main (argc, argv)
int argc; int argc;
char *argv[]; char *argv[];
{ {
char *ld_suffix = "ld"; const char *ld_suffix = "ld";
char *full_ld_suffix = ld_suffix; const char *full_ld_suffix = ld_suffix;
char *real_ld_suffix = "real-ld"; const char *real_ld_suffix = "real-ld";
char *collect_ld_suffix = "collect-ld"; const char *collect_ld_suffix = "collect-ld";
char *nm_suffix = "nm"; const char *nm_suffix = "nm";
char *full_nm_suffix = nm_suffix; const char *full_nm_suffix = nm_suffix;
char *gnm_suffix = "gnm"; const char *gnm_suffix = "gnm";
char *full_gnm_suffix = gnm_suffix; const char *full_gnm_suffix = gnm_suffix;
#ifdef LDD_SUFFIX #ifdef LDD_SUFFIX
char *ldd_suffix = LDD_SUFFIX; const char *ldd_suffix = LDD_SUFFIX;
char *full_ldd_suffix = ldd_suffix; const char *full_ldd_suffix = ldd_suffix;
#endif #endif
char *strip_suffix = "strip"; const char *strip_suffix = "strip";
char *full_strip_suffix = strip_suffix; const char *full_strip_suffix = strip_suffix;
char *gstrip_suffix = "gstrip"; const char *gstrip_suffix = "gstrip";
char *full_gstrip_suffix = gstrip_suffix; const char *full_gstrip_suffix = gstrip_suffix;
char *arg; const char *arg;
FILE *outf; FILE *outf;
#ifdef COLLECT_EXPORT_LIST #ifdef COLLECT_EXPORT_LIST
FILE *exportf; FILE *exportf;
FILE *importf; FILE *importf;
#endif #endif
char *ld_file_name; const char *ld_file_name;
char *p; const char *p;
char **c_argv; char **c_argv;
char **c_ptr; const char **c_ptr;
char **ld1_argv; char **ld1_argv;
char **ld1; const char **ld1;
char **ld2_argv; char **ld2_argv;
char **ld2; const char **ld2;
char **object_lst; char **object_lst;
char **object; const char **object;
int first_file; int first_file;
int num_c_args = argc+9; int num_c_args = argc+9;
...@@ -1030,9 +914,9 @@ main (argc, argv) ...@@ -1030,9 +914,9 @@ main (argc, argv)
/* Do not invoke xcalloc before this point, since locale needs to be /* Do not invoke xcalloc before this point, since locale needs to be
set first, in case a diagnostic is issued. */ set first, in case a diagnostic is issued. */
ld1 = ld1_argv = (char **) xcalloc (sizeof (char *), argc+3); ld1 = (const char **)(ld1_argv = (char **) xcalloc(sizeof (char *), argc+3));
ld2 = ld2_argv = (char **) xcalloc (sizeof (char *), argc+6); ld2 = (const char **)(ld2_argv = (char **) xcalloc(sizeof (char *), argc+6));
object = object_lst = (char **) xcalloc (sizeof (char *), argc); object = (const char **)(object_lst = (char **) xcalloc(sizeof (char *), argc));
#ifdef DEBUG #ifdef DEBUG
debug = 1; debug = 1;
...@@ -1064,14 +948,15 @@ main (argc, argv) ...@@ -1064,14 +948,15 @@ main (argc, argv)
p = getenv ("COLLECT_GCC_OPTIONS"); p = getenv ("COLLECT_GCC_OPTIONS");
while (p && *p) while (p && *p)
{ {
char *q = extract_string (&p); const char *q = extract_string (&p);
if (*q == '-' && (q[1] == 'm' || q[1] == 'f')) if (*q == '-' && (q[1] == 'm' || q[1] == 'f'))
num_c_args++; num_c_args++;
} }
obstack_free (&temporary_obstack, temporary_firstobj); obstack_free (&temporary_obstack, temporary_firstobj);
++num_c_args; ++num_c_args;
c_ptr = c_argv = (char **) xcalloc (sizeof (char *), num_c_args); c_ptr = (const char **)
(c_argv = (char **) xcalloc (sizeof (char *), num_c_args));
if (argc < 2) if (argc < 2)
fatal ("no arguments"); fatal ("no arguments");
...@@ -1107,51 +992,23 @@ main (argc, argv) ...@@ -1107,51 +992,23 @@ main (argc, argv)
But it we look for a program in the system directories, we need to But it we look for a program in the system directories, we need to
qualify the program name with the target machine. */ qualify the program name with the target machine. */
full_ld_suffix full_ld_suffix = concat(target_machine, "-", ld_suffix, NULL);
= xcalloc (strlen (ld_suffix) + strlen (target_machine) + 2, 1);
strcpy (full_ld_suffix, target_machine);
strcat (full_ld_suffix, "-");
strcat (full_ld_suffix, ld_suffix);
#if 0 #if 0
full_gld_suffix full_gld_suffix = concat (target_machine, "-", gld_suffix, NULL);
= xcalloc (strlen (gld_suffix) + strlen (target_machine) + 2, 1);
strcpy (full_gld_suffix, target_machine);
strcat (full_gld_suffix, "-");
strcat (full_gld_suffix, gld_suffix);
#endif #endif
full_nm_suffix full_nm_suffix = concat (target_machine, "-", nm_suffix, NULL);
= xcalloc (strlen (nm_suffix) + strlen (target_machine) + 2, 1);
strcpy (full_nm_suffix, target_machine);
strcat (full_nm_suffix, "-");
strcat (full_nm_suffix, nm_suffix);
full_gnm_suffix full_gnm_suffix = concat (target_machine, "-", gnm_suffix, NULL);
= xcalloc (strlen (gnm_suffix) + strlen (target_machine) + 2, 1);
strcpy (full_gnm_suffix, target_machine);
strcat (full_gnm_suffix, "-");
strcat (full_gnm_suffix, gnm_suffix);
#ifdef LDD_SUFFIX #ifdef LDD_SUFFIX
full_ldd_suffix full_ldd_suffix = concat (target_machine, "-", ldd_suffix, NULL);
= xcalloc (strlen (ldd_suffix) + strlen (target_machine) + 2, 1); #endif
strcpy (full_ldd_suffix, target_machine);
strcat (full_ldd_suffix, "-"); full_strip_suffix = concat (target_machine, "-", strip_suffix, NULL);
strcat (full_ldd_suffix, ldd_suffix);
#endif full_gstrip_suffix = concat (target_machine, "-", gstrip_suffix, NULL);
full_strip_suffix
= xcalloc (strlen (strip_suffix) + strlen (target_machine) + 2, 1);
strcpy (full_strip_suffix, target_machine);
strcat (full_strip_suffix, "-");
strcat (full_strip_suffix, strip_suffix);
full_gstrip_suffix
= xcalloc (strlen (gstrip_suffix) + strlen (target_machine) + 2, 1);
strcpy (full_gstrip_suffix, target_machine);
strcat (full_gstrip_suffix, "-");
strcat (full_gstrip_suffix, gstrip_suffix);
#endif /* CROSS_COMPILE */ #endif /* CROSS_COMPILE */
/* Try to discover a valid linker/nm/strip to use. */ /* Try to discover a valid linker/nm/strip to use. */
...@@ -1216,9 +1073,7 @@ main (argc, argv) ...@@ -1216,9 +1073,7 @@ main (argc, argv)
if (c_file_name == 0) if (c_file_name == 0)
{ {
#ifdef CROSS_COMPILE #ifdef CROSS_COMPILE
c_file_name = xcalloc (sizeof ("gcc-") + strlen (target_machine) + 1, 1); c_file_name = concat (target_machine, "-gcc", NULL);
strcpy (c_file_name, target_machine);
strcat (c_file_name, "-gcc");
#else #else
c_file_name = "gcc"; c_file_name = "gcc";
#endif #endif
...@@ -1268,7 +1123,7 @@ main (argc, argv) ...@@ -1268,7 +1123,7 @@ main (argc, argv)
p = getenv ("COLLECT_GCC_OPTIONS"); p = getenv ("COLLECT_GCC_OPTIONS");
while (p && *p) while (p && *p)
{ {
char *q = extract_string (&p); const char *q = extract_string (&p);
if (*q == '-' && (q[1] == 'm' || q[1] == 'f')) if (*q == '-' && (q[1] == 'm' || q[1] == 'f'))
*c_ptr++ = obstack_copy0 (&permanent_obstack, q, strlen (q)); *c_ptr++ = obstack_copy0 (&permanent_obstack, q, strlen (q));
if (strcmp (q, "-EL") == 0 || strcmp (q, "-EB") == 0) if (strcmp (q, "-EL") == 0 || strcmp (q, "-EB") == 0)
...@@ -1330,7 +1185,7 @@ main (argc, argv) ...@@ -1330,7 +1185,7 @@ main (argc, argv)
#ifdef COLLECT_EXPORT_LIST #ifdef COLLECT_EXPORT_LIST
{ {
/* Resolving full library name. */ /* Resolving full library name. */
char *s = resolve_lib_name (arg+2); const char *s = resolve_lib_name (arg+2);
/* If we will use an import list for this library, /* If we will use an import list for this library,
we should exclude it from ld args. */ we should exclude it from ld args. */
...@@ -1478,7 +1333,7 @@ main (argc, argv) ...@@ -1478,7 +1333,7 @@ main (argc, argv)
#endif #endif
*c_ptr++ = c_file; *c_ptr++ = c_file;
*object = *c_ptr = *ld1 = (char *) 0; *c_ptr = *ld1 = *object = (char *) 0;
if (vflag) if (vflag)
{ {
...@@ -1491,7 +1346,7 @@ main (argc, argv) ...@@ -1491,7 +1346,7 @@ main (argc, argv)
if (debug) if (debug)
{ {
char *ptr; const char *ptr;
fprintf (stderr, "ld_file_name = %s\n", fprintf (stderr, "ld_file_name = %s\n",
(ld_file_name ? ld_file_name : "not found")); (ld_file_name ? ld_file_name : "not found"));
fprintf (stderr, "c_file_name = %s\n", fprintf (stderr, "c_file_name = %s\n",
...@@ -1593,11 +1448,13 @@ main (argc, argv) ...@@ -1593,11 +1448,13 @@ main (argc, argv)
/* Strip now if it was requested on the command line. */ /* Strip now if it was requested on the command line. */
if (strip_flag) if (strip_flag)
{ {
char **strip_argv = (char **) xcalloc (sizeof (char *), 3); char **real_strip_argv = (char **) xcalloc (sizeof (char *), 3);
const char ** strip_argv = (const char **) real_strip_argv;
strip_argv[0] = strip_file_name; strip_argv[0] = strip_file_name;
strip_argv[1] = output_file; strip_argv[1] = output_file;
strip_argv[2] = (char *) 0; strip_argv[2] = (char *) 0;
fork_execute ("strip", strip_argv); fork_execute ("strip", real_strip_argv);
} }
#ifdef COLLECT_EXPORT_LIST #ifdef COLLECT_EXPORT_LIST
...@@ -1705,7 +1562,7 @@ main (argc, argv) ...@@ -1705,7 +1562,7 @@ main (argc, argv)
int int
collect_wait (prog) collect_wait (prog)
char *prog; const char *prog;
{ {
int status; int status;
...@@ -1732,7 +1589,7 @@ collect_wait (prog) ...@@ -1732,7 +1589,7 @@ collect_wait (prog)
static void static void
do_wait (prog) do_wait (prog)
char *prog; const char *prog;
{ {
int ret = collect_wait (prog); int ret = collect_wait (prog);
if (ret != 0) if (ret != 0)
...@@ -1747,9 +1604,9 @@ do_wait (prog) ...@@ -1747,9 +1604,9 @@ do_wait (prog)
void void
collect_execute (prog, argv, redir) collect_execute (prog, argv, redir)
char *prog; const char *prog;
char **argv; char **argv;
char *redir; const char *redir;
{ {
char *errmsg_fmt; char *errmsg_fmt;
char *errmsg_arg; char *errmsg_arg;
...@@ -1760,7 +1617,7 @@ collect_execute (prog, argv, redir) ...@@ -1760,7 +1617,7 @@ collect_execute (prog, argv, redir)
if (vflag || debug) if (vflag || debug)
{ {
char **p_argv; char **p_argv;
char *str; const char *str;
if (argv[0]) if (argv[0])
fprintf (stderr, "%s", argv[0]); fprintf (stderr, "%s", argv[0]);
...@@ -1821,7 +1678,7 @@ collect_execute (prog, argv, redir) ...@@ -1821,7 +1678,7 @@ collect_execute (prog, argv, redir)
static void static void
fork_execute (prog, argv) fork_execute (prog, argv)
char *prog; const char *prog;
char **argv; char **argv;
{ {
collect_execute (prog, argv, NULL); collect_execute (prog, argv, NULL);
...@@ -1832,7 +1689,7 @@ fork_execute (prog, argv) ...@@ -1832,7 +1689,7 @@ fork_execute (prog, argv)
static void static void
maybe_unlink (file) maybe_unlink (file)
char *file; const char *file;
{ {
if (!debug) if (!debug)
unlink (file); unlink (file);
...@@ -1848,7 +1705,7 @@ static long sequence_number = 0; ...@@ -1848,7 +1705,7 @@ static long sequence_number = 0;
static void static void
add_to_list (head_ptr, name) add_to_list (head_ptr, name)
struct head *head_ptr; struct head *head_ptr;
char *name; const char *name;
{ {
struct id *newid struct id *newid
= (struct id *) xcalloc (sizeof (struct id) + strlen (name), 1); = (struct id *) xcalloc (sizeof (struct id) + strlen (name), 1);
...@@ -1882,7 +1739,7 @@ add_to_list (head_ptr, name) ...@@ -1882,7 +1739,7 @@ add_to_list (head_ptr, name)
static int static int
extract_init_priority (name) extract_init_priority (name)
char *name; const char *name;
{ {
int pos = 0, pri; int pos = 0, pri;
...@@ -1943,7 +1800,7 @@ sort_ids (head_ptr) ...@@ -1943,7 +1800,7 @@ sort_ids (head_ptr)
static void static void
write_list (stream, prefix, list) write_list (stream, prefix, list)
FILE *stream; FILE *stream;
char *prefix; const char *prefix;
struct id *list; struct id *list;
{ {
while (list) while (list)
...@@ -1957,7 +1814,7 @@ write_list (stream, prefix, list) ...@@ -1957,7 +1814,7 @@ write_list (stream, prefix, list)
/* This function is really used only on AIX, but may be useful. */ /* This function is really used only on AIX, but may be useful. */
static int static int
is_in_list (prefix, list) is_in_list (prefix, list)
char *prefix; const char *prefix;
struct id *list; struct id *list;
{ {
while (list) while (list)
...@@ -1974,7 +1831,7 @@ is_in_list (prefix, list) ...@@ -1974,7 +1831,7 @@ is_in_list (prefix, list)
static void static void
dump_list (stream, prefix, list) dump_list (stream, prefix, list)
FILE *stream; FILE *stream;
char *prefix; const char *prefix;
struct id *list; struct id *list;
{ {
while (list) while (list)
...@@ -1989,7 +1846,7 @@ dump_list (stream, prefix, list) ...@@ -1989,7 +1846,7 @@ dump_list (stream, prefix, list)
static void static void
dump_prefix_list (stream, prefix, list) dump_prefix_list (stream, prefix, list)
FILE *stream; FILE *stream;
char *prefix; const char *prefix;
struct prefix_list *list; struct prefix_list *list;
{ {
while (list) while (list)
...@@ -2003,7 +1860,7 @@ dump_prefix_list (stream, prefix, list) ...@@ -2003,7 +1860,7 @@ dump_prefix_list (stream, prefix, list)
static void static void
write_list_with_asm (stream, prefix, list) write_list_with_asm (stream, prefix, list)
FILE *stream; FILE *stream;
char *prefix; const char *prefix;
struct id *list; struct id *list;
{ {
while (list) while (list)
...@@ -2020,15 +1877,16 @@ write_list_with_asm (stream, prefix, list) ...@@ -2020,15 +1877,16 @@ write_list_with_asm (stream, prefix, list)
static void static void
write_c_file_stat (stream, name) write_c_file_stat (stream, name)
FILE *stream; FILE *stream;
char *name; const char *name ATTRIBUTE_UNUSED;
{ {
char *prefix, *p, *q; const char *p, *q;
char *prefix, *r;
int frames = (frame_tables.number > 0); int frames = (frame_tables.number > 0);
/* Figure out name of output_file, stripping off .so version. */ /* Figure out name of output_file, stripping off .so version. */
p = rindex (output_file, '/'); p = rindex (output_file, '/');
if (p == 0) if (p == 0)
p = (char *) output_file; p = output_file;
else else
p++; p++;
q = p; q = p;
...@@ -2055,9 +1913,9 @@ write_c_file_stat (stream, name) ...@@ -2055,9 +1913,9 @@ write_c_file_stat (stream, name)
prefix = xmalloc (q - p + 1); prefix = xmalloc (q - p + 1);
strncpy (prefix, p, q - p); strncpy (prefix, p, q - p);
prefix[q - p] = 0; prefix[q - p] = 0;
for (q = prefix; *q; q++) for (r = prefix; *r; r++)
if (!ISALNUM ((unsigned char)*q)) if (!ISALNUM ((unsigned char)*r))
*q = '_'; *r = '_';
if (debug) if (debug)
notice ("\nwrite_c_file - output name is %s, prefix is %s\n", notice ("\nwrite_c_file - output name is %s, prefix is %s\n",
output_file, prefix); output_file, prefix);
...@@ -2155,7 +2013,7 @@ write_c_file_stat (stream, name) ...@@ -2155,7 +2013,7 @@ write_c_file_stat (stream, name)
static void static void
write_c_file_glob (stream, name) write_c_file_glob (stream, name)
FILE *stream; FILE *stream;
char *name; const char *name ATTRIBUTE_UNUSED;
{ {
/* Write the tables as C code */ /* Write the tables as C code */
...@@ -2220,7 +2078,7 @@ write_c_file_glob (stream, name) ...@@ -2220,7 +2078,7 @@ write_c_file_glob (stream, name)
static void static void
write_c_file (stream, name) write_c_file (stream, name)
FILE *stream; FILE *stream;
char *name; const char *name;
{ {
fprintf (stream, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n"); fprintf (stream, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n");
#ifndef LD_INIT_SWITCH #ifndef LD_INIT_SWITCH
...@@ -2259,12 +2117,13 @@ write_aix_file (stream, list) ...@@ -2259,12 +2117,13 @@ write_aix_file (stream, list)
static void static void
scan_prog_file (prog_name, which_pass) scan_prog_file (prog_name, which_pass)
char *prog_name; const char *prog_name;
enum pass which_pass; enum pass which_pass;
{ {
void (*int_handler) (); void (*int_handler) ();
void (*quit_handler) (); void (*quit_handler) ();
char *nm_argv[4]; char *real_nm_argv[4];
const char **nm_argv = (const char **) real_nm_argv;
int pid; int pid;
int argc = 0; int argc = 0;
int pipe_fd[2]; int pipe_fd[2];
...@@ -2295,8 +2154,8 @@ scan_prog_file (prog_name, which_pass) ...@@ -2295,8 +2154,8 @@ scan_prog_file (prog_name, which_pass)
/* Trace if needed. */ /* Trace if needed. */
if (vflag) if (vflag)
{ {
char **p_argv; const char **p_argv;
char *str; const char *str;
for (p_argv = &nm_argv[0]; (str = *p_argv) != (char *) 0; p_argv++) for (p_argv = &nm_argv[0]; (str = *p_argv) != (char *) 0; p_argv++)
fprintf (stderr, " %s", str); fprintf (stderr, " %s", str);
...@@ -2324,7 +2183,7 @@ scan_prog_file (prog_name, which_pass) ...@@ -2324,7 +2183,7 @@ scan_prog_file (prog_name, which_pass)
if (close (pipe_fd[1]) < 0) if (close (pipe_fd[1]) < 0)
fatal_perror ("close %d", pipe_fd[1]); fatal_perror ("close %d", pipe_fd[1]);
execv (nm_file_name, nm_argv); execv (nm_file_name, real_nm_argv);
fatal_perror ("execvp %s", nm_file_name); fatal_perror ("execvp %s", nm_file_name);
} }
...@@ -2446,9 +2305,11 @@ struct head libraries; ...@@ -2446,9 +2305,11 @@ struct head libraries;
/* Map the file indicated by NAME into memory and store its address. */ /* Map the file indicated by NAME into memory and store its address. */
static void mapfile PROTO ((const char *));
static void static void
mapfile (name) mapfile (name)
char *name; const char *name;
{ {
int fp; int fp;
struct stat s; struct stat s;
...@@ -2460,7 +2321,7 @@ mapfile (name) ...@@ -2460,7 +2321,7 @@ mapfile (name)
objsize = s.st_size; objsize = s.st_size;
object = (unsigned) mmap (0, objsize, PROT_READ|PROT_WRITE, MAP_PRIVATE, object = (unsigned) mmap (0, objsize, PROT_READ|PROT_WRITE, MAP_PRIVATE,
fp, 0); fp, 0);
if (object == -1) if (object == (unsigned)-1)
fatal ("unable to mmap file '%s'", name); fatal ("unable to mmap file '%s'", name);
close (fp); close (fp);
...@@ -2468,7 +2329,9 @@ mapfile (name) ...@@ -2468,7 +2329,9 @@ mapfile (name)
/* Helpers for locatelib. */ /* Helpers for locatelib. */
static char *libname; static const char *libname;
static int libselect PROTO ((struct direct *));
static int static int
libselect (d) libselect (d)
...@@ -2484,6 +2347,7 @@ libselect (d) ...@@ -2484,6 +2347,7 @@ libselect (d)
We must verify that the extension is numeric, because Sun saves the We must verify that the extension is numeric, because Sun saves the
original versions of patched libraries with a .FCS extension. Files with original versions of patched libraries with a .FCS extension. Files with
invalid extensions must go last in the sort, so that they will not be used. */ invalid extensions must go last in the sort, so that they will not be used. */
static int libcompare PROTO ((struct direct **, struct direct **));
static int static int
libcompare (d1, d2) libcompare (d1, d2)
...@@ -2528,16 +2392,17 @@ libcompare (d1, d2) ...@@ -2528,16 +2392,17 @@ libcompare (d1, d2)
/* Given the name NAME of a dynamic dependency, find its pathname and add /* Given the name NAME of a dynamic dependency, find its pathname and add
it to the list of libraries. */ it to the list of libraries. */
static void locatelib PROTO ((const char *));
static void static void
locatelib (name) locatelib (name)
char *name; const char *name;
{ {
static char **l; static const char **l;
static int cnt; static int cnt;
char buf[MAXPATHLEN]; char buf[MAXPATHLEN];
char *p, *q; char *p, *q;
char **pp; const char **pp;
if (l == 0) if (l == 0)
{ {
...@@ -2567,7 +2432,7 @@ locatelib (name) ...@@ -2567,7 +2432,7 @@ locatelib (name)
q = (char *) xmalloc (strlen (p) + 1); q = (char *) xmalloc (strlen (p) + 1);
strcpy (q, p); strcpy (q, p);
} }
l = (char **) xmalloc ((cnt + 3) * sizeof (char *)); l = (const char **) xmalloc ((cnt + 3) * sizeof (char *));
pp = l; pp = l;
if (ldr) if (ldr)
{ {
...@@ -2623,7 +2488,7 @@ locatelib (name) ...@@ -2623,7 +2488,7 @@ locatelib (name)
static void static void
scan_libraries (prog_name) scan_libraries (prog_name)
char *prog_name; const char *prog_name;
{ {
struct exec *header; struct exec *header;
char *base; char *base;
...@@ -2698,13 +2563,14 @@ scan_libraries (prog_name) ...@@ -2698,13 +2563,14 @@ scan_libraries (prog_name)
static void static void
scan_libraries (prog_name) scan_libraries (prog_name)
char *prog_name; const char *prog_name;
{ {
static struct head libraries; /* list of shared libraries found */ static struct head libraries; /* list of shared libraries found */
struct id *list; struct id *list;
void (*int_handler) (); void (*int_handler) ();
void (*quit_handler) (); void (*quit_handler) ();
char *ldd_argv[4]; char *ldd_argv[4];
const char **ldd_argv = (const char **) real_ldd_argv;
int pid; int pid;
int argc = 0; int argc = 0;
int pipe_fd[2]; int pipe_fd[2];
...@@ -2732,8 +2598,8 @@ scan_libraries (prog_name) ...@@ -2732,8 +2598,8 @@ scan_libraries (prog_name)
/* Trace if needed. */ /* Trace if needed. */
if (vflag) if (vflag)
{ {
char **p_argv; const char **p_argv;
char *str; const char *str;
for (p_argv = &ldd_argv[0]; (str = *p_argv) != (char *) 0; p_argv++) for (p_argv = &ldd_argv[0]; (str = *p_argv) != (char *) 0; p_argv++)
fprintf (stderr, " %s", str); fprintf (stderr, " %s", str);
...@@ -2761,7 +2627,7 @@ scan_libraries (prog_name) ...@@ -2761,7 +2627,7 @@ scan_libraries (prog_name)
if (close (pipe_fd[1]) < 0) if (close (pipe_fd[1]) < 0)
fatal_perror ("close %d", pipe_fd[1]); fatal_perror ("close %d", pipe_fd[1]);
execv (ldd_file_name, ldd_argv); execv (ldd_file_name, real_ldd_argv);
fatal_perror ("execv %s", ldd_file_name); fatal_perror ("execv %s", ldd_file_name);
} }
...@@ -2876,7 +2742,7 @@ extern char *ldgetname (); ...@@ -2876,7 +2742,7 @@ extern char *ldgetname ();
static void static void
scan_prog_file (prog_name, which_pass) scan_prog_file (prog_name, which_pass)
char *prog_name; const char *prog_name;
enum pass which_pass; enum pass which_pass;
{ {
LDFILE *ldptr = NULL; LDFILE *ldptr = NULL;
...@@ -2901,7 +2767,11 @@ scan_prog_file (prog_name, which_pass) ...@@ -2901,7 +2767,11 @@ scan_prog_file (prog_name, which_pass)
do do
{ {
#endif #endif
if ((ldptr = ldopen (prog_name, ldptr)) != NULL) /* Some platforms (e.g. OSF4) declare ldopen as taking a
non-const char * filename parameter, even though it will not
modify that string. So we must cast away const-ness here,
which will cause -Wcast-qual to burp. */
if ((ldptr = ldopen ((char *)prog_name, ldptr)) != NULL)
{ {
if (! MY_ISCOFF (HEADER (ldptr).f_magic)) if (! MY_ISCOFF (HEADER (ldptr).f_magic))
fatal ("%s: not a COFF file", prog_name); fatal ("%s: not a COFF file", prog_name);
...@@ -3070,7 +2940,7 @@ scan_prog_file (prog_name, which_pass) ...@@ -3070,7 +2940,7 @@ scan_prog_file (prog_name, which_pass)
generate import list for an object or to use it directly. */ generate import list for an object or to use it directly. */
static int static int
use_import_list (prog_name) use_import_list (prog_name)
char *prog_name; const char *prog_name;
{ {
char *p; char *p;
...@@ -3088,7 +2958,7 @@ use_import_list (prog_name) ...@@ -3088,7 +2958,7 @@ use_import_list (prog_name)
returns a full library name including a path. */ returns a full library name including a path. */
static char * static char *
resolve_lib_name (name) resolve_lib_name (name)
char *name; const char *name;
{ {
char *lib_buf; char *lib_buf;
int i, j, l = 0; int i, j, l = 0;
...@@ -3109,7 +2979,7 @@ resolve_lib_name (name) ...@@ -3109,7 +2979,7 @@ resolve_lib_name (name)
/* The following lines are needed because path_prefix list /* The following lines are needed because path_prefix list
may contain directories both with trailing '/' and may contain directories both with trailing '/' and
without it. */ without it. */
char *p = ""; const char *p = "";
if (list->prefix[strlen(list->prefix)-1] != '/') if (list->prefix[strlen(list->prefix)-1] != '/')
p = "/"; p = "/";
sprintf (lib_buf, "%s%slib%s.%s", sprintf (lib_buf, "%s%slib%s.%s",
...@@ -3132,7 +3002,7 @@ if (debug) fprintf (stderr, "found: %s\n", lib_buf); ...@@ -3132,7 +3002,7 @@ if (debug) fprintf (stderr, "found: %s\n", lib_buf);
/* Array of standard AIX libraries which should not /* Array of standard AIX libraries which should not
be scanned for ctors/dtors. */ be scanned for ctors/dtors. */
static char* aix_std_libs[] = { static const char *aix_std_libs[] = {
"/unix", "/unix",
"/lib/libc.a", "/lib/libc.a",
"/lib/libc_r.a", "/lib/libc_r.a",
...@@ -3148,9 +3018,9 @@ static char* aix_std_libs[] = { ...@@ -3148,9 +3018,9 @@ static char* aix_std_libs[] = {
if this name matches the location of a standard AIX library. */ if this name matches the location of a standard AIX library. */
static int static int
ignore_library (name) ignore_library (name)
char *name; const char *name;
{ {
char **p = &aix_std_libs[0]; const char **p = &aix_std_libs[0];
while (*p++ != NULL) while (*p++ != NULL)
if (! strcmp (name, *p)) return 1; if (! strcmp (name, *p)) return 1;
return 0; return 0;
...@@ -3213,7 +3083,7 @@ static void add_func_table PROTO((mo_header_t *, load_all_t *, ...@@ -3213,7 +3083,7 @@ static void add_func_table PROTO((mo_header_t *, load_all_t *,
static void print_header PROTO((mo_header_t *)); static void print_header PROTO((mo_header_t *));
static void print_load_command PROTO((load_union_t *, size_t, int)); static void print_load_command PROTO((load_union_t *, size_t, int));
static void bad_header PROTO((int)); static void bad_header PROTO((int));
static struct file_info *read_file PROTO((char *, int, int)); static struct file_info *read_file PROTO((const char *, int, int));
static void end_file PROTO((struct file_info *)); static void end_file PROTO((struct file_info *));
/* OSF/rose specific version to scan the name list of the loaded /* OSF/rose specific version to scan the name list of the loaded
...@@ -3228,7 +3098,7 @@ static void end_file PROTO((struct file_info *)); ...@@ -3228,7 +3098,7 @@ static void end_file PROTO((struct file_info *));
static void static void
scan_prog_file (prog_name, which_pass) scan_prog_file (prog_name, which_pass)
char *prog_name; const char *prog_name;
enum pass which_pass; enum pass which_pass;
{ {
char *obj; char *obj;
...@@ -3337,7 +3207,7 @@ scan_prog_file (prog_name, which_pass) ...@@ -3337,7 +3207,7 @@ scan_prog_file (prog_name, which_pass)
if (debug) if (debug)
{ {
char *kind = "unknown"; const char *kind = "unknown";
switch (load_hdr->sym.symc_kind) switch (load_hdr->sym.symc_kind)
{ {
...@@ -3628,7 +3498,7 @@ print_load_command (load_hdr, offset, number) ...@@ -3628,7 +3498,7 @@ print_load_command (load_hdr, offset, number)
int number; int number;
{ {
mo_long_t type = load_hdr->hdr.ldci_cmd_type; mo_long_t type = load_hdr->hdr.ldci_cmd_type;
char *type_str = (char *) 0; const char *type_str = (char *) 0;
switch (type) switch (type)
{ {
...@@ -3661,7 +3531,7 @@ print_load_command (load_hdr, offset, number) ...@@ -3661,7 +3531,7 @@ print_load_command (load_hdr, offset, number)
else else
{ {
char *region = ""; const char *region = "";
switch (load_hdr->region.regc_usage_type) switch (load_hdr->region.regc_usage_type)
{ {
case REG_TEXT_T: region = ", .text"; break; case REG_TEXT_T: region = ", .text"; break;
...@@ -3710,7 +3580,7 @@ bad_header (status) ...@@ -3710,7 +3580,7 @@ bad_header (status)
static struct file_info * static struct file_info *
read_file (name, fd, rw) read_file (name, fd, rw)
char *name; /* filename */ const char *name; /* filename */
int fd; /* file descriptor */ int fd; /* file descriptor */
int rw; /* read/write */ int rw; /* read/write */
{ {
......
...@@ -23,14 +23,29 @@ Boston, MA 02111-1307, USA. */ ...@@ -23,14 +23,29 @@ Boston, MA 02111-1307, USA. */
extern void do_tlink PARAMS ((char **, char **)); extern void do_tlink PARAMS ((char **, char **));
extern void collect_execute PARAMS ((char *, char **, char *)); extern void collect_execute PARAMS ((const char *, char **, const char *));
extern void collect_exit PARAMS ((int)) ATTRIBUTE_NORETURN; extern void collect_exit PARAMS ((int)) ATTRIBUTE_NORETURN;
extern int collect_wait PARAMS ((char *)); extern int collect_wait PARAMS ((const char *));
extern void dump_file PARAMS ((char *)); extern void dump_file PARAMS ((const char *));
extern int file_exists PARAMS ((char *)); extern int file_exists PARAMS ((const char *));
extern const char *ldout;
extern const char *c_file_name;
extern struct obstack temporary_obstack;
extern struct obstack permanent_obstack;
extern char *temporary_firstobj;
extern int vflag, debug;
extern void fancy_abort PARAMS ((void)) ATTRIBUTE_NORETURN;
extern void error PARAMS ((const char *, ...)) ATTRIBUTE_PRINTF_1;
extern void notice PARAMS ((const char *, ...)) ATTRIBUTE_PRINTF_1;
extern void fatal PARAMS ((const char *, ...))
ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN;
extern void fatal_perror PARAMS ((const char *, ...))
ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN;
#endif /* ! __COLLECT2_H__ */ #endif /* ! __COLLECT2_H__ */
...@@ -25,7 +25,6 @@ Boston, MA 02111-1307, USA. */ ...@@ -25,7 +25,6 @@ Boston, MA 02111-1307, USA. */
#include "system.h" #include "system.h"
#include "hash.h" #include "hash.h"
#include "demangle.h" #include "demangle.h"
#include "toplev.h"
#include "collect2.h" #include "collect2.h"
#define MAX_ITERATIONS 17 #define MAX_ITERATIONS 17
...@@ -34,14 +33,6 @@ Boston, MA 02111-1307, USA. */ ...@@ -34,14 +33,6 @@ Boston, MA 02111-1307, USA. */
#define obstack_chunk_alloc xmalloc #define obstack_chunk_alloc xmalloc
#define obstack_chunk_free free #define obstack_chunk_free free
/* Defined in collect2.c. */
extern int vflag, debug;
extern char *ldout;
extern char *c_file_name;
extern struct obstack temporary_obstack;
extern struct obstack permanent_obstack;
extern char * temporary_firstobj;
/* Defined in the automatically-generated underscore.c. */ /* Defined in the automatically-generated underscore.c. */
extern int prepends_underscore; extern int prepends_underscore;
...@@ -95,8 +86,8 @@ static symbol * symbol_pop PARAMS ((void)); ...@@ -95,8 +86,8 @@ static symbol * symbol_pop PARAMS ((void));
static void file_push PARAMS ((file *)); static void file_push PARAMS ((file *));
static file * file_pop PARAMS ((void)); static file * file_pop PARAMS ((void));
static void tlink_init PARAMS ((void)); static void tlink_init PARAMS ((void));
static int tlink_execute PARAMS ((char *, char **, char *)); static int tlink_execute PARAMS ((const char *, char **, const char *));
static char * frob_extension PARAMS ((char *, const char *)); static char * frob_extension PARAMS ((const char *, const char *));
static char * obstack_fgets PARAMS ((FILE *, struct obstack *)); static char * obstack_fgets PARAMS ((FILE *, struct obstack *));
static char * tfgets PARAMS ((FILE *)); static char * tfgets PARAMS ((FILE *));
static char * pfgets PARAMS ((FILE *)); static char * pfgets PARAMS ((FILE *));
...@@ -115,7 +106,7 @@ static struct hash_entry * ...@@ -115,7 +106,7 @@ static struct hash_entry *
symbol_hash_newfunc (entry, table, string) symbol_hash_newfunc (entry, table, string)
struct hash_entry *entry; struct hash_entry *entry;
struct hash_table *table; struct hash_table *table;
hash_table_key string; hash_table_key string ATTRIBUTE_UNUSED;
{ {
struct symbol_hash_entry *ret = (struct symbol_hash_entry *) entry; struct symbol_hash_entry *ret = (struct symbol_hash_entry *) entry;
if (ret == NULL) if (ret == NULL)
...@@ -140,7 +131,7 @@ symbol_hash_lookup (string, create) ...@@ -140,7 +131,7 @@ symbol_hash_lookup (string, create)
boolean create; boolean create;
{ {
return ((struct symbol_hash_entry *) return ((struct symbol_hash_entry *)
hash_lookup (&symbol_table, (hash_table_key) string, hash_lookup (&symbol_table, (const hash_table_key) string,
create, string_copy)); create, string_copy));
} }
...@@ -153,7 +144,7 @@ static struct hash_entry * ...@@ -153,7 +144,7 @@ static struct hash_entry *
file_hash_newfunc (entry, table, string) file_hash_newfunc (entry, table, string)
struct hash_entry *entry; struct hash_entry *entry;
struct hash_table *table; struct hash_table *table;
hash_table_key string; hash_table_key string ATTRIBUTE_UNUSED;
{ {
struct file_hash_entry *ret = (struct file_hash_entry *) entry; struct file_hash_entry *ret = (struct file_hash_entry *) entry;
if (ret == NULL) if (ret == NULL)
...@@ -177,7 +168,7 @@ file_hash_lookup (string) ...@@ -177,7 +168,7 @@ file_hash_lookup (string)
const char *string; const char *string;
{ {
return ((struct file_hash_entry *) return ((struct file_hash_entry *)
hash_lookup (&file_table, (hash_table_key) string, true, hash_lookup (&file_table, (const hash_table_key) string, true,
string_copy)); string_copy));
} }
...@@ -190,7 +181,7 @@ static struct hash_entry * ...@@ -190,7 +181,7 @@ static struct hash_entry *
demangled_hash_newfunc (entry, table, string) demangled_hash_newfunc (entry, table, string)
struct hash_entry *entry; struct hash_entry *entry;
struct hash_table *table; struct hash_table *table;
hash_table_key string; hash_table_key string ATTRIBUTE_UNUSED;
{ {
struct demangled_hash_entry *ret = (struct demangled_hash_entry *) entry; struct demangled_hash_entry *ret = (struct demangled_hash_entry *) entry;
if (ret == NULL) if (ret == NULL)
...@@ -212,7 +203,7 @@ demangled_hash_lookup (string, create) ...@@ -212,7 +203,7 @@ demangled_hash_lookup (string, create)
boolean create; boolean create;
{ {
return ((struct demangled_hash_entry *) return ((struct demangled_hash_entry *)
hash_lookup (&demangled_table, (hash_table_key) string, hash_lookup (&demangled_table, (const hash_table_key) string,
create, string_copy)); create, string_copy));
} }
...@@ -296,7 +287,7 @@ file_pop () ...@@ -296,7 +287,7 @@ file_pop ()
static void static void
tlink_init () tlink_init ()
{ {
char *p; const char *p;
hash_table_init (&symbol_table, symbol_hash_newfunc, string_hash, hash_table_init (&symbol_table, symbol_hash_newfunc, string_hash,
string_compare); string_compare);
...@@ -322,9 +313,9 @@ tlink_init () ...@@ -322,9 +313,9 @@ tlink_init ()
static int static int
tlink_execute (prog, argv, redir) tlink_execute (prog, argv, redir)
char *prog; const char *prog;
char **argv; char **argv;
char *redir; const char *redir;
{ {
collect_execute (prog, argv, redir); collect_execute (prog, argv, redir);
return collect_wait (prog); return collect_wait (prog);
...@@ -332,10 +323,10 @@ tlink_execute (prog, argv, redir) ...@@ -332,10 +323,10 @@ tlink_execute (prog, argv, redir)
static char * static char *
frob_extension (s, ext) frob_extension (s, ext)
char *s; const char *s;
const char *ext; const char *ext;
{ {
char *p = rindex (s, '/'); const char *p = rindex (s, '/');
if (! p) if (! p)
p = s; p = s;
p = rindex (p, '.'); p = rindex (p, '.');
...@@ -391,7 +382,7 @@ freadsym (stream, f, chosen) ...@@ -391,7 +382,7 @@ freadsym (stream, f, chosen)
symbol *sym; symbol *sym;
{ {
char *name = tfgets (stream); const char *name = tfgets (stream);
sym = symbol_hash_lookup (name, true); sym = symbol_hash_lookup (name, true);
} }
...@@ -507,7 +498,7 @@ recompile_files () ...@@ -507,7 +498,7 @@ recompile_files ()
{ {
char *line, *command; char *line, *command;
FILE *stream = fopen ((char*) f->root.key, "r"); FILE *stream = fopen ((char*) f->root.key, "r");
char *outname = frob_extension ((char*) f->root.key, ".rnw"); const char *outname = frob_extension ((char*) f->root.key, ".rnw");
FILE *output = fopen (outname, "w"); FILE *output = fopen (outname, "w");
while ((line = tfgets (stream)) != NULL) while ((line = tfgets (stream)) != NULL)
...@@ -559,7 +550,7 @@ read_repo_files (object_lst) ...@@ -559,7 +550,7 @@ read_repo_files (object_lst)
for (; *object; object++) for (; *object; object++)
{ {
char *p = frob_extension (*object, ".rpo"); const char *p = frob_extension (*object, ".rpo");
file *f; file *f;
if (! file_exists (p)) if (! file_exists (p))
...@@ -586,7 +577,7 @@ demangle_new_symbols () ...@@ -586,7 +577,7 @@ demangle_new_symbols ()
while ((sym = symbol_pop ()) != NULL) while ((sym = symbol_pop ()) != NULL)
{ {
demangled *dem; demangled *dem;
char *p = cplus_demangle ((char*) sym->root.key, const char *p = cplus_demangle ((char*) sym->root.key,
DMGL_PARAMS | DMGL_ANSI); DMGL_PARAMS | DMGL_ANSI);
if (! p) if (! p)
...@@ -635,7 +626,7 @@ scan_linker_output (fname) ...@@ -635,7 +626,7 @@ scan_linker_output (fname)
if (! sym && ! end) if (! sym && ! end)
/* Try a mangled name in quotes. */ /* Try a mangled name in quotes. */
{ {
char *oldq = q+1; const char *oldq = q+1;
demangled *dem = 0; demangled *dem = 0;
q = 0; q = 0;
...@@ -694,7 +685,7 @@ scan_linker_output (fname) ...@@ -694,7 +685,7 @@ scan_linker_output (fname)
void void
do_tlink (ld_argv, object_lst) do_tlink (ld_argv, object_lst)
char **ld_argv, **object_lst; char **ld_argv, **object_lst ATTRIBUTE_UNUSED;
{ {
int exit = tlink_execute ("ld", ld_argv, ldout); int exit = tlink_execute ("ld", ld_argv, ldout);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment