The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
* [TUHS] Debugging help sought
@ 2020-08-06  1:28 Adam Thornton
  2020-08-06  2:01 ` Jim Capp
  2020-08-06 15:47 ` Paul Winalski
  0 siblings, 2 replies; 19+ messages in thread
From: Adam Thornton @ 2020-08-06  1:28 UTC (permalink / raw)
  To: The Eunuchs Hysterical Society

[-- Attachment #1: Type: text/plain, Size: 398 bytes --]

I finally munged lbforth.c (https://gist.github.com/lbruder/10007431) into
compiling cleanly on mostly-stock v7 with the system compiler (lbforth
itself does fine on 211BSD, but it needs a little help to build in a real
K&R environment).

Which would be nice, except that when it gets to the linker....

$ cc -o 4th forth.c
ld:forth.o: Local symbol botch

WTF?

How do I begin to debug this?

Adam

[-- Attachment #2: Type: text/html, Size: 617 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread
* Re: [TUHS] Debugging help sought
@ 2020-08-07 16:07 Noel Chiappa
  2020-08-07 17:11 ` John Cowan
  2020-08-07 20:48 ` Warner Losh
  0 siblings, 2 replies; 19+ messages in thread
From: Noel Chiappa @ 2020-08-07 16:07 UTC (permalink / raw)
  To: tuhs; +Cc: jnc

    > 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


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2020-08-07 20:49 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-06  1:28 [TUHS] Debugging help sought Adam Thornton
2020-08-06  2:01 ` Jim Capp
2020-08-06  3:04   ` Warner Losh
2020-08-06  3:08     ` Warner Losh
2020-08-06  5:55       ` Adam Thornton
2020-08-06  4:57     ` Dave Horsfall
2020-08-06  7:16       ` Otto Moerbeek
2020-08-06 15:47 ` Paul Winalski
2020-08-06 16:09   ` Larry McVoy
2020-08-06 16:19     ` Paul Winalski
2020-08-06 16:24       ` Larry McVoy
2020-08-06 23:41         ` Adam Thornton
2020-08-07  0:35   ` Warner Losh
2020-08-07  4:30     ` Adam Thornton
2020-08-07  5:49       ` Warner Losh
2020-08-07  5:54         ` Adam Thornton
2020-08-07 16:07 Noel Chiappa
2020-08-07 17:11 ` John Cowan
2020-08-07 20:48 ` Warner Losh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).