BeOS PowerPC: a sad tale of Apple hardware

Yesterday I managed to test the exe being built…


And, yes - it works. Not too much of a surprise, I had this working before in the 2000’s. But great to see again.

Next I tries something a little more taxing. I took the “HelloWorld” source code from the R5 examples (it is in the “Intro” directory in the samples) and built and ran it under BeOS:


Zipping that up and moving it to the Mac, I started a new BeOS project (yes, I got the template to work, so I can now create a new project easily.) I then added the source code:


Anyone who knows BeIDE will see that looks a lot like a PowerPC BeIDE project :wink: Well, long story short - it compiled. So I copied it back to BeOS and, yep - it also runs!


The main issue is that it seems like the tool that deals with BeOS resource files is Be specific, and so I need to probably run a script on BeOS to add the resource file to the app for now. But other than that - it works!


When I investigated PPC BeOS I found that it use Preferred Executable Format (Joy!peff, documentation). I have not yet added support for it in my PE Decoder project, but I already have NE (Win16) and LE (VxD, OS/2), PE, ELF formats support.

Is it possible to produce PEF by some modern compiler or at least compiler that can run on Haiku/Linux/Windows?

Would also be my choice. But as far as I know, GCC does not support PEF. macOS (PPC) can only load PEF executables (it is also used by System 9 a.k.a. Classic macOS). I am unsure if Xcode can create PEF for Carbon applications.

Well, I don’t remember trying it, but there is a version of the Metrowerks compilers that ran on R5 X86 BeOS, and I guess should therefore run on 32bit Haiku. I believe you can get the from here: (no, not this one) or (this one). I forget which one is which… one should be ggc IA232 cross compiler for PowerPC, the other is a mwcc (and tools) PowerPC cross compiler for IA32. The names are not very helpful. But the one that contains mwcc, mwld etc is the one you want to try.

If you just want a general compiler than makes PEF, there is also Retro68. It can be configured to produce PEF executables for PowerPC. But it needs to be ported to build BeOS exes, and it seems like a bit of a hack and I doubt the C++ name mangling it produces will be compatible with BeOS/mwcc.

There are also command line tools for Windows. You will need to acquire a version of Metrowerks Codewarrior that runs on Windows, but I believe there might be a version on the Wayback machine archive. The Metrowerks tools are probably quite antiquated now. You need to make sure the version you install supports at least Carbon to get PEF, as the later versions only supported Mach-o. I think the version I have is version 6, but I think 8 or 9 had it them too.

I think the simplest would be the original dross compiler though, and I don’t see why it would not work under Haiku 32bit.

Edit: having downloaded the zip, (, looks like it has the compiler, linker and associated BeOS libs and headers. It also has the disassembler. It doesn’t have pefdump though, but if you look at the Retro68 project, he has a few extra PEF tools.

Edit2: The one weird thing about the MetroWerks compiler for BeOS is that all the static libs are in a MetroWerks specific format. It is based on their object file format. If you can find a copy of BeIDE, in the docs folder, the binary format is described quite well. If you do look at the PEF format, adding MW Object format would also be cool. I started writing a decompiler ages ago in C#, and started looking at it again but this time in C. - I can send you the docs if you want them and can’t get access.

I have a feeling that the stuff under Project Builder/XCode was a different format. I also don’t think there was ever an X86 version of XCode that made apps that targeted Classic. I can take a look at PowerPC. I have Project Builder installed under Jaguar.

Edit: Okay, I checked… apparently Project Builder builds Mach-o exes and I guess, there is a loader somewhere in MacOS 9.22 (maybe earlier) that can load them. PEFViewer under Jag can’t open the app I just made in Project Builder (it says the “Magic Cookie” is wrong, I assume the magic word in the header) and mwdis seems to only work with Mach-o and complains that the header on a PEF exe is not a Mach-o header…

I confirmed that it is running on Haiku and produce object files. Complete binary compilation fails because of missing symbols, I haven’t looked at details. Maybe can be used to compile Haiku system libraries for PPC.

UPDATE: I managed to compile minimal GUI application for BeOS PPC.

Yeah, you need 3 extra object files (glue-noinit.a, start_dyn.o and term_init_dyn.o), which I guess you found. They define 3 symbols the linker needs, __start, and I forget the other two, but it is an init and deinit routine. There are always 2 warnings about redefining symbols in

Great you got it compiling :slight_smile:

I started writing decoder of PEF executable format. It seems to use same C++ mangling as GCC2.



That’s amazing work! How would I get a copy of the code once you have made more progress? Is it on github?

The name mangling makes some sense. I don’t know if it was a MetroWerks thing or not, but as the compiler from MacOS will build BeOS executables with C++ that run, I am guessing the MW compiler in general implements the same scheme. It might be an Apple thing, because the Mac targets use the Apple Universal Headers. Though, I don’t know how much C++ was in those.

I progressed a bit more: I implemented relocation decoder, data section unpacker and initial PowerPC disassembler. BlackBox is needed to run, currently run only on 32 bit x86. It may be difficult to run program if not familiar with Oberon systems. Project PE Decoder is located on GitHub. I have not uploaded WorkPefDecoder and WorkDecPPC yet.

Do you have idea how R2 register is initalized? Always set to beginning of section 1? This don’t work for, PLT entries (or how it is usually called in PEF) have negative offsets to R2.


No, I don’t know much about the PEF format myself. I was mainly looking at making the MW Object Format decompiler, with an idea to make tools that can generate valid object files that mwld can link. I originally wanted to get VASM generating raw machine code blocks that I could plumb in to an object file. I do know that although the BeOS shared objects are PEF, The PEF tools under OS X really do not like them and the PEF Viewer crashed opening them. It can open the app I build under OS X. I haven’t tried any of the BeOS exes. It might be the fact that they are Shared Objects rather than exe files?

I did Delphi for 10+ years and some ADA 83 at University in the 90’s, so BlackBox and Oberon are not a complete mystery, But my Delphi is quite a long time out of use now.

The other thing I was going to say - the mwcc and mwld are identical in most ways to the MacOS versions… it could be that this is something Mac specific that BeOS does too by convention. If so you might more info from the Classic Mac documents. By implementing PEF you are getting Classic Mac PowerPC executable files for “free” too… though, the Mac HFS file system is funky and I don’t know if moving a Mac exe to non HFS will destroy the resource/data forks beyond usability.

I don’t see differences except NULL entry point for .so files. But I looked only BeOS PEF files. PEF has 3 entry points: main, init, term.

Yes. I think the Mac only uses main. I can get you a simple Mac exe quite easily, but I don’t know what will happen with the resource/data forks on a non HFS file system.

You may find useful, it extracts various data from PEF file (section data, import/export symbol list etc.).

The main issue will be that my PowerBook is running 10.2.8, and my only other MacOS X install is a MacBook Pro with the new apple file system… I don’t know if that handles old Mac files. I doubt python 3 will run under Jaguar.

Blackbox runs on MacOS System 7 (68k). But it use some older executable format and have no PPC support.

I can run apps under Classic on the PowerBook. As long as the app still runs in 9.2.2, it should work.

I do have 8.6 installed too. If I can convince it to boot to 8.6, I might also be able to try it. However, once OS X is installed, the Powerbook really does not want to boot in to anything else. I think there is a way to force it, but it is mostly really not interested.

Blackbox distribution for Mac OS Classic is here:

1 Like

I will try this out and see if I can at least get it running.

What do I need from your repo to run the code?

Thinking about it, I can try to run 8.0 under SheepShaver on the BeOS install also. So I guess it will work somehow.

You can install classic mac in qemu, i got 9.2 running this weekend, no idea if that could help or too new.