* ldmisc.c (vfinfo): For `%I', if the file is in an archive, print

the archive filename too.
This commit is contained in:
David MacKenzie
1994-01-28 21:20:11 +00:00
parent ddd0223e94
commit 288897f490
2 changed files with 89 additions and 80 deletions

View File

@ -1,5 +1,8 @@
Fri Jan 28 09:12:56 1994 David J. Mackenzie (djm@thepub.cygnus.com) Fri Jan 28 09:12:56 1994 David J. Mackenzie (djm@thepub.cygnus.com)
* ldmisc.c (vfinfo): For `%I', if the file is in an archive, print
the archive filename too.
* ldlex.l: Add rule to catch invalid input characters instead of * ldlex.l: Add rule to catch invalid input characters instead of
printing them. Include "ldmain.h" for program_name decl. printing them. Include "ldmain.h" for program_name decl.
(lex_warn_invalid): New function. (lex_warn_invalid): New function.

View File

@ -1,5 +1,5 @@
/* ldmisc.c /* ldmisc.c
Copyright (C) 1991 Free Software Foundation, Inc. Copyright (C) 1991, 1993 Free Software Foundation, Inc.
Written by Steve Chamberlain of Cygnus Support. Written by Steve Chamberlain of Cygnus Support.
@ -29,12 +29,13 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "ldexp.h" #include "ldexp.h"
#include "ldlang.h" #include "ldlang.h"
#include "ldlex.h" #include "ldlex.h"
#include "ldsym.h"
#include "ldmain.h" #include "ldmain.h"
#include "ldfile.h" #include "ldfile.h"
/* VARARGS*/ /* VARARGS*/
static void finfo (); static void finfo ();
static const char *demangle PARAMS ((const char *string,
int remove_underscore));
/* /*
%% literal % %% literal %
@ -44,7 +45,7 @@ static void finfo ();
%E current bfd error or errno %E current bfd error or errno
%I filename from a lang_input_statement_type %I filename from a lang_input_statement_type
%B filename from a bfd %B filename from a bfd
%T symbol table entry %T symbol name
%X no object output, fail return %X no object output, fail return
%V hex bfd_vma %V hex bfd_vma
%v hex bfd_vma, no leading zeros %v hex bfd_vma, no leading zeros
@ -54,22 +55,22 @@ static void finfo ();
%d integer, like printf %d integer, like printf
*/ */
static char * static const char *
demangle(string, remove_underscore) demangle (string, remove_underscore)
char *string; const char *string;
int remove_underscore; int remove_underscore;
{ {
char *res; const char *res;
if (remove_underscore && output_bfd) if (remove_underscore && output_bfd)
{ {
if (bfd_get_symbol_leading_char(output_bfd) == string[0]) if (bfd_get_symbol_leading_char (output_bfd) == string[0])
string++; string++;
} }
/* Note that there's a memory leak here, we keep buying memory /* Note that there's a memory leak here, we keep buying memory
for demangled names, and never free. But if you have so many for demangled names, and never free. But if you have so many
errors that you run out of VM with the error messages, then errors that you run out of VM with the error messages, then
there's something up */ there's something up */
res = cplus_demangle(string, DMGL_ANSI|DMGL_PARAMS); res = cplus_demangle (string, DMGL_ANSI|DMGL_PARAMS);
return res ? res : string; return res ? res : string;
} }
@ -132,27 +133,14 @@ vfinfo(fp, fmt, arg)
break; break;
case 'T': case 'T':
/* symbol table entry */ /* Symbol name. */
{ {
asymbol *symbol = va_arg(arg, asymbol *); const char *name = va_arg (arg, const char *);
if (symbol)
{ if (name != (const char *) NULL)
asection *section = symbol->section; fprintf (fp, "%s", demangle (name, 1));
char *cplusname = demangle(symbol->name, 1);
CONST char *section_name = section->name;
if (section != &bfd_und_section)
{
fprintf(fp,"%s (%s)", cplusname, section_name);
}
else else
{ fprintf (fp, "no symbol");
fprintf(fp,"%s", cplusname);
}
}
else
{
fprintf(fp,"no symbol");
}
} }
break; break;
@ -191,6 +179,8 @@ vfinfo(fp, fmt, arg)
lang_input_statement_type *i = lang_input_statement_type *i =
va_arg(arg,lang_input_statement_type *); va_arg(arg,lang_input_statement_type *);
if (i->the_bfd->my_archive)
fprintf(fp, "(%s)", i->the_bfd->my_archive->filename);
fprintf(fp,"%s", i->local_sym_name); fprintf(fp,"%s", i->local_sym_name);
} }
break; break;
@ -221,36 +211,52 @@ vfinfo(fp, fmt, arg)
case 'C': case 'C':
/* Clever filename:linenumber with function name if possible, /* Clever filename:linenumber with function name if possible,
or section name as a last resort */ or section name as a last resort. The arguments are a BFD,
a section, and an offset. */
{ {
CONST char *filename; bfd *abfd;
CONST char *functionname; asection *section;
char *cplus_name; bfd_vma offset;
lang_input_statement_type *entry;
asymbol **asymbols;
const char *filename;
const char *functionname;
unsigned int linenumber; unsigned int linenumber;
bfd *abfd = va_arg(arg, bfd *);
asection *section = va_arg(arg, asection *);
asymbol **symbols = va_arg(arg, asymbol **);
bfd_vma offset = va_arg(arg, bfd_vma);
if (bfd_find_nearest_line(abfd, abfd = va_arg (arg, bfd *);
section, section = va_arg (arg, asection *);
symbols, offset = va_arg (arg, bfd_vma);
offset,
&filename, entry = (lang_input_statement_type *) abfd->usrdata;
&functionname, if (entry != (lang_input_statement_type *) NULL
&linenumber)) && entry->asymbols != (asymbol **) NULL)
asymbols = entry->asymbols;
else
{ {
if (filename == (char *)NULL) unsigned int symsize;
filename = abfd->filename; unsigned int symbol_count;
if (functionname != (char *)NULL)
symsize = get_symtab_upper_bound (abfd);
asymbols = (asymbol **) ldmalloc (symsize);
symbol_count = bfd_canonicalize_symtab (abfd, asymbols);
if (entry != (lang_input_statement_type *) NULL)
{ {
cplus_name = demangle(functionname, 1); entry->asymbols = asymbols;
fprintf(fp,"%s:%u: %s", filename, linenumber, cplus_name); entry->symbol_count = symbol_count;
}
} }
if (bfd_find_nearest_line (abfd, section, asymbols, offset,
&filename, &functionname, &linenumber))
{
if (filename == (char *) NULL)
filename = abfd->filename;
if (functionname != (char *)NULL)
fprintf (fp, "%s:%u: %s", filename, linenumber,
demangle (functionname, 1));
else if (linenumber != 0) else if (linenumber != 0)
fprintf(fp,"%s:%u", filename, linenumber); fprintf (fp, "%s:%u", filename, linenumber);
else else
finfo (fp, "%s(%s+0x%v)", filename, section->name, offset); finfo (fp, "%s(%s+0x%v)", filename, section->name, offset);
@ -292,7 +298,7 @@ vfinfo(fp, fmt, arg)
hosed by LynxOS, which defines that name in its libc.) */ hosed by LynxOS, which defines that name in its libc.) */
void info_msg(va_alist) void info_msg(va_alist)
va_dcl va_dcl
{ {
char *fmt; char *fmt;
va_list arg; va_list arg;
@ -305,7 +311,7 @@ va_dcl
/* ('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 einfo(va_alist)
va_dcl va_dcl
{ {
char *fmt; char *fmt;
va_list arg; va_list arg;
@ -327,18 +333,18 @@ multiple_warn (message1, newsym, message2, oldsym)
char *message2; char *message2;
asymbol *oldsym; asymbol *oldsym;
{ {
lang_input_statement_type *stat; lang_input_statement_type *inp_stat;
asymbol **stat_symbols; asymbol **stat_symbols;
stat = (lang_input_statement_type *) bfd_asymbol_bfd (newsym)->usrdata; inp_stat = (lang_input_statement_type *) bfd_asymbol_bfd (newsym)->usrdata;
stat_symbols = stat ? stat->asymbols : 0; stat_symbols = inp_stat ? inp_stat->asymbols : 0;
einfo (message1, einfo (message1,
bfd_asymbol_bfd (newsym), newsym->section, stat_symbols, newsym->value, bfd_asymbol_bfd (newsym), newsym->section, stat_symbols, newsym->value,
demangle (newsym->name, 1)); demangle (newsym->name, 1));
stat = (lang_input_statement_type *) bfd_asymbol_bfd (oldsym)->usrdata; inp_stat = (lang_input_statement_type *) bfd_asymbol_bfd (oldsym)->usrdata;
stat_symbols = stat ? stat->asymbols : 0; stat_symbols = inp_stat ? inp_stat->asymbols : 0;
einfo (message2, einfo (message2,
bfd_asymbol_bfd (oldsym), oldsym->section, stat_symbols, oldsym->value); bfd_asymbol_bfd (oldsym), oldsym->section, stat_symbols, oldsym->value);
@ -394,7 +400,7 @@ PTR
xmalloc (size) xmalloc (size)
int size; int size;
{ {
return ldmalloc(size); return ldmalloc ((size_t) size);
} }
@ -414,9 +420,9 @@ ldrealloc (ptr, size)
PTR PTR
xrealloc (ptr, size) xrealloc (ptr, size)
PTR ptr; PTR ptr;
size_t size; int size;
{ {
return ldrealloc(ptr, size); return ldrealloc (ptr, (size_t) size);
} }
@ -434,7 +440,7 @@ buystring (x)
/* ('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 minfo(va_alist)
va_dcl va_dcl
{ {
char *fmt; char *fmt;
va_list arg; va_list arg;