* ldmisc.c: Include <stdarg.h> rather than <varargs.h> if

ANSI_PROTOTYPES is defined.  Remove special handling of
	WINDOWS_NT.  Various indendation fixes.
	(vfinfo): Change fmt parameter to const char *.
	(info_msg): Write <stdarg.h> version.
	(einfo, minfo, finfo): Likewise.
	(info_assert): Change file parameter to const char *.
	* ldmisc.h (einfo, minfo, info_msg): If ANSI_PROTOTYPES is
	defined, use a real prototype.
	(info_assert): Change first parameter to be const char *.
This commit is contained in:
Ian Lance Taylor 1996-01-12 20:01:17 +00:00
parent 6ddc0baaf9
commit 23cb3b6504
3 changed files with 137 additions and 71 deletions

View File

@ -1,3 +1,16 @@
Fri Jan 12 14:56:19 1996 Ian Lance Taylor <ian@cygnus.com>
* ldmisc.c: Include <stdarg.h> rather than <varargs.h> if
ANSI_PROTOTYPES is defined. Remove special handling of
WINDOWS_NT. Various indendation fixes.
(vfinfo): Change fmt parameter to const char *.
(info_msg): Write <stdarg.h> version.
(einfo, minfo, finfo): Likewise.
(info_assert): Change file parameter to const char *.
* ldmisc.h (einfo, minfo, info_msg): If ANSI_PROTOTYPES is
defined, use a real prototype.
(info_assert): Change first parameter to be const char *.
Fri Jan 12 13:29:55 1996 Michael Meissner <meissner@tiktok.cygnus.com> Fri Jan 12 13:29:55 1996 Michael Meissner <meissner@tiktok.cygnus.com>
* scripttempl/elfppc.sc: Add support for .sdata2/.sbss2, etc. Add * scripttempl/elfppc.sc: Add support for .sdata2/.sbss2, etc. Add

View File

@ -22,16 +22,13 @@ the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307
#include "bfd.h" #include "bfd.h"
#include "sysdep.h" #include "sysdep.h"
#include <demangle.h> #include <demangle.h>
/* this collection of routines wants to use the Unix style varargs
use special abbreviated portion of varargs.h */ #ifdef ANSI_PROTOTYPES
#ifdef WINDOWS_NT #include <stdarg.h>
/* Since macro __STDC__ is defined, the compiler will raise and error if #define USE_STDARG 1
VARARGS.H from mstools\h is included. Since we only need a portion of
this header file, it has been incorporated into local header file
xvarargs.h */
#include "xvarargs.h"
#else #else
#include <varargs.h> #include <varargs.h>
#define USE_STDARG 0
#endif #endif
#include "ld.h" #include "ld.h"
@ -44,8 +41,12 @@ the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307
#include "ldfile.h" #include "ldfile.h"
#if USE_STDARG
static void finfo PARAMS ((FILE *, const char *, ...));
#else
/* VARARGS*/ /* VARARGS*/
static void finfo (); static void finfo ();
#endif
static const char *demangle PARAMS ((const char *string, static const char *demangle PARAMS ((const char *string,
int remove_underscore)); int remove_underscore));
@ -75,23 +76,28 @@ demangle (string, remove_underscore)
int remove_underscore; int remove_underscore;
{ {
const char *res; const char *res;
if (remove_underscore && output_bfd)
{ if (remove_underscore
if (bfd_get_symbol_leading_char (output_bfd) == string[0]) && output_bfd != NULL
string++; && bfd_get_symbol_leading_char (output_bfd) == string[0])
} ++string;
/* Note that there's a memory leak here, we keep buying memory
for demangled names, and never free. But if you have so many /* This is a hack for better error reporting on XCOFF. */
errors that you run out of VM with the error messages, then if (remove_underscore && string[0] == '.')
there's something up */ ++string;
res = cplus_demangle (string, DMGL_ANSI|DMGL_PARAMS);
/* Note that there's a memory leak here, we keep buying memory for
demangled names, and never free. But if you have so many errors
that you run out of VM with the error messages, then there's
something up. */
res = cplus_demangle (string, DMGL_ANSI | DMGL_PARAMS);
return res ? res : string; return res ? res : string;
} }
static void static void
vfinfo(fp, fmt, arg) vfinfo (fp, fmt, arg)
FILE *fp; FILE *fp;
char *fmt; const char *fmt;
va_list arg; va_list arg;
{ {
boolean fatal = false; boolean fatal = false;
@ -360,39 +366,63 @@ vfinfo(fp, fmt, arg)
/* Format info message and print on stdout. */ /* Format info message and print on stdout. */
/* (You would think this should be called just "info", but then you would /* (You would think this should be called just "info", but then you
hosed by LynxOS, which defines that name in its libc.) */ would hosed by LynxOS, which defines that name in its libc.) */
void info_msg(va_alist) void
#if USE_STDARG
info_msg (const char *fmt, ...)
#else
info_msg (va_alist)
va_dcl va_dcl
#endif
{ {
char *fmt;
va_list arg; va_list arg;
va_start(arg);
fmt = va_arg(arg, char *); #if ! USE_STDARG
vfinfo(stdout, fmt, arg); const char *fmt;
va_end(arg);
va_start (arg);
fmt = va_arg (arg, const char *);
#else
va_start (arg, fmt);
#endif
vfinfo (stdout, fmt, arg);
va_end (arg);
} }
/* ('e' for error.) Format info message and print on stderr. */ /* ('e' for error.) Format info message and print on stderr. */
void einfo(va_alist) void
#if USE_STDARG
einfo (const char *fmt, ...)
#else
einfo (va_alist)
va_dcl va_dcl
#endif
{ {
char *fmt;
va_list arg; va_list arg;
va_start(arg);
fmt = va_arg(arg, char *); #if ! USE_STDARG
vfinfo(stderr, fmt, arg); const char *fmt;
va_end(arg);
va_start (arg);
fmt = va_arg (arg, const char *);
#else
va_start (arg, fmt);
#endif
vfinfo (stderr, fmt, arg);
va_end (arg);
} }
void void
info_assert(file, line) info_assert (file, line)
char *file; const char *file;
unsigned int line; unsigned int line;
{ {
einfo("%F%P: internal error %s %d\n", file,line); einfo ("%F%P: internal error %s %d\n", file, line);
} }
char * char *
@ -405,54 +435,72 @@ buystring (x)
return r; return r;
} }
/* ('m' for map) Format info message and print on map. */ /* ('m' for map) Format info message and print on map. */
void minfo(va_alist) void
#if USE_STDARG
minfo (const char *fmt, ...)
#else
minfo (va_alist)
va_dcl va_dcl
#endif
{ {
char *fmt;
va_list arg; va_list arg;
va_start(arg);
fmt = va_arg(arg, char *);
vfinfo(config.map_file, fmt, arg);
va_end(arg);
}
#if ! USE_STDARG
static void const char *fmt;
finfo (va_alist)
va_dcl
{
char *fmt;
FILE *file;
va_list arg;
va_start (arg); va_start (arg);
file = va_arg (arg, FILE *); fmt = va_arg (arg, const char *);
fmt = va_arg (arg, char *); #else
vfinfo (file, fmt, arg); va_start (arg, fmt);
#endif
vfinfo (config.map_file, fmt, arg);
va_end (arg); va_end (arg);
} }
static void
#if USE_STDARG
finfo (FILE *file, const char *fmt, ...)
#else
finfo (va_alist)
va_dcl
#endif
{
va_list arg;
#if ! USE_STDARG
FILE *file;
const char *fmt;
/*---------------------------------------------------------------------- va_start (arg);
Functions to print the link map file = va_arg (arg, FILE *);
*/ fmt = va_arg (arg, const char *);
#else
va_start (arg, fmt);
#endif
vfinfo (file, fmt, arg);
va_end (arg);
}
/* Functions to print the link map. */
void void
print_space () print_space ()
{ {
fprintf(config.map_file, " "); fprintf (config.map_file, " ");
} }
void void
print_nl () print_nl ()
{ {
fprintf(config.map_file, "\n"); fprintf (config.map_file, "\n");
} }
void void
print_address (value) print_address (value)
bfd_vma value; bfd_vma value;
{ {
fprintf_vma(config.map_file, value); fprintf_vma (config.map_file, value);
} }

View File

@ -1,5 +1,5 @@
/* ldmisc.h - /* ldmisc.h -
Copyright 1991, 1992 Free Software Foundation, Inc. Copyright (C) 1991, 92, 93, 94 Free Software Foundation, Inc.
This file is part of GLD, the Gnu Linker. This file is part of GLD, the Gnu Linker.
@ -15,24 +15,29 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GLD; see the file COPYING. If not, write to along with GLD; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifndef LDMISC_H #ifndef LDMISC_H
#define LDMISC_H #define LDMISC_H
#ifdef ANSI_PROTOTYPES
extern void einfo PARAMS ((const char *, ...));
extern void minfo PARAMS ((const char *, ...));
extern void info_msg PARAMS ((const char *, ...));
#else
/* VARARGS*/ /* VARARGS*/
extern void einfo (); extern void einfo ();
/* VARARGS*/ /* VARARGS*/
extern void minfo (); extern void minfo ();
/* VARARGS*/ /* VARARGS*/
extern void info_msg (); extern void info_msg ();
extern void info_assert PARAMS ((char *, unsigned int)); #endif
extern void multiple_warn PARAMS ((char *message1, asymbol *sym,
char *message2, asymbol *sy)); extern void info_assert PARAMS ((const char *, unsigned int));
extern void yyerror PARAMS ((char *)); extern void yyerror PARAMS ((const char *));
extern char *concat PARAMS ((CONST char *, CONST char *, CONST char *)); extern PTR xmalloc PARAMS ((size_t));
extern PTR ldmalloc PARAMS ((size_t)); extern PTR xrealloc PARAMS ((PTR, size_t));
extern PTR ldrealloc PARAMS ((PTR, size_t)); extern void xexit PARAMS ((int));
extern char *buystring PARAMS ((CONST char *CONST)); extern char *buystring PARAMS ((CONST char *CONST));
#define ASSERT(x) \ #define ASSERT(x) \