Related articles |
---|
Self compiling compiler ershc123@nyc.rr.com (ERSHC) (2016-03-31) |
Re: Self compiling compiler 545-066-4921@kylheku.com (Kaz Kylheku) (2016-03-31) |
Re: Self compiling compiler thomas.goorden@gmail.com (Thomas Goorden) (2016-03-31) |
Re: Self compiling compiler nmh@t3x.org (Nils M Holm) (2016-03-31) |
Re: Self compiling compiler rivers@dignus.com (Thomas David Rivers) (2016-03-31) |
Re: Self compiling compiler alexfrunews@gmail.com (2016-03-31) |
Re: Self compiling compiler jkallup@web.de (Jens Kallup) (2016-03-31) |
Re: Self compiling compiler 545-066-4921@kylheku.com (Kaz Kylheku) (2016-04-03) |
Re: Self compiling compiler ershc123@nyc.rr.com (ERSHC) (2016-04-02) |
Re: Self compiling compiler nmh@t3x.org (Nils M Holm) (2016-04-04) |
Re: Self compiling compiler federation2005@netzero.com (2016-05-25) |
Re: Self compiling compiler federation2005@netzero.com (2016-05-28) |
Re: Self compiling compiler rockbrentwood@gmail.com (2016-08-22) |
From: | Kaz Kylheku <545-066-4921@kylheku.com> |
Newsgroups: | comp.compilers |
Date: | Sun, 3 Apr 2016 10:34:11 -0400 (EDT) |
Organization: | Aioe.org NNTP Server |
References: | 16-03-013 16-03-016 |
Injection-Info: | miucha.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="95341"; mail-complaints-to="abuse@iecc.com" |
Keywords: | C |
Posted-Date: | 03 Apr 2016 10:34:11 EDT |
On 2016-03-31, Nils M Holm <nmh@t3x.org> wrote:
> ERSHC <ershc123@nyc.rr.com> wrote:
>> I'd like to teach an undergraduate class based on the Thompson hack
>> (see Ken Thompson's Turing Award lecture). I don't want to write a
>> "whole" compiler, so need a compiler that can compile itself,
>> preferably one that runs under Linux and is reasonably small. Can
>> anyone point me to something more appropriate than gcc (which is far
>> from small)?
>
> For something really small, check out Lindberg's Foogol. Here's a version
> I converted to C89: http://www.t3x.org/files/foogol5.shar.Z
>
> For something more complete, but still much simpler than GCC, have a look
> at SubC: http://www.t3x.org/subc/index.html There's also a book describing
> its internals: http://www.t3x.org/reload/index.html (Yes, I'm the author!)
>
> There are various other small compilers, from very simple ones to
> multi-platform optimizing compilers on my home page. Feel free to
> look around!
What matters here is not the compiler size but:
- The compiler has to be self-bootstrapping.
The Thompson trick can't be perpetuated on something which
strictly requires another compiler in order to build, and is then
not re-compiled with itself. The end goal of the trick is not
to have any traces of that trick in any piece of source code;
the result is a rogue compiler binary which replicates the rogue
code when it is used to compile itself, and which alters
some additional program, like a security-sensitive utility
(su, login, ..)
- how easy is it, within the compiler's framework, to do this:
- insert a piece of code which recognizes a static source
code structure (perhaps as an abstract-syntax-tree-level pattern
match) so that it can say "hey, I'm compiling myself: that parse is a
piece of *me*!" or "hey, I'm compiling the login program!".
- obtain the above AST-recognizing code not as C source, but as as a
piece of AST material which the compiler itself can insert into a
parse.
- obtain, as an AST, some rogue code which the malicious compiler
inserts into the parse of the target program such as login,
as well as the rogue code which perpetuates all of this.
If the compiler is small, but its data structures and internal API's are
a dog's breakfast, it will be tedious to do.
(Mind you GCC is big *and* a dog's breakfast.).
Return to the
comp.compilers page.
Search the
comp.compilers archives again.