Converting C for KCC on TOPS20

Warner Losh imp at bsdimp.com
Tue Dec 10 18:54:49 CST 2019


On Tue, Dec 10, 2019 at 5:53 PM Sean Conner via cctalk <
cctalk at classiccmp.org> wrote:

> It was thus said that the Great David Griffith via cctalk once stated:
> >
> > I'm trying to convert some C code[1] so it'll compile on TOPS20 with
> KCC.
> > KCC is mostly ANSI compliant, but it needs to use the TOPS20 linker,
> which
> > has a limit of six case-insentive characters.  Adam Thornton wrote a
> Perl
> > script[2] that successfully does this for Frotz 2.32.  The Frotz
> codebase
> > has evolved past what was done there and so 2.50 no longer works with
> > Adam's script.  So I've been expanding that script into something of my
> > own, which I call "snavig"[3].  It seems to be gradually working more
> and
> > more, but I fear the problem is starting to rapidly diverge because it
> > still doesn't yield compilable code even on Unix.  Does anyone here have
> > any knowledge of existing tools or techniques to do what I'm trying to
> do?
>
>   If you are doing this on Linux, an approach is to compile the code there,
> then run 'nm' over the object files, and it will output something like:
>
> [spc]lucy:~/source/boston/src>nm main.o
> 000000ef t CgiMethod
>          U CgiNew
> 00000000 r __PRETTY_FUNCTION__.21
>          U __assert_fail
>          U crashreport_core
>          U crashreport_with
>          U gd
>          U gf_debug
> 00000000 T main
>          U main_cgi_get
>          U main_cgi_head
>          U main_cgi_post
>          U main_cli
>
>   The last column are identifiers; the second column is the type of
> identifier, and the first column is the value.  What you want to look for
> are types 'T' (externally visible function), 'C' (externally visible
> constant data) and 'D' (externally visible data).  It is these identifiers
> that will need to be six unique characters long.
>
> Something like:
>
> [spc]lucy:~/source/boston/src>nm globals.o  | grep ' [CDT] '
> 00000041 T GlobalsInit
> 00000004 C c_adtag
> 00000004 C c_class
> 00000004 D c_conversion
> 00000004 C c_days
> 00000004 C c_tzmin
> 00000000 D c_updatetype
> 00000004 C c_webdir
> 00000008 D cf_emailupdate
> 00000004 C g_L
> 00000004 C g_blog
> 00000004 C g_templates
> 00000020 D gd
> 00000d09 T set_c_conversion
> 00000beb T set_c_updatetype
> 00000dbd T set_c_url
> 00000cab T set_cf_emailupdate
>
> (but over all object files).  I would then generate unique six character
> long identifiers for each of these, and slap the output into a header file
> like:
>
> #define GlobalsInit     id0001
> #define c_adtag         id0002
> #define c_class         id0003
> #define c_conversion    id0004
>
> and then include this file for every compilation unit.  I think that would
> be the easiest thing to do.
>

You'd need to exclude libc symbols, though.

In a.out times you could just change the names from old to new and adjust
the string table offset to do this :)

Warner


More information about the cctalk mailing list