There are two places where names are added to the global symbol table; one via

the -U command line option, and one via file scanning. Turns out only the
second would increment the number of global names, so adding names with -U
would cause names found via scanning to fall off the end of the list! This
wouldn't cause linker errors because fixups don't use the list, but would cause
the generated symbol table in the output to be incorrect.
This commit is contained in:
David Given 2018-03-11 12:37:23 +01:00
parent d5a9f1541a
commit 4cb4bdc85f
9 changed files with 25 additions and 14 deletions

View file

@ -17,6 +17,7 @@ static char rcsid[] = "$Id$";
#include "memory.h"
#include "orig.h"
#include "scan.h"
#include "sym.h"
static get_names();
static process();
@ -46,9 +47,6 @@ extract()
skip_modul(&head);
}
unsigned short NLocals = 0; /* Number of local names to be saved. */
unsigned short NGlobals = 0; /* Number of global names. */
/*
* Walk through the nametable of this module, counting the locals that must
* appear in the final output file if this module is linked.
@ -190,7 +188,6 @@ getexternal(name)
h = hash(string);
old = searchname(string, h);
if (old == (struct outname *)0) {
NGlobals++;
entername(name, h);
if (ISUNDEFINED(name)) {
verbose("requires %s", string, 0, 0, 0);

View file

@ -8,7 +8,6 @@ led \- link editor
.SH DESCRIPTION
.I Led
is a link editor for object modules,
created by one of the ACK assemblers.
It combines several
object programs into one,
resolves external references,
@ -128,6 +127,10 @@ error telling why
.I led
chose to link it (which unresolved reference it resolves).
This option is useful in resolving 'multiply defined' problems.
.TP
.B \-d
If led was built with debugging diagnostics, then output copious amounts
of tracing explaining what it is doing.
.SH FILES
~em/lib.bin/em_led
.PD 0

View file

@ -21,6 +21,7 @@ static char rcsid[] = "$Id$";
#include "defs.h"
#include "memory.h"
#include "orig.h"
#include "sym.h"
extern bool incore;
#ifndef NOSTATISTICS
@ -381,8 +382,6 @@ evaluate()
change_names();
}
extern unsigned short NGlobals, NLocals;
/*
* Sect_comm[N] is the number of common bytes in section N.
* It is computed after pass 1.

View file

@ -32,6 +32,7 @@ static char rcsid[] = "$Id$";
#include "debug.h"
#include "memory.h"
#include "object.h"
#include "sym.h"
static void copy_down(struct memory* mem, ind_t dist);
static void copy_up(struct memory* mem, ind_t dist);
@ -544,7 +545,6 @@ void write_bytes(void)
unsigned short nsect;
long offchar;
register struct memory *mem;
extern unsigned short NLocals, NGlobals;
extern long NLChars, NGChars;
extern int flagword;
extern struct outhead outhead;

View file

@ -13,6 +13,7 @@ static char rcsid[] = "$Id$";
#include <out.h>
#include "const.h"
#include "memory.h"
#include "sym.h"
static void generate_section_names();
@ -28,7 +29,6 @@ extern int flagword;
*/
beginoutput()
{
extern unsigned short NLocals, NGlobals;
extern long NLChars, NGChars;
extern char *outputname;

View file

@ -16,6 +16,7 @@ static char rcsid[] = "$Id$";
#include "debug.h"
#include "defs.h"
#include "orig.h"
#include "sym.h"
#define UBYTE(x) ((x) & BYTEMASK)
@ -400,7 +401,6 @@ static putvalu(uint32_t valu, char* addr, uint16_t type)
}
}
extern unsigned short NLocals, NGlobals;
extern struct outsect outsect[];
extern struct orig relorig[];

View file

@ -18,6 +18,7 @@ static char rcsid[] = "$Id$";
#include "const.h"
#include "memory.h"
#include "debug.h"
#include "sym.h"
/*
* Symbol table types. Each hash table entry contains the offset of a symbol
@ -34,6 +35,9 @@ struct symbol {
static ind_t hashtable[NHASH];
unsigned short NLocals = 0; /* Number of local names to be saved. */
unsigned short NGlobals = 0; /* Number of global names. */
/*
* Initialize the symbol table. All indices should be noticeably invalid.
*/
@ -90,9 +94,7 @@ searchname(string, hashval)
* destroyed by allocation. However, the string of which name->on_foff is the
* offset can be destroyed, so we save it first.
*/
entername(name, hashval)
struct outname *name;
int hashval;
void entername(struct outname* name, int hashval)
{
ind_t savindex;
ind_t symindex;
@ -115,6 +117,7 @@ entername(name, hashval)
newname->on_foff = savindex;
sym->sy_next = hashtable[hashval];
hashtable[hashval] = symindex;
NGlobals++;
}
/*

9
util/led/sym.h Normal file
View file

@ -0,0 +1,9 @@
#ifndef SYM_H
#define SYM_H
extern unsigned short NLocals; /* Number of local names to be saved. */
extern unsigned short NGlobals; /* Number of global names. */
extern void entername(struct outname* name, int hashval);
#endif

View file

@ -15,6 +15,7 @@ static char rcsid[] = "$Id$";
#include "out.h"
#include "const.h"
#include "memory.h"
#include "sym.h"
extern struct outhead outhead;
extern struct outsect outsect[];
@ -63,7 +64,6 @@ end_write()
{
register struct outname *name;
register int sectindex;
extern unsigned short NGlobals;
extern long NGChars;
assert(!incore);