From a6ee20cdc13307b003c1608f92ad81c8b69bbafb Mon Sep 17 00:00:00 2001 From: Olaf Seibert Date: Sun, 10 May 2015 17:36:58 +0200 Subject: [PATCH] Don't truncate the internal form of local symbols Local symbols like 32768$ (and such long ones can be generated automatically by macros) are suffixed with the "local symbol block number" to make different labels in different local symbol blocks: 32768$12345. However, this becomes longer than the regular symbol length (6). So, to avoid changing these labels, they are not truncated at this length. The listing code is updated to deal with the longest symbol name lengt it encounters in the symbol table. --- symbols.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/symbols.c b/symbols.c index 97c832c..2a3cb46 100644 --- a/symbols.c +++ b/symbols.c @@ -190,9 +190,15 @@ SYMBOL *add_sym( SYMBOL *sym; char label[SYMMAX_MAX + 1]; // big size - //JH: truncate symbol to SYMMAX - strncpy(label, labelraw, symbol_len); - label[symbol_len] = 0; + if (isdigit(labelraw[0])) { + // Don't truncate local labels + strncpy(label, labelraw, SYMMAX_MAX); + label[SYMMAX_MAX] = 0; + } else { + //JH: truncate symbol to SYMMAX + strncpy(label, labelraw, symbol_len); + label[symbol_len] = 0; + } sym = lookup_sym(label, table); if (sym != NULL) { @@ -495,6 +501,7 @@ void list_symbol_table( SYMBOL_ITER iter; SYMBOL *sym; int skip_locals = 0; + int longest_symbol = symbol_len; fprintf(lstfile,"\n\nSymbol table\n\n"); @@ -505,6 +512,10 @@ void list_symbol_table( continue; } nsyms++; + int len = strlen(sym->label); + if (len > longest_symbol) { + longest_symbol = len; + } } /* Sort them by name */ @@ -523,9 +534,8 @@ void list_symbol_table( symbolp = symbols; /* Print the listing in NCOLS columns. */ -#define NCOLS 5 - - int nlines = (nsyms + NCOLS - 1) / NCOLS; + int ncols = (132 / (longest_symbol + 18)); + int nlines = (nsyms + ncols - 1) / ncols; int line; /* * DIRER$ 004562RGX 006 @@ -544,12 +554,12 @@ void list_symbol_table( for (i = line; i < nsyms; i += nlines) { sym = symbols[i]; - fprintf(lstfile,"%-6s", sym->label); + fprintf(lstfile,"%-*s", longest_symbol, sym->label); fprintf(lstfile,"%c", (sym->section->flags & PSECT_REL) ? ' ' : '='); if (!(sym->flags & SYMBOLFLAG_DEFINITION)) { - fprintf(lstfile," ******"); + fprintf(lstfile,"******"); } else { - fprintf(lstfile," %06o", sym->value & 0177777); + fprintf(lstfile,"%06o", sym->value & 0177777); } fprintf(lstfile,"%c", (sym->section->flags & PSECT_REL) ? 'R' : ' '); fprintf(lstfile,"%c", (sym->flags & SYMBOLFLAG_GLOBAL) ? 'G' : ' ');