APE and other polyglot executables break GDB and LLDB because object-file plugins are greedy. The PE plugin sees MZ at offset 0 and claims the file. The ELF header sitting in a printf octal blob never gets a vote.
This repo patches that design:
-
Survey every
ObjectFile/ BFD target. Each returns a confidence score and the byte range it understood. -
If more than one target scores high — a chord — a meta-plugin (
ObjectFilePolyglot) owns the file. -
The meta-plugin asks the process plugin (Linux
ptrace, Windows, Darwin) which slice is live, then projects that layout into the symbol table.
That is parser theory, not a new UI. Stepping still looks like stepping.
LLDB (llvm-project, paths relative to lldb/):
git apply patches/lldb-objectfile-chord.patchThen add plugin/ObjectFilePolyglot.cpp to the ObjectFile plugin CMake list (the patch expects ObjectFile/Polyglot/).
GDB: patches/gdb-bfd-survey.patch against binutils-gdb bfd/format.c.
Scoring loops parse more of a hostile file than first-match. Keep the survey on the first 8 KiB plus each plugin’s existing magic probe. Do not follow unbounded overlay pointers during the survey pass.