.Sanitize: added relax.c

ldsym.c ldlang.* more map stuff
This commit is contained in:
Steve Chamberlain
1992-01-24 22:36:06 +00:00
parent 2e2bf962db
commit 6fd50a2010
3 changed files with 91 additions and 86 deletions

View File

@ -30,6 +30,7 @@ README
i386aout.c i386aout.c
i386aout.sc i386aout.sc
ChangeLog ChangeLog
relax.c
Makefile.in Makefile.in
config config
config.h config.h
@ -91,7 +92,11 @@ echo Done in `pwd`.
# #
# #
# $Log$ # $Log$
# Revision 1.25 1991/12/12 03:42:08 sac # Revision 1.26 1992/01/24 22:35:55 sac
# .Sanitize: added relax.c
# ldsym.c ldlang.* more map stuff
#
# Revision 1.25 1991/12/12 03:42:08 sac
# New dos files # New dos files
# #
# Revision 1.24 1991/12/08 01:27:59 sac # Revision 1.24 1991/12/08 01:27:59 sac

View File

@ -112,19 +112,19 @@ static void
DEFUN(print_size,(value), DEFUN(print_size,(value),
size_t value) size_t value)
{ {
printf("%5x", (unsigned)value); fprintf(config.map_file, "%5x", (unsigned)value);
} }
static void static void
DEFUN(print_alignment,(value), DEFUN(print_alignment,(value),
unsigned int value) unsigned int value)
{ {
printf("2**%1u",value); fprintf(config.map_file, "2**%1u",value);
} }
static void static void
DEFUN(print_fill,(value), DEFUN(print_fill,(value),
fill_type value) fill_type value)
{ {
printf("%04x",(unsigned)value); fprintf(config.map_file, "%04x",(unsigned)value);
} }
@ -132,7 +132,7 @@ static void
DEFUN(print_section,(name), DEFUN(print_section,(name),
CONST char *CONST name) CONST char *CONST name)
{ {
printf("%*s", -longest_section_name, name); fprintf(config.map_file, "%*s", -longest_section_name, name);
} }
/*---------------------------------------------------------------------- /*----------------------------------------------------------------------
@ -443,46 +443,44 @@ DEFUN(lang_output_section_statement_lookup,(name),
static void static void
DEFUN(print_flags, (outfile, ignore_flags), DEFUN(print_flags, ( ignore_flags),
FILE *outfile AND
int *ignore_flags) int *ignore_flags)
{ {
fprintf(outfile,"("); fprintf(config.map_file, "(");
#if 0 #if 0
if (flags->flag_read) fprintf(outfile,"R"); if (flags->flag_read) fprintf(outfile,"R");
if (flags->flag_write) fprintf(outfile,"W"); if (flags->flag_write) fprintf(outfile,"W");
if (flags->flag_executable) fprintf(outfile,"X"); if (flags->flag_executable) fprintf(outfile,"X");
if (flags->flag_loadable) fprintf(outfile,"L"); if (flags->flag_loadable) fprintf(outfile,"L");
#endif #endif
fprintf(outfile,")"); fprintf(config.map_file, ")");
} }
void void
DEFUN(lang_map,(outfile), DEFUN_VOID(lang_map)
FILE *outfile)
{ {
lang_memory_region_type *m; lang_memory_region_type *m;
fprintf(outfile,"**MEMORY CONFIGURATION**\n\n"); fprintf(config.map_file,"**MEMORY CONFIGURATION**\n\n");
#ifdef HOST_64_BIT #ifdef HOST_64_BIT
fprintf(outfile,"name\t\torigin\t\tlength\t\tattributes\n"); fprintf(config.map_file,"name\t\torigin\t\tlength\t\tattributes\n");
#else #else
fprintf(outfile,"name\t\torigin length\t\tattributes\n"); fprintf(config.map_file,"name\t\torigin length\t\tattributes\n");
#endif #endif
for (m = lang_memory_region_list; for (m = lang_memory_region_list;
m != (lang_memory_region_type *)NULL; m != (lang_memory_region_type *)NULL;
m = m->next) m = m->next)
{ {
fprintf(outfile,"%-16s", m->name); fprintf(config.map_file,"%-16s", m->name);
print_address(m->origin); print_address(m->origin);
print_space(); print_space();
print_address(m->length); print_address(m->length);
print_space(); print_space();
print_flags(outfile, &m->flags); print_flags( &m->flags);
fprintf(outfile,"\n"); fprintf(config.map_file,"\n");
} }
fprintf(outfile,"\n\n**LINK EDITOR MEMORY MAP**\n\n"); fprintf(config.map_file,"\n\n**LINK EDITOR MEMORY MAP**\n\n");
fprintf(outfile,"output input virtual\n"); fprintf(config.map_file,"output input virtual\n");
fprintf(outfile,"section section address tsize\n\n"); fprintf(config.map_file,"section section address tsize\n\n");
print_statements(); print_statements();
@ -941,21 +939,21 @@ DEFUN(print_output_section_statement,(output_section_statement),
print_alignment(section->alignment_power); print_alignment(section->alignment_power);
print_space(); print_space();
#if 0 #if 0
printf("%s flags", output_section_statement->region->name); fprintf(config.map_file, "%s flags", output_section_statement->region->name);
print_flags(stdout, &output_section_statement->flags); print_flags(stdout, &output_section_statement->flags);
#endif #endif
if (section->flags & SEC_LOAD) if (section->flags & SEC_LOAD)
printf("load "); fprintf(config.map_file, "load ");
if (section->flags & SEC_ALLOC) if (section->flags & SEC_ALLOC)
printf("alloc "); fprintf(config.map_file, "alloc ");
if (section->flags & SEC_RELOC) if (section->flags & SEC_RELOC)
printf("reloc "); fprintf(config.map_file, "reloc ");
if (section->flags & SEC_HAS_CONTENTS) if (section->flags & SEC_HAS_CONTENTS)
printf("contents "); fprintf(config.map_file, "contents ");
} }
else { else {
printf("No attached output section"); fprintf(config.map_file, "No attached output section");
} }
print_nl(); print_nl();
print_statement(output_section_statement->children.head, print_statement(output_section_statement->children.head,
@ -986,11 +984,11 @@ DEFUN(print_assignment,(assignment, output_section),
} }
else else
{ {
printf("*undefined*"); fprintf(config.map_file, "*undefined*");
} }
print_space(); print_space();
exp_print_tree(stdout, assignment->exp); exp_print_tree(assignment->exp);
printf("\n"); fprintf(config.map_file, "\n");
} }
static void static void
@ -998,7 +996,7 @@ DEFUN(print_input_statement,(statm),
lang_input_statement_type *statm) lang_input_statement_type *statm)
{ {
if (statm->filename != (char *)NULL) { if (statm->filename != (char *)NULL) {
printf("LOAD %s\n",statm->filename); fprintf(config.map_file, "LOAD %s\n",statm->filename);
} }
} }
@ -1007,11 +1005,11 @@ DEFUN(print_symbol,(q),
asymbol *q) asymbol *q)
{ {
print_section(""); print_section("");
printf(" "); fprintf(config.map_file, " ");
print_section(""); print_section("");
printf(" "); fprintf(config.map_file, " ");
print_address(outside_symbol_address(q)); print_address(outside_symbol_address(q));
printf(" %s", q->name ? q->name : " "); fprintf(config.map_file, " %s", q->name ? q->name : " ");
print_nl(); print_nl();
} }
@ -1027,32 +1025,32 @@ DEFUN(print_input_section,(in),
if(size != 0) { if(size != 0) {
print_section(""); print_section("");
printf(" "); fprintf(config.map_file, " ");
print_section(i->name); print_section(i->name);
printf(" "); fprintf(config.map_file, " ");
if (i->output_section) { if (i->output_section) {
print_address(i->output_section->vma + i->output_offset); print_address(i->output_section->vma + i->output_offset);
printf(" "); fprintf(config.map_file, " ");
print_size(size); print_size(size);
printf(" "); fprintf(config.map_file, " ");
print_alignment(i->alignment_power); print_alignment(i->alignment_power);
printf(" "); fprintf(config.map_file, " ");
if (in->ifile) { if (in->ifile) {
bfd *abfd = in->ifile->the_bfd; bfd *abfd = in->ifile->the_bfd;
if (in->ifile->just_syms_flag == true) { if (in->ifile->just_syms_flag == true) {
printf("symbols only "); fprintf(config.map_file, "symbols only ");
} }
printf(" %s ",abfd->xvec->name); fprintf(config.map_file, " %s ",abfd->xvec->name);
if(abfd->my_archive != (bfd *)NULL) { if(abfd->my_archive != (bfd *)NULL) {
printf("[%s]%s", abfd->my_archive->filename, fprintf(config.map_file, "[%s]%s", abfd->my_archive->filename,
abfd->filename); abfd->filename);
} }
else { else {
printf("%s", abfd->filename); fprintf(config.map_file, "%s", abfd->filename);
} }
printf("(overhead %d bytes)", (int)bfd_alloc_size(abfd)); fprintf(config.map_file, "(overhead %d bytes)", (int)bfd_alloc_size(abfd));
print_nl(); print_nl();
/* Find all the symbols in this file defined in this section */ /* Find all the symbols in this file defined in this section */
@ -1075,7 +1073,7 @@ DEFUN(print_input_section,(in),
print_dot = outside_section_address(i) + size; print_dot = outside_section_address(i) + size;
} }
else { else {
printf("No output section allocated\n"); fprintf(config.map_file, "No output section allocated\n");
} }
} }
} }
@ -1084,7 +1082,7 @@ static void
DEFUN(print_fill_statement,(fill), DEFUN(print_fill_statement,(fill),
lang_fill_statement_type *fill) lang_fill_statement_type *fill)
{ {
printf("FILL mask "); fprintf(config.map_file, "FILL mask ");
print_fill( fill->fill); print_fill( fill->fill);
} }
@ -1105,22 +1103,22 @@ DEFUN(print_data_statement,(data),
print_space(); print_space();
switch (data->type) { switch (data->type) {
case BYTE : case BYTE :
printf("BYTE "); fprintf(config.map_file, "BYTE ");
print_dot += BYTE_SIZE; print_dot += BYTE_SIZE;
break; break;
case SHORT: case SHORT:
printf("SHORT "); fprintf(config.map_file, "SHORT ");
print_dot += SHORT_SIZE; print_dot += SHORT_SIZE;
break; break;
case LONG: case LONG:
printf("LONG "); fprintf(config.map_file, "LONG ");
print_dot += LONG_SIZE; print_dot += LONG_SIZE;
break; break;
} }
exp_print_tree(stdout, data->exp); exp_print_tree(data->exp);
printf("\n"); fprintf(config.map_file, "\n");
} }
@ -1145,18 +1143,18 @@ DEFUN(print_wild_statement,(w,os),
lang_wild_statement_type *w AND lang_wild_statement_type *w AND
lang_output_section_statement_type *os) lang_output_section_statement_type *os)
{ {
printf(" from "); fprintf(config.map_file, " from ");
if (w->filename != (char *)NULL) { if (w->filename != (char *)NULL) {
printf("%s",w->filename); fprintf(config.map_file, "%s",w->filename);
} }
else { else {
printf("*"); fprintf(config.map_file, "*");
} }
if (w->section_name != (char *)NULL) { if (w->section_name != (char *)NULL) {
printf("(%s)",w->section_name); fprintf(config.map_file, "(%s)",w->section_name);
} }
else { else {
printf("(*)"); fprintf(config.map_file, "(*)");
} }
print_nl(); print_nl();
print_statement(w->children.head, os); print_statement(w->children.head, os);
@ -1172,22 +1170,22 @@ DEFUN(print_statement,(s, os),
switch (s->header.type) switch (s->header.type)
{ {
case lang_constructors_statement_enum: case lang_constructors_statement_enum:
printf("constructors:\n"); fprintf(config.map_file, "constructors:\n");
print_statement(constructor_list.head, os); print_statement(constructor_list.head, os);
break; break;
case lang_wild_statement_enum: case lang_wild_statement_enum:
print_wild_statement(&s->wild_statement, os); print_wild_statement(&s->wild_statement, os);
break; break;
default: default:
printf("Fail with %d\n",s->header.type); fprintf(config.map_file, "Fail with %d\n",s->header.type);
FAIL(); FAIL();
break; break;
case lang_address_statement_enum: case lang_address_statement_enum:
printf("address\n"); fprintf(config.map_file, "address\n");
break; break;
break; break;
case lang_object_symbols_statement_enum: case lang_object_symbols_statement_enum:
printf("object symbols\n"); fprintf(config.map_file, "object symbols\n");
break; break;
case lang_fill_statement_enum: case lang_fill_statement_enum:
print_fill_statement(&s->fill_statement); print_fill_statement(&s->fill_statement);
@ -1209,10 +1207,10 @@ DEFUN(print_statement,(s, os),
os); os);
break; break;
case lang_target_statement_enum: case lang_target_statement_enum:
printf("TARGET(%s)\n", s->target_statement.target); fprintf(config.map_file, "TARGET(%s)\n", s->target_statement.target);
break; break;
case lang_output_statement_enum: case lang_output_statement_enum:
printf("OUTPUT(%s %s)\n", fprintf(config.map_file, "OUTPUT(%s %s)\n",
s->output_statement.name, s->output_statement.name,
output_target); output_target);
break; break;
@ -2005,7 +2003,7 @@ DEFUN_VOID(lang_common)
if (write_map) if (write_map)
{ {
printf ("Allocating common %s: %x at %x %s\n", fprintf (config.map_file, "Allocating common %s: %x at %x %s\n",
lgs->name, lgs->name,
(unsigned) size, (unsigned) size,
(unsigned) com->value, (unsigned) com->value,

View File

@ -70,6 +70,8 @@ extern discard_locals_type discard_locals;
ldsym_type *symbol_head = (ldsym_type *)NULL; ldsym_type *symbol_head = (ldsym_type *)NULL;
ldsym_type **symbol_tail_ptr = &symbol_head; ldsym_type **symbol_tail_ptr = &symbol_head;
extern ld_config_type config;
/* /*
incremented for each symbol in the ldsym_type table incremented for each symbol in the ldsym_type table
no matter what flavour it is no matter what flavour it is
@ -192,9 +194,9 @@ list_file_locals (entry)
lang_input_statement_type *entry; lang_input_statement_type *entry;
{ {
asymbol **q; asymbol **q;
printf ( "\nLocal symbols of "); fprintf (config.map_file, "\nLocal symbols of ");
info("%I", entry); minfo("%I", entry);
printf (":\n\n"); fprintf (config.map_file, ":\n\n");
if (entry->asymbols) { if (entry->asymbols) {
for (q = entry->asymbols; *q; q++) for (q = entry->asymbols; *q; q++)
{ {
@ -209,13 +211,13 @@ lang_input_statement_type *entry;
static void static void
print_file_stuff(f) DEFUN(print_file_stuff,(f),
lang_input_statement_type *f; lang_input_statement_type *f)
{ {
fprintf (stdout, " %s\n", f->filename); fprintf (config.map_file," %s\n", f->filename);
if (f->just_syms_flag) if (f->just_syms_flag)
{ {
fprintf (stdout, " symbols only\n"); fprintf (config.map_file, " symbols only\n");
} }
else else
{ {
@ -227,14 +229,14 @@ lang_input_statement_type *f;
print_address(s->output_offset); print_address(s->output_offset);
if (s->flags & SEC_HAS_CONTENTS) if (s->flags & SEC_HAS_CONTENTS)
{ {
printf (" %08x 2**%2ud %s\n", fprintf (config.map_file, " %08x 2**%2ud %s\n",
(unsigned)bfd_get_section_size_after_reloc(s), (unsigned)bfd_get_section_size_after_reloc(s),
s->alignment_power, s->name); s->alignment_power, s->name);
} }
else else
{ {
printf (" %08x 2**%2ud %s\n", fprintf (config.map_file, " %08x 2**%2ud %s\n",
(unsigned)bfd_get_section_size_before_reloc(s), (unsigned)bfd_get_section_size_before_reloc(s),
s->alignment_power, s->name); s->alignment_power, s->name);
} }
@ -247,32 +249,32 @@ lang_input_statement_type *f;
for (s = f->the_bfd->sections; for (s = f->the_bfd->sections;
s != (asection *)NULL; s != (asection *)NULL;
s = s->next) { s = s->next) {
printf("%s ", s->name); fprintf(config.map_file, "%s ", s->name);
print_address(s->output_offset); print_address(s->output_offset);
printf("(%x)", (unsigned)bfd_get_section_size_after_reloc(s)); fprintf(config.map_file, "(%x)", (unsigned)bfd_get_section_size_after_reloc(s));
} }
printf("hex \n"); fprintf(config.map_file, "hex \n");
} }
} }
fprintf (stdout, "\n"); fprintf (config.map_file, "\n");
} }
void void
ldsym_print_symbol_table () ldsym_print_symbol_table ()
{ {
fprintf (stdout, "**FILES**\n\n"); fprintf (config.map_file, "**FILES**\n\n");
lang_for_each_file(print_file_stuff); lang_for_each_file(print_file_stuff);
fprintf(stdout, "**GLOBAL SYMBOLS**\n\n"); fprintf(config.map_file, "**GLOBAL SYMBOLS**\n\n");
fprintf(stdout, "offset section offset symbol\n"); fprintf(config.map_file, "offset section offset symbol\n");
{ {
register ldsym_type *sp; register ldsym_type *sp;
for (sp = symbol_head; sp; sp = sp->next) for (sp = symbol_head; sp; sp = sp->next)
{ {
if (sp->flags & SYM_INDIRECT) { if (sp->flags & SYM_INDIRECT) {
fprintf(stdout,"indirect %s to %s\n", fprintf(config.map_file,"indirect %s to %s\n",
sp->name, (((ldsym_type *)(sp->sdefs_chain))->name)); sp->name, (((ldsym_type *)(sp->sdefs_chain))->name));
} }
else { else {
@ -283,7 +285,7 @@ ldsym_print_symbol_table ()
print_address(defsym->value); print_address(defsym->value);
if (defsec) if (defsec)
{ {
printf(" %-10s", fprintf(config.map_file, " %-10s",
bfd_section_name(output_bfd, bfd_section_name(output_bfd,
defsec)); defsec));
print_space(); print_space();
@ -292,23 +294,23 @@ ldsym_print_symbol_table ()
} }
else else
{ {
printf(" ......."); fprintf(config.map_file, " .......");
} }
} }
if (sp->scoms_chain) { if (sp->scoms_chain) {
printf("common "); fprintf(config.map_file, "common ");
print_address((*(sp->scoms_chain))->value); print_address((*(sp->scoms_chain))->value);
printf(" %s ",sp->name); fprintf(config.map_file, " %s ",sp->name);
} }
else if (sp->sdefs_chain) { else if (sp->sdefs_chain) {
printf(" %s ",sp->name); fprintf(config.map_file, " %s ",sp->name);
} }
else { else {
printf("undefined "); fprintf(config.map_file, "undefined ");
printf("%s ",sp->name); fprintf(config.map_file, "%s ",sp->name);
} }
} }