Skip to content

ptx-fix-output-parameters: ET_REL relocatable-object loader (option relocobjects) - #37

Merged
mahaloz merged 3 commits into
mainfrom
feat/angr-ptx-fix-output-parameters-bcee92
Jun 25, 2026
Merged

mahaloz merged 3 commits into
mainfrom
feat/angr-ptx-fix-output-parameters-bcee92

Conversation

@mahaloz

@mahaloz mahaloz commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

relocobjects: load ELF relocatable objects (ET_REL / .o)

Closes the angr-vs-kuna gap test_decompiling_ptx_fix_output_parameters::fix_output_parameters
(ptx.o, angr 9.2.213). Analysis: analysis.md · approved proposal:
proposal.md.

The gap

ptx.o is a relocatable ELF object (ET_REL) with no PT_LOAD program headers. kuna's
faithful LoadImageBfd port (kuna-analysis/loadimage_object.rs) builds its byte map only from
PT_LOAD segments, so a .o mapped zero bytes and every function failed to lift
(Unable to load N bytes at ...) — kuna emitted no output at all. angr's CLE ELF relocatable
backend decompiles it fully with resolved names.

Mechanism

A new kuna file kuna-analysis/src/s1_loader/elf_reloc.rs. For an ET_REL object
(kind()==Relocatable + empty segments()), ObjectLoadImage::from_bytes takes a new
from_relocatable path that:

  1. lays out each SHF_ALLOC section at a non-overlapping VMA above 0x400000 (angr's CLE
    default — fix_output_parameters lands at 0x400660, matching angr), respecting alignment;
    .bss/NOBITS is zero-filled;
  2. applies the .rela.* relocations into the snapshotted bytes — R_X86_64_PC32/PLT32
    (S + A − P), R_X86_64_64/32/32S (S + A); an unhandled kind degrades with a logged
    warning rather than miscompiling;
  3. rebases defined symbols to their load VMA and binds undefined externs (PLT-relative call
    targets are named even when gcc emits them STT_NOTYPE) to synthetic addresses, so calls render
    by name (strlen(...), __sprintf_chk(...), __ctype_b_loc(...), …).

The linked ET_EXEC/ET_DYN PT_LOAD path is untouched (byte-identical).

Option

relocobjects (default on — it only affects .o files, which the loader otherwise cannot load
at all). The loader runs at load file, upstream of the per-function option machinery, so the
toggle is bridged to the loader by the KUNA_RELOC_OBJECTS (RELOC_OBJECTS_ENV) process env var
that Architecture::set_kuna_option and kuna decompile write:

kuna decompile ptx.o fix_output_parameters                       # default: loads + decompiles
kuna decompile ptx.o fix_output_parameters --option relocobjects off   # upstream PT_LOAD-only loader (errors)
KUNA_RELOC_OBJECTS=0 kuna decompile ptx.o fix_output_parameters         # same, via env

Discoverable via kuna catalog --json (source_decompiler: angr, change_kind: structure-recovery). New divergence DIV-7.

Ablation / parity / speed

  • 0 of 675 upstream datatest assertions change — the XML datatest path never constructs an
    ObjectLoadImage, and the linked-ELF path is byte-identical. make test → PARITY OK.
  • make test-stages → PARITY OK (159/159; the two kuna-catalog.xml provenance counts bumped
    3→4 angr / 2→3 structure-recovery for the new settable).
  • Speed within budget: median fix_output_parameters decompile −6.97% (on vs the off/error
    path), well under the +5% budget; the layout+relocation work is a one-time O(sections+relocs) pass
    at load.

Tests

Cargo workspace (make rust-test) — no XML stage test is possible for a loader feature (the
datatest path bypasses ObjectLoadImage entirely):

  • s1_loader::elf_reloc — a hand-assembled ET_REL exercising section layout + each relocation
    kind + defined/extern symbol binding;
  • loadimage_object — the vendored real ptx.o fixture: fix_output_parameters rebases to
    0x400660, its bytes load, and externs (strlen/dcgettext/error) resolve.

Note: make rust-test has one pre-existing failure on this branch
(verify_w10_proto_unlock's const-return direction-check, a stale DIV-6 oracle assertion) that
fails identically on the base commit and is unrelated to this feature; left untouched.

🤖 Generated with Claude Code


Before / after — fix_output_parameters in ptx.o

Real captured kuna output on the function this feature was built for, with option relocobjects flipped. Ported from angr — test_decompiling_ptx_fix_output_parameters; CLE ELF relocatable backend; fix_output_parameters.

metric relocobjects off relocobjects on (default)
gotos 34 34
labels 28 28
loc 661 661
switches 0 0
speed 1089.32 ms 1013.4 ms — Δ -6.97% (budget 5.0%)
kuna — before (option relocobjects off)
void fix_output_parameters(void)

{
  char *v1;
  char v10; // dl
  char v11; // dl
  char v12; // dl
  char v13; // dl
  char v14; // dl
  int8 v15; // rdx
  int8 v16; // rdx
  char *v17;
  char *v18; // rdx
  char *v19; // rdx
  uint1 v2; // al
  int8 v20; // rdx
  char *v21;
  char *v22; // rdx
  int8 v23; // rdx
  int8 v24; // rdx
  unsigned long v25; // rdx
  int8 v26; // rdx
  char *v27; // rdx
  char *v28; // rdx
  int8 v29; // rdx
  int4 v3;
  int8 v30; // rdx
  int8 v31; // rdx
  int8 v32;
  char *v33;
  char v34 [24];
  char v35;
  int8 v36;
  char *v37;
  char *v38;
  char *v39;
  int8 *v4; // rax
  uint8 v40;
  uint8 v41; // r14
  char *v42;
  char *v43;
  int8 v44; // fs_offset
  bool v45; // al
  char *v46; // stack - 0xe0
  char *v47; // stack - 0xd8
  char *v48; // stack - 0xc8
  char *v49; // stack - 0xa8
  void *v5; // rax
  char *v50; // stack - 0xa0
  char *v51; // stack - 0x98
  char *v52; // stack - 0x90
  char *v53; // stack - 0x88
  int8 v54; // stack - 0x30
  char v6;
  char *v7; // rcx
  char *v8; // rcx
  char *v9;
  
label_400ffa:
  if (v42 < v9) {
    dat_402e10 = 0;
    AL = dat_404c48 != (char *)0x0 && v7 < v42;
    v4 = (int8 *)__ctype_b_loc();
    v25 = 0;
    v32 = *v4;
    while (v2 = to_uchar((int4)*v42,v51,v25), (*(uint1 *)(v32 + 1 + (uint8)v2 * 2) & 0x20) != 0) {
      v42 = &v42[1];
      v25 = 1;
      if (v42 == v9) {
        Unique10000c0e = v42;
        goto label_40100a;
      }
      v51 = v42;
    }
    v6 = dat_403529;
    if (v14 != '\0') goto label_401199;
  }
  else {
label_401003:
    dat_402dd0 = 0;
  }
label_40100a:
  v51 = dat_402de0;
  v6 = dat_403529;
label_401199:
  Unique1000069b = v51;
  Unique10000e91 = v6;
  if (Unique1000075c == '\0') {
    if (v6 != '\0') {
      v38 = &Unique100006ce[*(int8 *)&v38[0x20]];
      Unique10000bae = v38;
      Unique10000bce = v38;
      if (v38 < v8) {
        v4 = (int8 *)__ctype_b_loc();
        v32 = *v4;
        v35 = '\0';
        while (v2 = to_uchar((int4)*v38,v53,v32), (*(uint1 *)(v26 + 1 + (uint8)v2 * 2) & 0x20) == 0) {
          v38 = &v38[1];
          if (v38 == v8) {
            dat_402dc8 = v38;
            return;
          }
          v32 = v26;
          v53 = v38;
          v35 = v6;
        }
        if (v35 != '\0') {
          Unique10000bde = v53;
        }
      }
    }
  }
  else {
    v3 = *(int4 *)&v38[0x28];
    v32 = *(int8 *)(Unique10000732 + (int8)v3 * 8);
    if (v32 == 0) {
      v32 = 0x404025;
    }
    v36 = *(int8 *)&v38[0x20] + 1;
    if (1 <= v3) {
      v36 = v36 - Unique1000072a[(int8)v3 + -1];
    }
    v32 = stpcpy(Unique100006b4,v32);
    v3 = __sprintf_chk(v32,1,0xffffffffffffffff,0x404026,v36);
    Unique10000bbe = (char *)(v32 + v3);
  }
  return;
  v54 = *(int8 *)(v44 + 0x28);
  if (dat_40352a == '\0') {
label_400689:
    if (dat_403529 == '\0') goto label_400696;
  }
  else {
    dat_402ff8 = 0;
    if (dat_402fb8 != 0) {
      v32 = *dat_402fa0 + 1;
      v40 = 0;
      while( true ) {
        v39 = (char *)(v40 * 8);
        v3 = __sprintf_chk(v34,1,0x15,0x404021,v32);
        v32 = (int8)v3;
        if (*(int8 *)&v39[dat_402fa8] != 0) {
          v32 = strlen();
          v32 = v3 + v32;
        }
        if (dat_402ff8 < v32) {
          Unique10000dc8 = v32;
        }
        v41 = v40 + 1;
        if ((uint8)(int8)dat_402fb8 <= v41) break;
        v32 = (&dat_402fa0[1])[v40] + 1;
        if (v41 != 0) {
          v32 = v32 - dat_402fa0[v40];
        }
        v40 = v41;
      }
    }
    v32 = dat_402ff8 + 1;
    v36 = dat_402ff8 + 2;
    Unique10000db8 = v32;
    RAX = (char *)xmalloc(v36);
    if (dat_40352a == '\0') goto label_400689;
  }
  if (dat_403528 == '\0') {
    RAX = dat_402da8 - (int8)&dat_402da0[dat_402ff8];
  }
label_400696:
  v38 = dat_404c48;
  if (dat_402da8 <= -1) {
    dat_402da8 = 0;
  }
  v32 = dat_402da8 / 2;
  v36 = v32 - (int8)dat_402da0;
  Unique10000e81 = v36;
  Unique10000e89 = v32;
  if ((dat_404c48 == (char *)0x0) || (*dat_404c48 == '\0')) {
    dat_404c48 = (char *)0x0;
  }
  else {
    Unique10000d88 = (char *)v32;
    RAX = strlen();
  }
  if (dat_402db0 == '\0') {
    v36 = -(dat_402e50 * 2 + 1);
  }
  else {
    RBP = v36 + dat_402e50 * -2;
    if (RBP <= -1) {
      RBP = 0;
    }
    v36 = dat_402e50 * -2;
  }
  Unique10000d90 = (char *)(v32 + v36);
  v4 = (int8 *)__ctype_b_loc();
  v15 = 0;
  v36 = 0x402e80;
  v32 = *v4;
  do {
    *(uint1 *)(v15 + 0x402e80) = SUB21(*(void *)(v32 + v15 * 2),1) >> 5 & 1;
    v15 = v15 + 1;
  } while (v15 != 0x100);
  dat_402e8c = 1;
  if (dat_403524 == 2) {
    dat_402ea2 = 1;
  }
  else if (dat_403524 == 3) {
    v38 = (char *)0x24;
    do {
      v2 = to_uchar(v38);
      v6 = *(char *)(v16 + 1);
      v38 = (char *)(uint8)(uint4)(int4)v6;
      *(void *)(v36 + (uint8)v2) = 1;
    } while (v6 != '\0');
  }
  if (v54 == *(int8 *)(v44 + 0x28)) {
    return;
  }
  __stack_chk_fail();
  v9 = *(char **)v38;
  v47 = *(char **)&v38[0x10];
  v7 = &v47[(int8)v9];
  v42 = &v9[*(int8 *)&v38[8]];
  v5 = (void *)((int8)*(int4 *)&v38[0x28] * 0x10 + dat_402f98);
  v17 = &dat_402e58[(int8)v9];
  v1 = (char *)*v5;
  v33 = (char *)v5[1];
  v8 = &v9[*(int8 *)&v38[0x18]];
  Unique10000e51 = v9;
  Unique10000e59 = v42;
  if (v42 < v8) {
    v37 = (char *)0x403020;
    v21 = v17;
    do {
      v17 = v21;
      if (v17 < v42) {
        v47 = *(char **)&v38[0x10];
        v42 = dat_402e08;
        goto label_400a78;
      }
      Unique10000e61 = v42;
      if (dat_403260 == 0) {
        v2 = to_uchar((int4)*v42);
        if (*(char *)((uint8)v2 + 0x403020) == '\0') {
          v42 = &v42[1];
          v21 = v18;
        }
        else {
          if (v8 <= v42) {
            v47 = *(char **)&v38[0x10];
            goto label_400a71;
          }
          do {
            v42 = &v42[1];
            if (v8 == v42) goto label_400a54;
            v2 = to_uchar((int4)*v42);
            v21 = v19;
          } while (*(char *)((uint8)v2 + 0x403020) != '\0');
        }
      }
      else {
        v3 = re_match(0x403268,v42,(int4)v8 - (int4)v42,0,0);
        if (v3 == -2) goto label_401578;
        if (v3 == -1) {
          v3 = 1;
        }
        v17 = &dat_402e58[(int8)dat_402e00];
        v42 = &v42[v3];
        v21 = v17;
        v9 = dat_402e00;
      }
    } while (v42 < v8);
label_400a54:
    v47 = *(char **)&v38[0x10];
  }
  if (v17 < v42) {
    v42 = dat_402e08;
  }
  else {
label_400a71:
    Unique10000cae = v42;
  }
label_400a78:
  AL = dat_404c48 != (char *)0x0 && v42 < v8;
  if (v9 < v42) {
    __ctype_b_loc();
    v6 = '\0';
    do {
      v42 = &v42[-1];
      v2 = to_uchar((int4)*v42);
      if ((*(uint1 *)(v20 + 1 + (uint8)v2 * 2) & 0x20) == 0) {
        if (v6 != '\0') {
          Unique10000c86 = v39;
        }
        goto label_400ae9;
      }
      v6 = '\x01';
      v39 = v42;
    } while (v9 != v42);
    Unique10000c8e = v9;
  }
label_400ae9:
  v32 = dat_403000 + dat_402e68;
  if ((char *)-v32 == v47 || -(int8)v47 < v32) {
    v42 = &v47[(int8)v9];
  }
  else {
    v42 = &v9[-v32];
    if (dat_403260 == 0) {
      v2 = to_uchar((int4)*v42);
      if (*(char *)(v30 + (uint8)v2) == '\0') {
        v42 = &v42[1];
      }
      else if (v42 < v9) {
        do {
          v42 = &v42[1];
          if (v42 == v9) goto label_400b49;
          v2 = to_uchar((int4)*v42);
        } while (*(char *)(v31 + (uint8)v2) != '\0');
      }
    }
    else {
      v3 = re_match(0x403268,v42,v32,0,0);
      v37 = v42;
      if (v3 == -2) goto label_401578;
      if (v3 == -1) {
        v3 = 1;
      }
      v42 = &v42[v3];
    }
  }
label_400b49:
  v9 = dat_402e00;
  dat_402e28 = dat_402e00;
  Unique10000e69 = v42;
  if (v42 < dat_402e00) {
    v4 = (int8 *)__ctype_b_loc();
    v25 = 0;
    v32 = *v4;
    v21 = (char *)(v32 + v36);
    v17 = v9;
    do {
      v17 = &v17[-1];
      v2 = to_uchar((int4)*v17,v21,v25);
      if ((*(uint1 *)(v32 + 1 + (uint8)v2 * 2) & 0x20) == 0) {
        if (v10 != '\0') {
          v9 = v21;
          Unique10000d28 = v21;
        }
        goto label_400bbb;
      }
      v25 = 1;
      v21 = v17;
    } while (v42 != v17);
    v9 = v17;
    Unique10000d30 = v42;
  }
label_400bbb:
  v32 = dat_402e60;
  v17 = v42;
  if (&v42[dat_402e60] < v9) {
    v21 = v48;
    do {
label_400c39:
      if (dat_403260 == 0) {
        v36 = 0x403020;
        v2 = to_uchar((int4)*v17);
        if (*(char *)(v36 + (uint8)v2) == '\0') {
          v17 = &v17[1];
          v9 = dat_402e28;
          Unique10000cf0 = v17;
          if (&v17[v32] >= dat_402e28) goto label_400c77;
          goto label_400c39;
        }
        v6 = '\0';
        v17 = dat_402e20;
        v37 = dat_402e20;
        if (dat_402e20 < v9) {
          while (v2 = to_uchar((int4)*v17), *(char *)((uint8)v2 + 0x403020) != '\0') {
            v17 = (char *)(v23 + 1);
            v6 = '\x01';
            if (v17 == v9) {
              Unique10000cd0 = v17;
              goto label_400c29;
            }
            v21 = v17;
          }
          v17 = v37;
          if (v6 != '\0') {
            v17 = v21;
            Unique10000cc8 = v21;
          }
        }
      }
      else {
        v3 = re_match(0x403268);
        v37 = v42;
        if (v3 == -2) goto label_401578;
        if (v3 == -1) {
          v3 = 1;
        }
        RSI = &dat_402e20[v3];
        v17 = RSI;
        v32 = dat_402e60;
      }
label_400c29:
      v9 = dat_402e28;
    } while (dat_402e28 > &v17[v32]);
label_400c77:
    v9 = dat_402e28;
  }
  v45 = 0;
  if (dat_404c48 != (char *)0x0) {
    if (v1 < v17) {
      v4 = (int8 *)__ctype_b_loc();
      v36 = *v4;
      v21 = v17;
      v37 = v1;
      do {
        v2 = to_uchar((int4)v21[-1]);
        v21 = v22;
        if ((*(uint1 *)(v36 + 1 + (uint8)v2 * 2) & 0x20) == 0) goto label_400cc4;
        v21 = &v22[-1];
      } while (v37 != v21);
    }
    else {
      v21 = v17;
    }
label_400cc4:
    v45 = v7 < v21;
  }
  Unique10000cb7 = v45;
  if (v17 < v33) {
    v4 = (int8 *)__ctype_b_loc();
    v36 = *v4;
    v21 = v33;
    do {
      v2 = to_uchar((int4)*v17);
      if ((*(uint1 *)(v36 + 1 + (uint8)v2 * 2) & 0x20) == 0) {
        if (v11 != '\0') {
          Unique10000cd8 = v49;
        }
        goto label_400d23;
      }
      v49 = &v17[1];
      v17 = v49;
    } while (v49 != v21);
    Unique10000ce0 = v49;
  }
label_400d23:
  v21 = dat_402e08;
  v48 = dat_402da0;
  v32 = (v32 - ((int8)v9 - (int8)v17)) - (int8)dat_402da0;
  v47 = dat_402e08;
  if (v32 <= 0) {
    dat_402e40 = (char *)0x0;
    dat_402e48 = (char *)0x0;
    goto label_400ea6;
  }
  dat_402e40 = dat_402e08;
  if (dat_402e08 < v33) {
    v4 = (int8 *)__ctype_b_loc();
    v25 = 0;
    v36 = *v4;
    v37 = v21;
    do {
      v2 = to_uchar((int4)*v37,v46,v25);
      if ((*(uint1 *)(v36 + 1 + (uint8)v2 * 2) & 0x20) == 0) {
        if (v12 == '\0') {
          v46 = v21;
        }
        else {
          Unique10000d38 = v46;
        }
        goto label_40127f;
      }
      v46 = &v37[1];
      v25 = 1;
      v37 = v46;
    } while (v46 != v33);
    Unique10000d40 = v46;
  }
  else {
    v46 = dat_402e08;
    v37 = dat_402e08;
  }
label_40127f:
  v9 = &v46[v32];
  Unique10000e79 = v37;
  if (v37 < v8) {
    v33 = v9;
    v17 = v46;
    do {
      v9 = v33;
      if (v9 <= v37) {
        v47 = dat_402e08;
        v48 = dat_402da0;
        v37 = dat_402e48;
        v46 = v17;
        goto label_4013a0;
      }
      Unique10000e71 = v37;
      if (dat_403260 == 0) {
        v2 = to_uchar((int4)*v37);
        if (*(char *)((uint8)v2 + 0x403020) == '\0') {
          v37 = &v37[1];
          v33 = v27;
        }
        else {
          if (v8 <= v37) {
            v47 = dat_402e08;
            v48 = dat_402da0;
            v46 = v17;
            goto label_401399;
          }
          do {
            v37 = &v37[1];
            if (v8 == v37) goto label_40136b;
            v2 = to_uchar((int4)*v37);
            v33 = v28;
          } while (*(char *)((uint8)v2 + 0x403020) != '\0');
        }
      }
      else {
        v3 = re_match(0x403268,v37,(int4)v8 - (int4)v37,0,0);
        v47 = v42;
        if (v3 == -2) goto label_401578;
        if (v3 == -1) {
          v3 = 1;
        }
        v9 = &dat_402e40[v32];
        v37 = &v37[v3];
        v33 = v9;
        v17 = dat_402e40;
      }
    } while (v37 < v8);
label_40136b:
    v47 = dat_402e08;
    v48 = dat_402da0;
    v46 = v17;
  }
  if (v9 <= v37) goto label_40157d;
label_401399:
  Unique10000d70 = v37;
  do {
label_4013a0:
    if (v46 < v37) {
      dat_402df0 = 0;
      AL = dat_404c48 != (char *)0x0 && v37 < v8;
      v4 = (int8 *)__ctype_b_loc();
      v6 = '\0';
      v32 = *v4;
      v9 = v52;
      v33 = v46;
      while( true ) {
        v37 = &v37[-1];
        v17 = v37;
        v2 = to_uchar((int4)*v37,v37,v32);
        if ((*(uint1 *)(v29 + 1 + (uint8)v2 * 2) & 0x20) == 0) break;
        v6 = '\x01';
        if (v33 == v37) {
          dat_402e48 = v46;
          goto label_400ead;
        }
        v32 = v29;
        v9 = v17;
      }
      if (v6 != '\0') {
        Unique10000d80 = v9;
      }
    }
    else {
label_400ea6:
      dat_402e30 = 0;
    }
label_400ead:
    v9 = dat_402e20;
    v33 = &dat_402e58[-(int8)v48 - ((int8)v47 - (int8)dat_402e00)];
    if ((int8)v33 <= 0) {
      dat_402de0 = (char *)0x0;
      dat_402de8 = (char *)0x0;
      goto label_401003;
    }
    dat_402de8 = dat_402e20;
    if (v1 < dat_402e20) {
      v4 = (int8 *)__ctype_b_loc();
      v25 = 0;
      v32 = *v4;
      v21 = v1;
      v17 = v9;
      do {
        v17 = &v17[-1];
        v2 = to_uchar((int4)*v17,v43,v25);
        if ((*(uint1 *)(v32 + 1 + (uint8)v2 * 2) & 0x20) == 0) {
          if (v13 != '\0') {
            v9 = v43;
            Unique10000c3e = v43;
          }
          goto label_400f43;
        }
        v25 = 1;
        v43 = v17;
      } while (v21 != v17);
      v9 = v17;
      Unique10000c46 = v17;
    }
label_400f43:
    Unique10000c2e = v42;
    if (v9 <= &v42[(int8)v33]) goto label_400ffa;
    v37 = v50;
    v43 = v9;
    while (
label_400fbf:dat_403260 == 0) {
      v2 = to_uchar((int4)*v42);
      if (*(char *)((uint8)v2 + 0x403020) != '\0') {
        v6 = '\0';
        v42 = dat_402de0;
        v9 = dat_402de0;
        if (dat_402de0 < v43) {
          while (v2 = to_uchar((int4)*v42), *(char *)((uint8)v2 + 0x403020) != '\0') {
            v42 = (char *)(v24 + 1);
            v6 = '\x01';
            if (v42 == v43) {
              Unique10000bf6 = v42;
              goto label_400faf;
            }
            v37 = v42;
          }
          v42 = v9;
          if (v6 != '\0') {
            v42 = v37;
            Unique10000bee = v37;
          }
        }
        goto label_400faf;
      }
      v42 = &v42[1];
      v43 = dat_402de8;
      Unique10000c1e = v42;
      if (dat_402de8 <= &v42[(int8)v33]) {
label_400ff7:
        v9 = dat_402de8;
        goto label_400ffa;
      }
    }
    v3 = re_match(0x403268);
    if (v3 != -2) {
      if (v3 == -1) {
        v3 = 1;
      }
      RSI = &dat_402de0[v3];
      v42 = RSI;
label_400faf:
      v43 = dat_402de8;
      if (dat_402de8 <= &v42[(int8)v33]) goto label_400ff7;
      goto label_400fbf;
    }
label_401578:
    matcher_error();
    v42 = v37;
label_40157d:
    v37 = dat_402e48;
  } while( true );
}
kuna — after (option relocobjects on)
void fix_output_parameters(void)

{
  char *v1;
  char v10; // dl
  char v11; // dl
  char v12; // dl
  char v13; // dl
  char v14; // dl
  int8 v15; // rdx
  int8 v16; // rdx
  char *v17;
  char *v18; // rdx
  char *v19; // rdx
  uint1 v2; // al
  int8 v20; // rdx
  char *v21;
  char *v22; // rdx
  int8 v23; // rdx
  int8 v24; // rdx
  unsigned long v25; // rdx
  int8 v26; // rdx
  char *v27; // rdx
  char *v28; // rdx
  int8 v29; // rdx
  int4 v3;
  int8 v30; // rdx
  int8 v31; // rdx
  int8 v32;
  char *v33;
  char v34 [24];
  char v35;
  int8 v36;
  char *v37;
  char *v38;
  char *v39;
  int8 *v4; // rax
  uint8 v40;
  uint8 v41; // r14
  char *v42;
  char *v43;
  int8 v44; // fs_offset
  bool v45; // al
  char *v46; // stack - 0xe0
  char *v47; // stack - 0xd8
  char *v48; // stack - 0xc8
  char *v49; // stack - 0xa8
  void *v5; // rax
  char *v50; // stack - 0xa0
  char *v51; // stack - 0x98
  char *v52; // stack - 0x90
  char *v53; // stack - 0x88
  int8 v54; // stack - 0x30
  char v6;
  char *v7; // rcx
  char *v8; // rcx
  char *v9;
  
label_400ffa:
  if (v42 < v9) {
    dat_402e10 = 0;
    AL = dat_404c48 != (char *)0x0 && v7 < v42;
    v4 = (int8 *)__ctype_b_loc();
    v25 = 0;
    v32 = *v4;
    while (v2 = to_uchar((int4)*v42,v51,v25), (*(uint1 *)(v32 + 1 + (uint8)v2 * 2) & 0x20) != 0) {
      v42 = &v42[1];
      v25 = 1;
      if (v42 == v9) {
        Unique10000c0e = v42;
        goto label_40100a;
      }
      v51 = v42;
    }
    v6 = dat_403529;
    if (v14 != '\0') goto label_401199;
  }
  else {
label_401003:
    dat_402dd0 = 0;
  }
label_40100a:
  v51 = dat_402de0;
  v6 = dat_403529;
label_401199:
  Unique1000069b = v51;
  Unique10000e91 = v6;
  if (Unique1000075c == '\0') {
    if (v6 != '\0') {
      v38 = &Unique100006ce[*(int8 *)&v38[0x20]];
      Unique10000bae = v38;
      Unique10000bce = v38;
      if (v38 < v8) {
        v4 = (int8 *)__ctype_b_loc();
        v32 = *v4;
        v35 = '\0';
        while (v2 = to_uchar((int4)*v38,v53,v32), (*(uint1 *)(v26 + 1 + (uint8)v2 * 2) & 0x20) == 0) {
          v38 = &v38[1];
          if (v38 == v8) {
            dat_402dc8 = v38;
            return;
          }
          v32 = v26;
          v53 = v38;
          v35 = v6;
        }
        if (v35 != '\0') {
          Unique10000bde = v53;
        }
      }
    }
  }
  else {
    v3 = *(int4 *)&v38[0x28];
    v32 = *(int8 *)(Unique10000732 + (int8)v3 * 8);
    if (v32 == 0) {
      v32 = 0x404025;
    }
    v36 = *(int8 *)&v38[0x20] + 1;
    if (1 <= v3) {
      v36 = v36 - Unique1000072a[(int8)v3 + -1];
    }
    v32 = stpcpy(Unique100006b4,v32);
    v3 = __sprintf_chk(v32,1,0xffffffffffffffff,0x404026,v36);
    Unique10000bbe = (char *)(v32 + v3);
  }
  return;
  v54 = *(int8 *)(v44 + 0x28);
  if (dat_40352a == '\0') {
label_400689:
    if (dat_403529 == '\0') goto label_400696;
  }
  else {
    dat_402ff8 = 0;
    if (dat_402fb8 != 0) {
      v32 = *dat_402fa0 + 1;
      v40 = 0;
      while( true ) {
        v39 = (char *)(v40 * 8);
        v3 = __sprintf_chk(v34,1,0x15,0x404021,v32);
        v32 = (int8)v3;
        if (*(int8 *)&v39[dat_402fa8] != 0) {
          v32 = strlen();
          v32 = v3 + v32;
        }
        if (dat_402ff8 < v32) {
          Unique10000dc8 = v32;
        }
        v41 = v40 + 1;
        if ((uint8)(int8)dat_402fb8 <= v41) break;
        v32 = (&dat_402fa0[1])[v40] + 1;
        if (v41 != 0) {
          v32 = v32 - dat_402fa0[v40];
        }
        v40 = v41;
      }
    }
    v32 = dat_402ff8 + 1;
    v36 = dat_402ff8 + 2;
    Unique10000db8 = v32;
    RAX = (char *)xmalloc(v36);
    if (dat_40352a == '\0') goto label_400689;
  }
  if (dat_403528 == '\0') {
    RAX = dat_402da8 - (int8)&dat_402da0[dat_402ff8];
  }
label_400696:
  v38 = dat_404c48;
  if (dat_402da8 <= -1) {
    dat_402da8 = 0;
  }
  v32 = dat_402da8 / 2;
  v36 = v32 - (int8)dat_402da0;
  Unique10000e81 = v36;
  Unique10000e89 = v32;
  if ((dat_404c48 == (char *)0x0) || (*dat_404c48 == '\0')) {
    dat_404c48 = (char *)0x0;
  }
  else {
    Unique10000d88 = (char *)v32;
    RAX = strlen();
  }
  if (dat_402db0 == '\0') {
    v36 = -(dat_402e50 * 2 + 1);
  }
  else {
    RBP = v36 + dat_402e50 * -2;
    if (RBP <= -1) {
      RBP = 0;
    }
    v36 = dat_402e50 * -2;
  }
  Unique10000d90 = (char *)(v32 + v36);
  v4 = (int8 *)__ctype_b_loc();
  v15 = 0;
  v36 = 0x402e80;
  v32 = *v4;
  do {
    *(uint1 *)(v15 + 0x402e80) = SUB21(*(void *)(v32 + v15 * 2),1) >> 5 & 1;
    v15 = v15 + 1;
  } while (v15 != 0x100);
  dat_402e8c = 1;
  if (dat_403524 == 2) {
    dat_402ea2 = 1;
  }
  else if (dat_403524 == 3) {
    v38 = (char *)0x24;
    do {
      v2 = to_uchar(v38);
      v6 = *(char *)(v16 + 1);
      v38 = (char *)(uint8)(uint4)(int4)v6;
      *(void *)(v36 + (uint8)v2) = 1;
    } while (v6 != '\0');
  }
  if (v54 == *(int8 *)(v44 + 0x28)) {
    return;
  }
  __stack_chk_fail();
  v9 = *(char **)v38;
  v47 = *(char **)&v38[0x10];
  v7 = &v47[(int8)v9];
  v42 = &v9[*(int8 *)&v38[8]];
  v5 = (void *)((int8)*(int4 *)&v38[0x28] * 0x10 + dat_402f98);
  v17 = &dat_402e58[(int8)v9];
  v1 = (char *)*v5;
  v33 = (char *)v5[1];
  v8 = &v9[*(int8 *)&v38[0x18]];
  Unique10000e51 = v9;
  Unique10000e59 = v42;
  if (v42 < v8) {
    v37 = (char *)0x403020;
    v21 = v17;
    do {
      v17 = v21;
      if (v17 < v42) {
        v47 = *(char **)&v38[0x10];
        v42 = dat_402e08;
        goto label_400a78;
      }
      Unique10000e61 = v42;
      if (dat_403260 == 0) {
        v2 = to_uchar((int4)*v42);
        if (*(char *)((uint8)v2 + 0x403020) == '\0') {
          v42 = &v42[1];
          v21 = v18;
        }
        else {
          if (v8 <= v42) {
            v47 = *(char **)&v38[0x10];
            goto label_400a71;
          }
          do {
            v42 = &v42[1];
            if (v8 == v42) goto label_400a54;
            v2 = to_uchar((int4)*v42);
            v21 = v19;
          } while (*(char *)((uint8)v2 + 0x403020) != '\0');
        }
      }
      else {
        v3 = re_match(0x403268,v42,(int4)v8 - (int4)v42,0,0);
        if (v3 == -2) goto label_401578;
        if (v3 == -1) {
          v3 = 1;
        }
        v17 = &dat_402e58[(int8)dat_402e00];
        v42 = &v42[v3];
        v21 = v17;
        v9 = dat_402e00;
      }
    } while (v42 < v8);
label_400a54:
    v47 = *(char **)&v38[0x10];
  }
  if (v17 < v42) {
    v42 = dat_402e08;
  }
  else {
label_400a71:
    Unique10000cae = v42;
  }
label_400a78:
  AL = dat_404c48 != (char *)0x0 && v42 < v8;
  if (v9 < v42) {
    __ctype_b_loc();
    v6 = '\0';
    do {
      v42 = &v42[-1];
      v2 = to_uchar((int4)*v42);
      if ((*(uint1 *)(v20 + 1 + (uint8)v2 * 2) & 0x20) == 0) {
        if (v6 != '\0') {
          Unique10000c86 = v39;
        }
        goto label_400ae9;
      }
      v6 = '\x01';
      v39 = v42;
    } while (v9 != v42);
    Unique10000c8e = v9;
  }
label_400ae9:
  v32 = dat_403000 + dat_402e68;
  if ((char *)-v32 == v47 || -(int8)v47 < v32) {
    v42 = &v47[(int8)v9];
  }
  else {
    v42 = &v9[-v32];
    if (dat_403260 == 0) {
      v2 = to_uchar((int4)*v42);
      if (*(char *)(v30 + (uint8)v2) == '\0') {
        v42 = &v42[1];
      }
      else if (v42 < v9) {
        do {
          v42 = &v42[1];
          if (v42 == v9) goto label_400b49;
          v2 = to_uchar((int4)*v42);
        } while (*(char *)(v31 + (uint8)v2) != '\0');
      }
    }
    else {
      v3 = re_match(0x403268,v42,v32,0,0);
      v37 = v42;
      if (v3 == -2) goto label_401578;
      if (v3 == -1) {
        v3 = 1;
      }
      v42 = &v42[v3];
    }
  }
label_400b49:
  v9 = dat_402e00;
  dat_402e28 = dat_402e00;
  Unique10000e69 = v42;
  if (v42 < dat_402e00) {
    v4 = (int8 *)__ctype_b_loc();
    v25 = 0;
    v32 = *v4;
    v21 = (char *)(v32 + v36);
    v17 = v9;
    do {
      v17 = &v17[-1];
      v2 = to_uchar((int4)*v17,v21,v25);
      if ((*(uint1 *)(v32 + 1 + (uint8)v2 * 2) & 0x20) == 0) {
        if (v10 != '\0') {
          v9 = v21;
          Unique10000d28 = v21;
        }
        goto label_400bbb;
      }
      v25 = 1;
      v21 = v17;
    } while (v42 != v17);
    v9 = v17;
    Unique10000d30 = v42;
  }
label_400bbb:
  v32 = dat_402e60;
  v17 = v42;
  if (&v42[dat_402e60] < v9) {
    v21 = v48;
    do {
label_400c39:
      if (dat_403260 == 0) {
        v36 = 0x403020;
        v2 = to_uchar((int4)*v17);
        if (*(char *)(v36 + (uint8)v2) == '\0') {
          v17 = &v17[1];
          v9 = dat_402e28;
          Unique10000cf0 = v17;
          if (&v17[v32] >= dat_402e28) goto label_400c77;
          goto label_400c39;
        }
        v6 = '\0';
        v17 = dat_402e20;
        v37 = dat_402e20;
        if (dat_402e20 < v9) {
          while (v2 = to_uchar((int4)*v17), *(char *)((uint8)v2 + 0x403020) != '\0') {
            v17 = (char *)(v23 + 1);
            v6 = '\x01';
            if (v17 == v9) {
              Unique10000cd0 = v17;
              goto label_400c29;
            }
            v21 = v17;
          }
          v17 = v37;
          if (v6 != '\0') {
            v17 = v21;
            Unique10000cc8 = v21;
          }
        }
      }
      else {
        v3 = re_match(0x403268);
        v37 = v42;
        if (v3 == -2) goto label_401578;
        if (v3 == -1) {
          v3 = 1;
        }
        RSI = &dat_402e20[v3];
        v17 = RSI;
        v32 = dat_402e60;
      }
label_400c29:
      v9 = dat_402e28;
    } while (dat_402e28 > &v17[v32]);
label_400c77:
    v9 = dat_402e28;
  }
  v45 = 0;
  if (dat_404c48 != (char *)0x0) {
    if (v1 < v17) {
      v4 = (int8 *)__ctype_b_loc();
      v36 = *v4;
      v21 = v17;
      v37 = v1;
      do {
        v2 = to_uchar((int4)v21[-1]);
        v21 = v22;
        if ((*(uint1 *)(v36 + 1 + (uint8)v2 * 2) & 0x20) == 0) goto label_400cc4;
        v21 = &v22[-1];
      } while (v37 != v21);
    }
    else {
      v21 = v17;
    }
label_400cc4:
    v45 = v7 < v21;
  }
  Unique10000cb7 = v45;
  if (v17 < v33) {
    v4 = (int8 *)__ctype_b_loc();
    v36 = *v4;
    v21 = v33;
    do {
      v2 = to_uchar((int4)*v17);
      if ((*(uint1 *)(v36 + 1 + (uint8)v2 * 2) & 0x20) == 0) {
        if (v11 != '\0') {
          Unique10000cd8 = v49;
        }
        goto label_400d23;
      }
      v49 = &v17[1];
      v17 = v49;
    } while (v49 != v21);
    Unique10000ce0 = v49;
  }
label_400d23:
  v21 = dat_402e08;
  v48 = dat_402da0;
  v32 = (v32 - ((int8)v9 - (int8)v17)) - (int8)dat_402da0;
  v47 = dat_402e08;
  if (v32 <= 0) {
    dat_402e40 = (char *)0x0;
    dat_402e48 = (char *)0x0;
    goto label_400ea6;
  }
  dat_402e40 = dat_402e08;
  if (dat_402e08 < v33) {
    v4 = (int8 *)__ctype_b_loc();
    v25 = 0;
    v36 = *v4;
    v37 = v21;
    do {
      v2 = to_uchar((int4)*v37,v46,v25);
      if ((*(uint1 *)(v36 + 1 + (uint8)v2 * 2) & 0x20) == 0) {
        if (v12 == '\0') {
          v46 = v21;
        }
        else {
          Unique10000d38 = v46;
        }
        goto label_40127f;
      }
      v46 = &v37[1];
      v25 = 1;
      v37 = v46;
    } while (v46 != v33);
    Unique10000d40 = v46;
  }
  else {
    v46 = dat_402e08;
    v37 = dat_402e08;
  }
label_40127f:
  v9 = &v46[v32];
  Unique10000e79 = v37;
  if (v37 < v8) {
    v33 = v9;
    v17 = v46;
    do {
      v9 = v33;
      if (v9 <= v37) {
        v47 = dat_402e08;
        v48 = dat_402da0;
        v37 = dat_402e48;
        v46 = v17;
        goto label_4013a0;
      }
      Unique10000e71 = v37;
      if (dat_403260 == 0) {
        v2 = to_uchar((int4)*v37);
        if (*(char *)((uint8)v2 + 0x403020) == '\0') {
          v37 = &v37[1];
          v33 = v27;
        }
        else {
          if (v8 <= v37) {
            v47 = dat_402e08;
            v48 = dat_402da0;
            v46 = v17;
            goto label_401399;
          }
          do {
            v37 = &v37[1];
            if (v8 == v37) goto label_40136b;
            v2 = to_uchar((int4)*v37);
            v33 = v28;
          } while (*(char *)((uint8)v2 + 0x403020) != '\0');
        }
      }
      else {
        v3 = re_match(0x403268,v37,(int4)v8 - (int4)v37,0,0);
        v47 = v42;
        if (v3 == -2) goto label_401578;
        if (v3 == -1) {
          v3 = 1;
        }
        v9 = &dat_402e40[v32];
        v37 = &v37[v3];
        v33 = v9;
        v17 = dat_402e40;
      }
    } while (v37 < v8);
label_40136b:
    v47 = dat_402e08;
    v48 = dat_402da0;
    v46 = v17;
  }
  if (v9 <= v37) goto label_40157d;
label_401399:
  Unique10000d70 = v37;
  do {
label_4013a0:
    if (v46 < v37) {
      dat_402df0 = 0;
      AL = dat_404c48 != (char *)0x0 && v37 < v8;
      v4 = (int8 *)__ctype_b_loc();
      v6 = '\0';
      v32 = *v4;
      v9 = v52;
      v33 = v46;
      while( true ) {
        v37 = &v37[-1];
        v17 = v37;
        v2 = to_uchar((int4)*v37,v37,v32);
        if ((*(uint1 *)(v29 + 1 + (uint8)v2 * 2) & 0x20) == 0) break;
        v6 = '\x01';
        if (v33 == v37) {
          dat_402e48 = v46;
          goto label_400ead;
        }
        v32 = v29;
        v9 = v17;
      }
      if (v6 != '\0') {
        Unique10000d80 = v9;
      }
    }
    else {
label_400ea6:
      dat_402e30 = 0;
    }
label_400ead:
    v9 = dat_402e20;
    v33 = &dat_402e58[-(int8)v48 - ((int8)v47 - (int8)dat_402e00)];
    if ((int8)v33 <= 0) {
      dat_402de0 = (char *)0x0;
      dat_402de8 = (char *)0x0;
      goto label_401003;
    }
    dat_402de8 = dat_402e20;
    if (v1 < dat_402e20) {
      v4 = (int8 *)__ctype_b_loc();
      v25 = 0;
      v32 = *v4;
      v21 = v1;
      v17 = v9;
      do {
        v17 = &v17[-1];
        v2 = to_uchar((int4)*v17,v43,v25);
        if ((*(uint1 *)(v32 + 1 + (uint8)v2 * 2) & 0x20) == 0) {
          if (v13 != '\0') {
            v9 = v43;
            Unique10000c3e = v43;
          }
          goto label_400f43;
        }
        v25 = 1;
        v43 = v17;
      } while (v21 != v17);
      v9 = v17;
      Unique10000c46 = v17;
    }
label_400f43:
    Unique10000c2e = v42;
    if (v9 <= &v42[(int8)v33]) goto label_400ffa;
    v37 = v50;
    v43 = v9;
    while (
label_400fbf:dat_403260 == 0) {
      v2 = to_uchar((int4)*v42);
      if (*(char *)((uint8)v2 + 0x403020) != '\0') {
        v6 = '\0';
        v42 = dat_402de0;
        v9 = dat_402de0;
        if (dat_402de0 < v43) {
          while (v2 = to_uchar((int4)*v42), *(char *)((uint8)v2 + 0x403020) != '\0') {
            v42 = (char *)(v24 + 1);
            v6 = '\x01';
            if (v42 == v43) {
              Unique10000bf6 = v42;
              goto label_400faf;
            }
            v37 = v42;
          }
          v42 = v9;
          if (v6 != '\0') {
            v42 = v37;
            Unique10000bee = v37;
          }
        }
        goto label_400faf;
      }
      v42 = &v42[1];
      v43 = dat_402de8;
      Unique10000c1e = v42;
      if (dat_402de8 <= &v42[(int8)v33]) {
label_400ff7:
        v9 = dat_402de8;
        goto label_400ffa;
      }
    }
    v3 = re_match(0x403268);
    if (v3 != -2) {
      if (v3 == -1) {
        v3 = 1;
      }
      RSI = &dat_402de0[v3];
      v42 = RSI;
label_400faf:
      v43 = dat_402de8;
      if (dat_402de8 <= &v42[(int8)v33]) goto label_400ff7;
      goto label_400fbf;
    }
label_401578:
    matcher_error();
    v42 = v37;
label_40157d:
    v37 = dat_402e48;
  } while( true );
}
angr reference (the goal, v9.2.213)
typedef struct struct_0 {
    char field_0;
} struct_0;

typedef struct struct_1 {
    char padding_0[1];
    char field_1;
} struct_1;

extern char auto_reference;
extern unsigned long long before_max_width;
extern char edited_flag;
extern unsigned long gap_size;
extern char gnu_extensions;
extern unsigned long long half_line_width;
extern unsigned long input_file_name;
extern char input_reference;
extern unsigned long long keyafter_max_width;
extern unsigned long long line_width;
extern unsigned int number_input_files;
extern unsigned int output_format;
extern unsigned long long reference;
extern unsigned long long reference_max_width;
extern char right_reference;
extern unsigned long long truncation_string;
extern unsigned long long truncation_string_length;

long long fix_output_parameters(void)
{
    unsigned long v3;  // 4110
    unsigned long long v4;  // r14
    unsigned long v13;  // rbp
    unsigned long long v14;  // rax
    unsigned long long v15;  // rbp
    unsigned long v16;  // rbx
    unsigned long long *v17;  // rax
    unsigned long long cur;  // rdx
    long long v19;  // rdi
    char v20;  // al
    struct_1 *ptr;  // rdx
    unsigned long v22;  // rcx
    unsigned long long v5;  // r13
    unsigned long v23;  // fs
    unsigned int v6;  // ebx
    unsigned long v7;  // rax
    unsigned long long v8;  // rax
    unsigned long ptr;  // rax
    unsigned long v10;  // 4111
    char *v11;  // rdi
    long long v12;  // rbx
    char v0[24];  // [bp-0x48]
    unsigned long v1;  // [bp-0x30]

    if (auto_reference)
    {
        v3 = number_input_files;
        reference_max_width = 0;
        if ((unsigned int)v3)
        {
            v4 = 0;
            v5 = 0;
            while (true)
            {
                v6 = __sprintf_chk(&v0, 0x1);
                v7 = v6;
                if (*((long long *)(input_file_name + v5)))
                    v7 = v6 + strlen(*((long long *)(input_file_name + v5)));
                if (reference_max_width < v7)
                    reference_max_width = v7;
                v4 += 1;
                if (number_input_files <= v4)
                    break;
                v5 += 8;
            }
        }
        v8 = reference_max_width;
        reference_max_width = v8 + 1;
        ptr = xmalloc(v8 + 2);
        v10 = auto_reference;
        reference = ptr;
        if ((char)v10)
            goto LABEL_4008b1;
    }
    if (!input_reference)
        goto LABEL_400696;
LABEL_4008b1:
    if (!right_reference)
        line_width = line_width - (gap_size + reference_max_width);
LABEL_400696:
    if ((char)(line_width - 0 >> 63))
        line_width = 0;
    v11 = truncation_string;
    v12 = (line_width >> 63) + line_width >> 1;
    v13 = v12 - gap_size;
    half_line_width = v12;
    before_max_width = v13;
    keyafter_max_width = v12;
    if (!v11 || !*(v11))
        truncation_string = 0;
    else
        truncation_string_length = strlen(v11);
    v14 = truncation_string_length * 2;
    if (gnu_extensions)
    {
        v15 = before_max_width - v14;
        if ((char)(before_max_width - v14 >> 63))
            v15 = 0;
        v16 = v12 - v14;
        before_max_width = v15;
    }
    else
    {
        v16 = v12 - (v14 + 1);
    }
    keyafter_max_width = v16;
    v17 = __ctype_b_loc();
    cur = 0;
    do
    {
        (&edited_flag)[cur] = (char)(*((short *)(*(v17) + cur * 2)) >> 13) & 1;
        cur += 1;
    } while (cur != 0x100);
    edited_flag = 1;
    if (output_format == 2)
    {
        edited_flag = 1;
    }
    else if (output_format == 3)
    {
        v19 = 36;
        do
        {
            v20 = to_uchar(v19);
            v19 = ptr->field_1;
            *((char *)(v22 + v20)) = 1;
        } while ((char)v19);
    }
    return v1 - *((long long *)(40 + v23));
}

…t loader support

The angr testcase test_decompiling_ptx_fix_output_parameters decompiles
fix_output_parameters from ptx.o, a relocatable ELF object (ET_REL). kuna's
loader (kuna-analysis loadimage_object.rs) builds its memory map only from
PT_LOAD segments; a .o has no program headers, so the map is empty and EVERY
function fails with "Unable to load N bytes" — kuna emits zero output while
angr decompiles fully with resolved symbols.

Closing this needs loader infrastructure (synthesize segments from SHF_ALLOC
sections + apply .rela.* relocations + rebase symbols), not a single
option-gated decompiler Action/Rule. Scope decider returned "large" → this is
a [PROPOSAL] draft PR for human go/no-go, not an implementation.

Bundle: docs/features/ptx-fix-output-parameters-bcee92/ (analysis.md,
proposal.md, angr-vs-kuna.txt, record.json).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…er (option relocobjects, DIV-7)

Closes the angr-vs-kuna gap test_decompiling_ptx_fix_output_parameters::
fix_output_parameters. ptx.o is a relocatable ELF object (ET_REL) with no
PT_LOAD program headers; kuna's PT_LOAD-only LoadImageBfd port mapped zero bytes,
so every function failed ("Unable to load N bytes") and kuna emitted no output at
all, while angr's CLE ELF relocatable backend decompiled it fully.

New kuna-analysis/src/s1_loader/elf_reloc.rs lays SHF_ALLOC sections out above
0x400000 (angr's default; fix_output_parameters -> 0x400660), applies the .rela.*
relocations (R_X86_64_PC32/PLT32/32/32S/64), rebases defined symbols, and binds
undefined externs (PLT-relative call targets named even when STT_NOTYPE) to
synthetic addresses. ObjectLoadImage::from_bytes branches to from_relocatable for
kind()==Relocatable with empty segments(); the linked ET_EXEC/ET_DYN path is
byte-identical.

Option `relocobjects` (default on). The loader runs at `load file`, upstream of
the per-function option machinery, so the toggle is bridged via the
KUNA_RELOC_OBJECTS env var that set_kuna_option and `kuna decompile` write.

Ablation 0/675 (XML datatest path never builds an ObjectLoadImage); speed within
budget. DIV-7. make test PARITY OK; make test-stages PARITY OK (159/159; two
kuna-catalog.xml provenance counts bumped for the new settable). Loader cargo
tests (hand-assembled ET_REL + real ptx.o fixture); no XML stage test is possible
for a loader feature. The one rust-test failure (verify_w10_proto_unlock) is a
pre-existing DIV-6 stale-oracle assertion, unrelated, left untouched.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@mahaloz
mahaloz marked this pull request as ready for review June 25, 2026 04:40
@mahaloz mahaloz changed the title [PROPOSAL] angr-ptx-fix-output-parameters-bcee92: ET_REL relocatable-object loader support ptx-fix-output-parameters: ET_REL relocatable-object loader (option relocobjects) Jun 25, 2026
@mahaloz

mahaloz commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

APPROVE

Bring the relocobjects (ET_REL loader) feature branch up to current main.
Conflicts resolved by UNION; relocobjects' DIV renumbered DIV-7 -> DIV-8
(DIV-7 is now dedupvardecls on main):
- stages.toml: 40 settable blocks; count assertions updated to 40
- decompile.rs: keep both the relocobjects env bridge and experimental_formats env
- loadimage_object.rs from_relocatable: add the new fallback_archtype field (main)
- kuna-catalog.xml / baseline: angr provenance 6, structure-recovery 3;
  use_when/change_kind max bumped 40 -> 50 (40 settables + 1 extra returnpair row)
- divergences.md: DIV-7 dedupvardecls (main) kept, relocobjects added as DIV-8
- UPSTREAM.md / PROGRESS.md / stage-mapping.md: relocobjects DIV-7 -> DIV-8
- assertions.md + baseline-stages.json regenerated

Gates: catalog OK, make test PARITY OK (675/675), make test-stages PARITY OK (163/163).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01PBrckq3YYAzBLq5k4KpWac
@mahaloz
mahaloz merged commit 45e813a into main Jun 25, 2026
@mahaloz
mahaloz deleted the feat/angr-ptx-fix-output-parameters-bcee92 branch July 29, 2026 08:01
mahaloz added a commit to borancar/kuna that referenced this pull request Nov 14, 2026
MSVC /O1 writes mov ebx,3 as push 3; pop ebx. That pop into a
callee-saved register is not the epilogue, and ending the cleanup scan
there dropped the arguments of a cdecl call whose cleanup MSVC deferred
past it (pkgen2: sub_42ea6e(v1,v2) -> (v1), and the next
zend_register_long_constant took the orphaned pair). A pop right after a
push is now passed over. The fixture gains consts (rebuilt from its
recipe), stage Noelo-Lab#36/Noelo-Lab#37; spec 04 also states the remaining limit (a frame
torn down with no callee-saved restore first).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
mahaloz added a commit to borancar/kuna that referenced this pull request Nov 14, 2026
…oelo-Lab#1581

docs/baseline-stages.json is synthesized with mergebaseline.py (main's
keys plus the five CALLEEARGS Noelo-Lab#33-Noelo-Lab#37 this branch adds); every other file
merged without conflict.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant