Pages

Friday, September 16, 2011

GCC Plugins: Being a Parasite

Much of my research into region based memory management has been accomplished via gcc plugins. In such a means of implementation, one does not need to do full-up re-compiles of the gcc compiler or even a small stage-1 gcc compile. Instead, the plugins provide a wealth of the gcc API and are implemented as shared objects. In other words, if you wanna test a compiler optimization pass, or do some static analysis, cough-up a plugin, compile that bad-boy, and tell gcc to run 'er via the '-fplugin=' command line argument.

Of course, one can use the force for good or evil. I prefer to ere towards a phrase I have leaned about: "research purposes." Such a lovely phrase conveys an innocent meaning of that if something doesn't work, it's not the creators fault. It is a lot Like saying: "hey... this plugin might not have been proven correct." In other words, if my plugin posts your ssh private key to pastebin... oops. Muhahahahahhaha

:-)

-Matt

4 comments:

  1. It's the programmers equivalent of a southerner saying "bless his/her heart". That phrase allows anyone to say anything about anyone. To wit, "That's the ugliest baby in creation, bless its little heart!" The addition of "little" in that last sentence is bonus points.

    ReplyDelete
  2. > if my plugin posts your ssh private key to pastebin

    gcc has a long history of this.

    During the ANSI C standardisation process, the exact meaning of all the #pragma preprocessor directives was left "implementation dependent". The GCC decided to take it literally, and if you used #pragma in your program, the GCC compiler would try running a succession of games, and if it couln't, would abort.

    More info:

    http://www.feross.org/gcc-ownage/

    I guess it tried to invoke games because that was the pre-pastebin, pre-SSH era :-)

    Exercise for the reader: Use Matt's LWN article to write a GCC plugin which runs games when the preprocessor hits a #pragma :-)

    ReplyDelete
  3. Once upon a time when ANSI C was being standardised, the meaning of the different #pragmas was left "implementation dependent". The GCC guys thought this was a stupid idea, and decided that their interpretation of #pragma would be that the compiler would try to start a number of game programs, and if unsuccessful, abort.

    http://www.feross.org/gcc-ownage/

    I'm guessing it's just because this was in the pre-pastebin, pre-SSH era.

    Exercise: Use Matt's LWN tutorial to write a tutorial which launches a game (web game?) when it hits a #pragma...

    ReplyDelete
  4. Thanks Mitch! I was not aware of this.

    -Matt

    ReplyDelete