[CDG5] MPW and Trampoline

Elliot Nunn elliotnunn at fastmail.com
Tue Feb 5 22:29:20 AWST 2019


Great work!

At some point, will you be able to compare your target Trampoline to the very final version released?

> On 5 Feb 2019, at 8:21 am, Max Poliakovski <maximumspatium at googlemail.com> wrote:
> 
> Hi Elliot,
> 
> thank you for your helpful suggestions!
> 
> After hours of downloading of historical development disks and searching them for MPW packages, I finally managed to find a MrC compiler that produces binary code very close to the code found in the Apple binary. That compiler is resided on the E.T.O #21 disk from 1996 and is a part of the MPW 3.4.2b3 pre-release. It identifies itself as "MrC C Compiler 2.0.2d1c6".
> 
> After playing a bit with this compiler and my code, I was able to produce near byte-perfect output for string.c and fully byte-perfect output for ofci.c!
> 
> The former contains seven functions; six of them are byte-identical to the Apple binary; the 7th - memchr() -contains two instructions where operands are swapped compared to Apple's code. I wasn't able to figure out why it happens.
> 
> When I say "byte-identical", I actually mean anything except TOC references and cross-module call offsets. These will be changed by PPCLink during the linkage of the final binary. Tweaking PPCLink to generate byte-identical output is a task on its own. I'm not sure I'll even succeed on it.
> 
> Anyway, round-tripping MrC has become feasible. Even if the 100% match cannot be achieved, it's still a good validation of the correctness of the decompiled code.
> 
> Stay tuned.
> 
> Cheers
> Max
> 
> 
>> Am Mi., 9. Jan. 2019 um 05:22 Uhr schrieb Elliot Nunn <elliotnunn at fastmail.com>:
>> Happy new year!
>> 
>> MrC round-tripping sounds like a very hard slog. After all, RISC is
>> sometimes said to stand for "Relegate the Interesting Stuff to the
>> Compiler"! Mind you, with your intimate familiarity with the
>> architecture, you could well enjoy some breakthroughs.
>> 
>> I can't seem to find MPW 3.4 in my archives. Is it old enough even to
>> have a RISC compiler? I think that the early ones were distributed as a
>> separate SDK. I suggest downloading all the E.T.O. images that you can
>> find. They are the best library of MPW tools that I have found.
>> 
>> Have you built any bootable Trampolines? That would be a very powerful
>> validation of your reversal.
>> 
>> > On 8 Jan 2019, at 11:05 pm, Max Poliakovski <maximumspatium at googlemail.com> wrote:
>> > 
>> > Hi guys,
>> > 
>> > happy new year!
>> > 
>> > > Quoting Elliot's mail from 05-02-2018:
>> > > I have had some success getting Apple's 68k C compiler to produce byte-accurate output. (A few things were in my favour here: simple C code, a simple C compiler and some sources for a previous version of the binary.) I always aim for byte-perfection after building my reversed sources (admittedly mostly assembly) because it lets me know when I've messed up. However, my approach is not always practical, and your focus on high-level hacking is likely to be more rewarding.
>> > 
>> > I've played a couple of days with EMPW with the goal to get a byte-perfect output for the string.c module that consists of seven short functions (3-7 statements).
>> > 
>> > As expected, I wasn't able to obtain byte-perfect output with MrC regardless different optimizations and even compiler versions.
>> > 
>> > Below a short report:
>> > 
>> > MrC 4.1.0 from MPW 3.5 GM emits code that is far from the code located in the Trampoline binary.
>> > 
>> > I therefore downgraded to MrC 3.0.1 from 02-20-1997 that can be obtained here: https://www.staticky.com/mirrors/ftp.apple.com/developer/Tool_Chest/Core_Mac_OS_Tools/MPW_Website_Downloads/
>> > 
>> > With MrC 3.0.1, I was able to perfectly reconstruct strlen() and memset() - both are very, very simple functions. After playing with optimization settings abit, the code for strcpy() got very close to the Apple's binary except a small difference in the register allocation ($r11 and $r12 are swapped).
>> > 
>> > I also tried MrC 4.1a1 but it seems to go in the wrong direction.
>> > 
>> > I suspect that Apple might have used even an older compiler. The only possibility to check that out is to get a copy of MPW 3.4 (1995) which seems to be one of the first MPW versions including PowerPC compilers.
>> > 
>> > Does somebody own MPW 3.4? I've seen only 3.3, 3.5 and PR so far...
>> > 
>> > Cheers
>> > Max
>> > _______________________________________________
>> > cdg5 mailing list
>> > cdg5 at ucc.asn.au
>> > https://lists.ucc.gu.uwa.edu.au/mailman/listinfo/cdg5
>> 
>> _______________________________________________
>> cdg5 mailing list
>> cdg5 at ucc.asn.au
>> https://lists.ucc.gu.uwa.edu.au/mailman/listinfo/cdg5
> _______________________________________________
> cdg5 mailing list
> cdg5 at ucc.asn.au
> https://lists.ucc.gu.uwa.edu.au/mailman/listinfo/cdg5
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.ucc.gu.uwa.edu.au/pipermail/cdg5/attachments/20190205/b86c0e51/attachment.htm 


More information about the cdg5 mailing list