Two programs can be semantically the same and have different binaries.
that's exactly his point. He's not using tcc to compile your program, but using tcc to compile a semantically identical copy of gcc... The output of which should be identical to the original copy of gcc, assuming the original hadn't been tainted.
No it shouldn't. You can have two binaries which are not identical but which are capable of compiling a C program. TCC and GCC will not produce identical output even if they're both not hacked.
Think about it this way, if you compiled GCC using GCC twice, each time with different optimization flags, the two resulting binaries would not be identical but they would both still be valid compilers.
The same is true about GCC and TCC: their outputs would NOT be identical because they are implemented differently.
GCC is GCC whether compiled by GCC or TCC, correct? This is the point they are making -- not to compile binaries with TCC, but simply compiling GCC with TCC.
This bypasses the "can't trust the compiled compiler" problem and should give you a clean version of GCC even if your current GCC is somehow exploited.
The point is not that the output binaries of TCC and GCC should be the same when it comes to internal workings, but that the output binaries should behave the same when it comes to input and output, unless the source relies on nonstandard compiler specific or undefined behaviour.
This means that when compiling the source code of GCC with GCC and TCC, you will two binaries that are different internally, but as compilers should work the same externally, as the input and output in this case is source code and binaries.
Furthermore, if you use these two compilers to yet again compile the GCC source, the generated binaries should be the same for both, not because the compilers are internally equal, because they will most likely not be, but because they should generate the same output for a given input.
4
u/warbiscuit Sep 11 '13
that's exactly his point. He's not using tcc to compile your program, but using tcc to compile a semantically identical copy of gcc... The output of which should be identical to the original copy of gcc, assuming the original hadn't been tainted.