The precise nature of how ppc64 software is broken

gsteemso

New Tinkerer
Mar 28, 2026
1
2
3
So, as many of us are aware, there’s some kind of fault in Apple’s PowerPC-era toolchains which cause them to incorrectly construct the error-unwinding information on subroutines when building for “-arch ppc64”. (As far as I can make out, information which should occupy several words of memory is instead overwritten onto the same word, rendering it useless.) Apple took advantage of the transition to Intel to declare they would not fix it, which is why Clang will only do 32-bit PowerPC.

I am most of the way through working out how to fix this, but I have yet to determine exactly what component of the toolchain is failing to correctly write the error-unwinding data. I’m 100% confident in identifying it eventually, but I figure it would save me a lot of time if anyone out there already knows. It costs nothing to ask. :¬)

So, how about it? Does anyone know more?
 

nilobject

Tinkerer
Nov 21, 2023
116
45
28
"GCC developer Iain Sandoe documented in September 2025 that Darwin's LLVM-based assemblers accept .cfi_* directives but can produce incompatible compact-unwind output when used with GCC. GCC consequently disables those directives on Darwin."

"Hi gsteemso, I had a dig through the old Apple sources and the usual PPC forums. I haven't single-stepped a 10.5 link, so treat this as a map rather than a finished proof.

The likely place the unwind records get smashed is the linker, not GCC's code generator and not the libgcc unwinder (that only reads the table at run time).

  • Apple's gcc 4.2 Darwin backend does emit .quad for 8-byte FDE deltas, and the ppc64 assembler writes those 8-byte PPC_RELOC_VANILLA values in order. Personality and LSDA are deliberately 4-byte (sdata4 / .long), which matches the encoding byte.
  • Classic ld (cctools ppc_reloc.c) has no 8-byte (r_length == 3) path for PPC_RELOC_VANILLA at all, only 1, 2 and 4 byte stores.
  • ld64 is the better match for "several words written onto the same word". In the later ppc64 CFI path (Iain Sandoe's darwin-xtools), unlike x86_64/arm64, it parses __eh_frame without applying relocations first ("FIXME: libunwind does not support ppc64"). The shared ppc/ppc64 reloc routine uses 32-bit source addresses, and the ppc64 personality fixup always does a 4-byte store, with a FIXME that encoding 0x90 (pointer-sized, 8 bytes on ppc64) is treated as a 4-byte offset.
I'd start by assembling a small -arch ppc64 file with Apple gcc and comparing __eh_frame in the .o with the same section after the link. If the .o is already wrong, it's as. If it only goes wrong in the linked image, it's ld64 (or classic ld if that's what got invoked).

Also: Iain Sandoe has been around this for years (libffi FDE encoding on darwin9 -m64, and older ld64 needing scattered relocs for CIE/FDE). On MacRumors, ld64-127 is known to mishandle ppc64 and people stay on ld64-97. And modern Clang dropped Darwin PowerPC entirely (32 and 64) in 2018"
 
Last edited: