Subject: leading-underscore-ifying assembler source code
To: None <port-pmax@netbsd.org>
From: Jonathan Stone <jonathan@DSG.Stanford.EDU>
List: port-pmax
Date: 12/09/1994 00:33:06
Ted Lemon writes:

>I actually went to the trouble of macrofying locore.S so that it can
>be compiled either way - each symbol is encapsulated in a cpp macro,
>like this:
>
>        .globl  US(foo)
>US(foo):        ...
>
>Then US can be defined as follows:
>
>#ifdef PREPEND_UNDERSCORES
># ifdef __STDC__
>#  define US(x) _##x
># else
>#  define US(x) _/**/x
># endif
>#else
># define US(x)  x
>#endif

When I faced this, oh, back in August, when I needed an a.out
format kernel to get netstat (or, if you prefer, libkvm.a)
to work, I took what I still think is the best approach.
I added a macro XTERNAL() -- the name is arbitrary but this
one seemed good -- that prepends an underscore. It's easy
to define it to NOT add the underscore.


Then I changed the definition of LEAF(), NON_LEAF(), NNON_LEAF(), and
END() in sys/arch/pmax/includemachAsmDefs.h to wrap every use of the
label arguments to these macros in XTERNAL().

If compiling for ECOFF, make XTERNAL(x) expand to x. If compiling
for NetBSD/a.out, make XTERNAL(x) expand to _x.

This seems clean, simple, and not completely inelegant.  One member of
the NetBSD core team suggested that maintaing ECOFF compatibility
wasn't worthwhile.  I truly think this individual has no experience
with a NetBSD platform where the native vendor's compiler toolset
format (.o format and linker conventions), and bootstrap, is
significantly different from the NetBSD conventions. That is, this
individual doesn't have the experience (isn't qualified) to judge the
_benefit_ side of the cost/benefit tradeoff as to whether to keep the
ability to build ECOFF kernels.  However, their opinion carried the
day.  Sigh.

Perhaps we could conduct a straw poll and see if it's worth adding
this capability back?  Perhaps Dean would care to take votes??

Another fix -- probably too late by now, and probably unacceptable --
would be to abandon the underscores altogether, and have libkvm.a
simply strip  off the first character of a name given to it,
if compiled for a pmax.  Ugly, ugly, ugly.

--Jonathan