+Fri Feb 4 16:26:08 1994 David J. Mackenzie (djm@thepub.cygnus.com)
+
+ * ldmisc.c (ldmalloc, xmalloc, ldrealloc, xrealloc): Functions
+ deleted; will use libiberty versions instead.
+ * ldctor.c ldfile.c ldlang.c ldmain.c ldmisc.c ldmisc.h lexsup.c
+ mri.c Makefile.in: Change callers.
+
+ * ldmisc.c (vfinfo): Remove cleanup code.
+ * ldmain.c (remove_output): Put it here (new function).
+ (preserve_output): New function.
+ (main): Register remove_output and preserve_output with atexit.
+ * ldmain.c ldgram.y: Call xexit instead of exit.
+ * ldmisc.h: Declare xexit.
+
Fri Feb 4 15:19:01 1994 Steve Chamberlain (sac@cygnus.com)
* Makefile.in: Lots of new H8/500 memory models.
/* Linker command language support.
- Copyright 1991, 1992, 1993 Free Software Foundation, Inc.
+ Copyright (C) 1991, 92, 93, 94 Free Software Foundation, Inc.
This file is part of GLD, the Gnu Linker.
/* LOCALS */
static struct obstack stat_obstack;
-#define obstack_chunk_alloc ldmalloc
+#define obstack_chunk_alloc xmalloc
#define obstack_chunk_free free
static CONST char *startup_file;
static lang_statement_list_type input_file_chain;
unsigned int symsize;
symsize = get_symtab_upper_bound (i->owner);
- is->ifile->asymbols = (asymbol **) ldmalloc (symsize);
+ is->ifile->asymbols = (asymbol **) xmalloc (symsize);
is->ifile->symbol_count =
bfd_canonicalize_symtab (i->owner, is->ifile->asymbols);
/* Main program of GNU linker.
- Copyright (C) 1991, 1993, 1994 Free Software Foundation, Inc.
+ Copyright (C) 1991, 92, 93, 94 Free Software Foundation, Inc.
Written by Steve Chamberlain steve@cygnus.com
This file is part of GLD, the Gnu Linker.
struct bfd_link_info link_info;
\f
-extern int main PARAMS ((int, char **));
+static void
+remove_output ()
+{
+ if (output_filename)
+ {
+ if (output_bfd && output_bfd->iostream)
+ fclose((FILE *)(output_bfd->iostream));
+ if (delete_output_file_on_failure)
+ unlink (output_filename);
+ }
+}
+
+/* Prevent remove_output from doing anything.
+ Called after a successful link. */
+
+static void
+preserve_output ()
+{
+ output_filename = NULL;
+}
int
main (argc, argv)
bfd_init ();
+ atexit (remove_output);
+
/* Initialize the data about options. */
trace_files = trace_file_tries = version_printed = false;
write_map = false;
{
/* sizeof counts the terminating NUL. */
size_t size = strlen (s) + sizeof ("-T ");
- char *buf = (char *) ldmalloc(size);
+ char *buf = (char *) xmalloc(size);
sprintf (buf, "-T %s", s);
parse_line (buf, 0);
free (buf);
if (lang_has_input_file == false)
{
if (version_printed)
- exit (0);
+ xexit (0);
einfo ("%P%F: no input files\n");
}
fclose ((FILE *) (output_bfd->iostream));
unlink (output_filename);
- exit (1);
+ xexit (1);
}
else
{
(long) (lim - (char *) &environ));
}
- exit (0);
+ atexit (preserve_output);
+ xexit (0);
return 0;
}
dirlen = strlen (dir);
/* sizeof counts the terminating NUL. */
- buf = (char *) ldmalloc (dirlen + sizeof("/ldscripts"));
+ buf = (char *) xmalloc (dirlen + sizeof("/ldscripts"));
sprintf (buf, "%s/ldscripts", dir);
res = stat (buf, &s) == 0 && S_ISDIR (s.st_mode);
dirlen = end - program_name;
/* Make a copy of program_name in dir.
Leave room for later "/../lib". */
- dir = (char *) ldmalloc (dirlen + 8);
+ dir = (char *) xmalloc (dirlen + 8);
strncpy (dir, program_name, dirlen);
dir[dirlen] = '\0';
}
else
{
dirlen = 1;
- dir = (char *) ldmalloc (dirlen + 8);
+ dir = (char *) xmalloc (dirlen + 8);
strcpy (dir, ".");
}
if (link_info.notice_hash == (struct bfd_hash_table *) NULL)
{
link_info.notice_hash = ((struct bfd_hash_table *)
- ldmalloc (sizeof (struct bfd_hash_table)));
+ xmalloc (sizeof (struct bfd_hash_table)));
if (! bfd_hash_table_init_n (link_info.notice_hash,
bfd_hash_newfunc,
61))
}
link_info.keep_hash = ((struct bfd_hash_table *)
- ldmalloc (sizeof (struct bfd_hash_table)));
+ xmalloc (sizeof (struct bfd_hash_table)));
if (! bfd_hash_table_init (link_info.keep_hash, bfd_hash_newfunc))
einfo ("%P%F: bfd_hash_table_init failed: %E\n");
bufsize = 100;
- buf = (char *) ldmalloc (bufsize);
+ buf = (char *) xmalloc (bufsize);
c = getc (file);
while (c != EOF)
if (len >= bufsize)
{
bufsize *= 2;
- buf = ldrealloc (buf, bufsize);
+ buf = xrealloc (buf, bufsize);
}
c = getc (file);
}
lang_input_statement_type *input;
input = ((lang_input_statement_type *)
- ldmalloc ((bfd_size_type) sizeof (lang_input_statement_type)));
+ xmalloc ((bfd_size_type) sizeof (lang_input_statement_type)));
input->filename = abfd->filename;
input->local_sym_name = abfd->filename;
input->the_bfd = abfd;