Issue 243550
Summary [RuntimeDyld][MachO] Loading a PowerPC Mach-O object hits llvm_unreachable("Unsupported target for RuntimeDyldMachO.")
Labels mcjit, crash
Assignees
Reporter AnantaSrikar
    `RuntimeDyld::loadObject` passes every Mach-O object to `RuntimeDyldMachO::create`, whose `switch` on the architecture ends in `llvm_unreachable("Unsupported target for RuntimeDyldMachO.")`. The architecture comes from the object, and `MachOObjectFile` accepts architectures RuntimeDyld doesn't handle, such as PowerPC. So an empty PowerPC Mach-O object aborts an assertions build of `llvm-rtdyld`, and crashes a release build (Ubuntu `llvm-rtdyld` 21.1.8 dies with SIGTRAP).

**Version**: main at c7014922f582 (2026-11-16), built from the Git repository with `-DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_TARGETS_TO_BUILD="X86;AArch64;ARM;PowerPC;WebAssembly"`, on x86_64 Linux.

### Reproducer

```sh
cat > ppc.yaml <<'YAML'
--- !mach-o
IsLittleEndian:  false
FileHeader:
  magic:           0xFEEDFACE
 cputype:         0x12
  cpusubtype:      0x0
  filetype:        0x1
 ncmds:           0
  sizeofcmds:      0
  flags: 0x0
...
YAML
yaml2obj ppc.yaml -o ppc.o
llvm-rtdyld -verify -triple=powerpc-apple-darwin ppc.o
```

A PowerPC64 object (`magic: 0xFEEDFACF`, `cputype: 0x1000012`, plus `reserved: 0x0`) with `-triple=powerpc64-apple-darwin` aborts the same way. An empty x86-64 Mach-O object with `-triple=x86_64-apple-darwin` exits 0.

### Observed

```
Unsupported target for RuntimeDyldMachO.
UNREACHABLE executed at llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp:353!
```

### Expected

An error that RuntimeDyld doesn't support Mach-O objects for this architecture.

### Analysis

https://github.com/llvm/llvm-project/blob/c7014922f5829426952a38d079220c21b0a8ebe8/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp#L347-L354

called from:

https://github.com/llvm/llvm-project/blob/c7014922f5829426952a38d079220c21b0a8ebe8/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp#L1371-L1381

`RuntimeDyldCOFF::create` has the same `default: llvm_unreachable(...)`. Returning `nullptr` (or an `Error`) from the factories and having `loadObject` report the unsupported architecture would fix it.

This report was drafted with help from an AI assistant (Claude); I reviewed it and reproduced it myself.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to