Kenneth Brody wrote On 05/09/06 16:08,:
David Wade wrote:
Folks,
Does any one know of any "name mangling" software that allows standard C
with long names to be linked? Any suggestions for a better place to look? I
have tried putting various searchs into google to no avail.
Why do you need to "mangle" the names just because they're "long"?
The usual reason is that the code uses a set of
external names that clash if merely truncated to the
linker's limit:
int getDescenderHeight(const Font *f);
const char *getDescription(const Font *f);
struct design_t *getDesign(const Font *f);
enum destination getDestination(const Taxi *t);
.... all of which are just `GETDES' to a case-insensitive
six-character linker satisfying the C89 minimal requirement.
What D.W. needs is some kind of tool that collects all these
names and writes a .h file like
#define getDescent GET121
#define getDescription GEN845
#define getDesign GEN126
#define getDestination GEN666
.... that he can then #include everywhere.
It was more than twenty years ago that I last confronted
this problem, and the tool we used was not something pre-
packaged: We just cobbled together a few shell scripts and
a short ad-hoc program. One important advantage was that we
were doing a port from a less-limited system where we were
able to build the program with the full names; this allowed
us to extract the names from the executable with an existing
system utility ("nm") instead of needing to parse the C source.
The worst part, as I recall, wasn't writing the mangler
but trying to use the debugger on the code whose long external
names had all been changed ... A pair of original-to-mangled
and mangled-to-original "dictionaries" helped, but there was
a lot of back-and-forthing just to figure out where to set a
breakpoint. Interpreting a stack trace was painful ... It
helps a little if the mangling preserves some "interesting"
features of the original names. It helps even more if the
mangling doesn't change (much) from day to day. Together,
these two suggest that the mangling should be driven as much
from the name itself as possible, and shouldn't just be a
disguised sequence number or address or some such that has
zero mnemonic value and defeats memorization.
Alas, I'm not aware of a pre-packaged tool that does this
sort of thing. On the other hand, it was a smallish bit of
work to put the tool together, and only the work of a few days
to refine it as far as we thought we could usefully go.
--
Er*********@sun.com