[TUHS] Debugging help sought

Noel Chiappa jnc at mercury.lcs.mit.edu
Sat Aug 8 02:07:23 AEST 2020


    > From: Warner Losh

    > 8 I think was the limit.

IIRC, you could use longer names than that (in C), but external references
only used the first 7 (in C - C symbols had a leading '_' tacked on; I used to
know why), 8 (in assembler).

    > Could that cause this error?

Seems unlikely - see below.


    > The error comes from lookloc. This is called for external type
    > relocations. It searches the local symbol table for something that
    > matches the relocation entry. This error happens when it can't find
    > it...

Someone who actually looked at the source:

  https://www.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src/cmd/ld.c

instead of just guessing. Give that man a star!

I spent a while looking at the code, trying to figure out i) how it works, and
ii) what's going wrong with that message, but I don't have a definitive
answer. The code is not super well commented, so one has to actually
understand what it's doing! :-)

It seems to my initial perusal that it maintains two symbol tables, one for
globals (which accumulates as each file is processed), and one for locals
(which is discarded/reset for each file). As Werner mentioned, the message
appears when a local symbol referenced in the relocation information in the
current file can't be found (in the local symbol table).

It's not, I think, simply due to too many local symbols in an input file -
there seems to be a check for that as it's reading the input file symbol
table:

   if (lp >= &local[NSYMPR])
           error(1, "Local symbol overflow");
   *lp++ = symno;
   *lp++ = sp;

although of course there could be a bug which breaks this check. It seems to
me that this is an 'impossible' error, one which can only happen due to i) a
bug in the loader (a fencepost error, or something), or ii) an error in the
input a.out file.

I don't want to spend more time on it, since I'm not sure if you've managed to
bypass the problem. If not, let me know, and we'll track it down. (This may
involve you addding some printf's so we have more info about the details.)

    Noel



More information about the TUHS mailing list