name mangling/parser

GrahamJWalsh@gmail.com
Thu, 05 Jul 2007 01:19:16 -0700

          From comp.compilers

Related articles
name mangling/parser GrahamJWalsh@gmail.com (2007-07-05)
Re: name mangling/parser nicola.musatti@gmail.com (Nicola Musatti) (2007-07-06)
| List of all articles for this month |
From: GrahamJWalsh@gmail.com
Newsgroups: comp.compilers
Date: Thu, 05 Jul 2007 01:19:16 -0700
Organization: Compilers Central
Keywords: linker, question
Posted-Date: 05 Jul 2007 15:33:57 EDT

Hi,


We're stuck in a precarious position whereby cross compilation between
two compilers, is broken.. due to differences in name mangling.
Specifically we have a dll/lib from microsoft visual studio 2005 and
an application compiled with cbuilder 6 from borland. The problem lies
(as everybody on this forum will know all too well) in the fact that
differnent decoration/mangling systems are used. e.g.


for example a function "initialise" is mangled like this under
borlands system;


  @prs@PrsGrid@initialise$qqspxct1t1p18prs@PricerCallbackui


however it looks like this under the MS mangling;


?initialise@PrsGrid@prs@@QAG_NPBD00PAVPricerCallback@2@I@Z




we link the two together by *manually* providing aliases like this to
the borland linker (via impdef and implib)


  @prs@PrsGrid@initialise$qqspxct1t1p18prs@PricerCallbackui =
  ?initialise@PrsGrid@prs@@QAG_NPBD00PAVPricerCallback@2@I@Z ;


Anyways, we can get various functions to work at the moment by using
this manual approach. This wont scale obviously. Other approaches such
as using extern "C" or LoadLibrary won't scale either for us.


We are about to write a parser that will translate a micsoft mangled
name into a borland mangled name. That way we can automate the process
for all the symbols defined in the MS dll and link create a .lib that
is acceptable in the other (borland) link environment. We have the
EBNF for both name mangling systems and intend to use boost spirit to
parse and generate the translation we need.


I would be VERY VERY VERY grateful if anybody out there has already
done this. If yes, you're going to save us serious amounts of
headache. Does such a tool already exist? Is the approach we've
decided upon to use a translator a viable one? Or is the vendor
mangling scheme riddled with proprietory stuff such that doing the
translation/parsing will never work?




thanks very much for any assistance or input/feedback.
[Looks like it should be about three lines of TXL. -John]




regards


Graham



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.