This is the mail archive of the bfd@sourceware.cygnus.com mailing list for the bfd project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Jumptables: How painful to hack?


   From: Jason Merrill <jason@cygnus.com>
   Date: 31 Mar 1999 11:16:29 -0800

    >    Date: Tue, 30 Mar 1999 21:09:18 -0800
    >    From: Jason Merrill <jason@cygnus.com>

    >    A question for folks who have worked on BFD for a while: How horrible
    >    are jumptables to deal with?  I'm looking at parameterizing the g++
    >    ABI, and am strongly considering that as an implementation strategy.

    > I started to reply, but then I realized that it depends upon what you
    > mean by the g++ ABI.  Do you mean the code that g++ generates, or do
    > you mean the files in gcc/cp?  The former already uses jumptables, of
    > course, since that's what virtual functions are, and I'm not sure in
    > what sense the latter has an ABI.

   I mean the latter.  The C++ ABI involves things like object layout,
   handling of virtual functions and bases, name mangling and such things.

I'd say the main lessons from BFD are:

* Define your interfaces clearly.  People can't look at the code to
  figure them out, since they won't look at all the possible targets
  of an indirect call.

* BFD uses macros to hide the jumptable invocations and make them look
  like a function call.  I think this was a mistake.  It makes it
  harder for novices to understand what the code is doing.  You can't
  do a tags search to find the target of the call.  Macros per se may
  be useful, but don't make it look like an ordinary function.

Ian