Skip to content

tail-tail-bytes-ret-dup-f79d1d: name-based no-return for undefined externs (option noreturn_extern) - #90

Merged
mahaloz merged 2 commits into
mainfrom
feat/angr-tail-tail-bytes-ret-dup-f79d1d
Jun 26, 2026
Merged

mahaloz merged 2 commits into
mainfrom
feat/angr-tail-tail-bytes-ret-dup-f79d1d

Conversation

@mahaloz

@mahaloz mahaloz commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

noreturn_extern: bound functions at undefined-extern no-return calls (opt-in)

Closes the gap angr's test_tail_tail_bytes_ret_dup exposes on tail.o::tail_bytes
(an ELF relocatable object). Full write-up:
docs/features/tail-tail-bytes-ret-dup-f79d1d/analysis.md.

The gap

kuna decompiled tail_bytes (a 615-byte function, 0x401e80..0x4020e7) as 326 lines /
9 gotos
, running far past the function's real end and swallowing several adjacent
functions (tail_lines, a fstatfs/die_pipe function, an lstat loop, …), even
synthesizing a bogus do { … } while (…) outer loop. angr renders 96 lines / 1 goto.

Root cause

In a .o, __stack_chk_fail is an undefined external symbol (UND, NOTYPE, size 0).
kuna's analysis-tier known-no-return pass (noreturn_known, default on) keys its facts on
the address of a defined FUNC symbol, so it never marks the UND extern — even though
its base name is on the shipped ELF no-return list. At decompile flow time the call resolves
to a display name but the symbol's no-return flag is false, so
FlowEnvironment::query_call_no_return returns false, no artificialHalt(noreturn) is
planted, and flow runs off the function's end into the next function.

Mechanism

A name-based fallback in the flow seam ArchFlowEnv::query_call_no_return
(infra/decompile_drive.rs): when the address-keyed check is false and the gate is on,
resolve the callee display name and return true if matches_noreturn_extern_name matches the
known ELF no-return list (leading-_ strip + std-only namespace guard, exact match against
a closed set — mirrors the analysis-tier name_matches). This plants the existing artificial
halt, so flow stops at the call and the function is bounded correctly. New module
kuna_noreturnextern.rs (ElementId 4103), Architecture flag noreturn_extern_calls modelled
on the tail_call_jumps flow-seam gate. No new pass type, no S7 change.

Option

option noreturn_extern on|off (S2 flow-classification, default-off opt-in).

  • kuna decompile tail.o tail_bytes --option noreturn_extern on → 326 → 87 lines.
  • default (off) keeps the old fall-through rendering (byte-identical to before this PR).

Why opt-in (not default-on)

The 675-datatest ablation with the gate on is byte-identical (0/675) and the target is
37% faster with it — which first argued for default-on. But make rust-test caught a
real interaction the bytechunk-only corpus can't exercise:
verify_multiformat_passes::pe_exit_eliminates_dead_code_via_noreturn_list asserts that
option noreturn_known off restores the dead fall-through after a PE exit, yet the
name-based fallback independently catches exit, so default-on would silently change
PE/ELF exit-family handling under noreturn_known off. The name match overlaps
noreturn_known's for defined/imported symbols, so the honest call is opt-in (no DIV) —
like tailcalljump/gotoreduce/stackguard. The fallback only fires when the address-keyed
check already returned false, so it never double-fires on an already-marked callee.

Parity & speed

  • Speed: 37% faster on the target when on (299 ms → 188 ms median over 5 runs) — it
    decodes less code.
  • Gates: make test PARITY OK 675/675, make test-stages 192/192,
    kuna catalog --check OK, make rust-test green (4 new unit tests).
  • Test: tests/stages/ghangr-noreturn_extern.xml (two-pass: pass 1 off reproduces the bug,
    pass 2 on proves the fix); docs/baseline-stages.json 190 → 192. No DIV (default output
    unchanged).

🤖 Generated with Claude Code


Before / after — tail_bytes in tail.o

Real captured kuna output on the function this feature was built for, with option noreturn_extern flipped. Ported from angr — test_tail_tail_bytes_ret_dup; angr CFG call-graph no-return analysis (undefined-extern __stack_chk_fail); tail_bytes.

metric noreturn_extern off (default) noreturn_extern on
gotos 9 4 ⬇️
labels 9 3 ⬇️
loc 326 84 ⬇️
switches 0 0
speed 299.22 ms 188.1 ms — Δ -37.14% (budget 5.0%)
kuna — before (option noreturn_extern off)
uint4 * tail_bytes(void *a0,void *a1,int8 *a2,int8 *a3)

{
  unsigned long v1;
  void *v10; // rsp
  void *v11;
  int8 *v17;
  uint8 v18; // r12
  int8 *v19;
  char v2; // al
  uint8 v20; // r14
  unsigned long v21; // r15
  int8 v22; // fs_offset
  int4 v3; // eax
  uint8 v4; // rax
  uint4 *v8;
  int8 v9;
  
  v13 = PTRSUB(RSP,0);
  do {
    v10 = v13;
    *(uint8 *)&v10[-8] = v20;
    v20 = (uint8)a1 & 0xffffffff;
    *(int8 **)&v10[-0x10] = v19;
    *(int8 **)&v10[-0x18] = v17;
    *(void **)&v10[-0x20] = v11;
    *(uint4 **)&v10[-0x28] = v8;
    *(void *)&v10[-0x30] = *(void *)(v22 + 0x28);
    *(void *)&v10[-0xd0] = 0x401eb9;
    v3 = fstat(v20,&v10[-200]);
    if (v3 == 0) {
      v19 = a3;
      v5 = a3;
      if (dat_40459e == 0) {
        if ((dat_404595 == '\0') && (0 <= (int8)a2)) {
          *(void *)&v10[-0xd0] = 0x401f7a;
          v2 = usable_st_size.isra.0();
          if (v2 == '\0') {
            *(void *)&v10[-0xd0] = 0x4020d3;
            v4 = (int8)lseek((uint8)a1 & 0xffffffff,-(int8)a2,2);
            if (v4 == (uint4 *)0xffffffffffffffff) goto label_402068;
            v9 = (int8)v4 + (int8)a2;
          }
          else {
            v9 = *(int8 *)&v10[-0x98];
            v4 = (uint4 *)0xffffffffffffffff;
          }
          v6 = *(int8 *)&v10[-0x90];
          if (0x2000000000000000 <= (uint8)(v6 - 1U)) {
            v6 = 0x200;
          }
          if (v6 < v9) {
            if (v4 == (uint4 *)0xffffffffffffffff) {
              *(void *)&v10[-0xd0] = 0x401fce;
              v4 = (int8)xlseek((uint8)a1 & 0xffffffff,0,1,a0);
            }
            if (((int8)v4 < v9) && (a2 < (int8 *)(v9 - (int8)v4))) {
              v9 = v9 - (int8)a2;
              *(void *)&v10[-0xd0] = 0x4020bb;
              xlseek((uint8)a1 & 0xffffffff,v9,0,a0);
            }
            else {
              v9 = (int8)v4;
            }
            *a3 = v9;
            goto label_401f20;
          }
        }
label_402068:
        v14 = (void *)((uint8)a1 & 0xffffffff);
        *(void *)&v10[-0xd0] = 0x402079;
        v4 = (uint8)pipe_bytes(a0,v14,a2);
        v17 = a2;
      }
      else {
        if ((dat_404595 == '\0') && (0 <= (int8)a2)) {
          v3 = *(uint4 *)&v10[-0xb0] & 0xf000;
          if (v3 == 0x8000) {
            *(void *)&v10[-0xd0] = 0x402093;
            v4 = (int8)xlseek((uint8)a1 & 0xffffffff,a2,1,a0);
            if ((int8)v4 <= -1) goto label_401efa;
          }
          else {
label_401efa:
            *(void *)&v10[-0xd0] = 0x401f0a;
            v4 = (int8)lseek((uint8)a1 & 0xffffffff,a2,1);
            if (v4 == (uint4 *)0xffffffffffffffff) goto label_401ff0;
          }
          *a3 = *a3 + (int8)a2;
          a2 = (int8 *)0xffffffffffffffff;
        }
        else {
label_401ff0:
          v14 = (void *)((uint8)a1 & 0xffffffff);
          *(void *)&v10[-0xd0] = 0x402001;
          v3 = start_bytes(a0,v14,a2);
          a2 = (int8 *)0xffffffffffffffff;
          if (v3 != 0) {
            v3 = v3 >> 0x1f;
            v4 = (uint8)(uint8)v3;
            v17 = a2;
            goto label_401f39;
          }
        }
label_401f20:
        a0 = (void *)0x0;
        *(void *)&v10[-0xd0] = 0x401f30;
        v5 = a2;
        v14 = a0;
        v4 = (int8)dump_remainder(0,a0,(uint8)a1 & 0xffffffff);
        *a3 = *a3 + (int8)v4;
        v4 = (uint4 *)0x1;
        v17 = a2;
      }
    }
    else {
      *(void *)&v10[-0xd0] = 0x40202d;
      v4 = (int8 *)quotearg_style(4,a0);
      v19 = (int8 *)v4;
      *(void *)&v10[-0xd0] = 0x402043;
      v4 = (int8 *)dcgettext(0,0x40558d,5);
      v17 = (int8 *)v4;
      *(void *)&v10[-0xd0] = 0x40204b;
      v4 = (uint4 *)__errno_location();
      a0 = (void *)0x0;
      v14 = (void *)(uint8)*v4;
      *(void *)&v10[-0xd0] = 0x40205c;
      v5 = v19;
      error(0,v14,v17);
      v4 = (uint4 *)0x0;
    }
label_401f39:
    v8 = (uint4 *)(*(uint8 *)&v10[-0x30] ^ *(uint8 *)(v22 + 0x28));
    if (v8 == (uint4 *)0x0) {
      return v4;
    }
    *(void *)&v10[-0xd0] = 0x4020e7;
    __stack_chk_fail();
    *v5 = 0;
    a3 = v5;
    a2 = v7;
    v13 = &v10[-200];
    v11 = a0;
    a1 = v14;
  } while (dat_4045a1 == '\0');
  *(void *)&v10[-0xd0] = v21;
  *(uint8 *)&v10[-0xd8] = v20;
  *(int8 **)&v10[-0xe0] = v19;
  *(int8 **)&v10[-0xe8] = v17;
  *(void **)&v10[-0xf0] = a0;
  *(uint4 **)&v10[-0xf8] = v8;
  *(void *)&v10[-0x108] = *(void *)(v22 + 0x28);
  *(void *)&v10[-0x1a8] = 0x401ac9;
  v3 = fstat((uint8)v14 & 0xffffffff);
  if (v3 == 0) {
    v18 = (uint8)dat_40459e;
    if (dat_40459e == 0) {
      if ((dat_404595 == '\0') && (v3 = *(uint4 *)&v10[-0x188] & 0xf000, v3 == 0x8000)) {
        *(void *)&v10[-0x1a8] = 0x401bd6;
        v4 = (uint4 *)lseek((uint8)v14 & 0xffffffff,0,1);
        v8 = v4;
        if (v4 != (uint4 *)0xffffffffffffffff) {
          v12 = (void *)0x0;
          v16 = (void *)((uint8)v14 & 0xffffffff);
          *(void *)&v10[-0x1a8] = 0x401bf1;
          v4 = (int8)lseek(v16,0,2);
          if ((int8)v8 < (int8)v4) {
            *v5 = (int8)v4;
            v18 = 1;
            if (v4 != (uint4 *)0x0) {
              v12 = (void *)((uint8)v14 & 0xffffffff);
              *(void *)&v10[-0x1a8] = 0x401c1e;
              v16 = a0;
              v3 = file_lines(a0,v12,v7,v8,v4,v5);
              v18 = (uint8)v3;
            }
            goto label_401b0e;
          }
          *(void *)&v10[-0x1a8] = 0x401c3f;
          xlseek((uint8)v14 & 0xffffffff,v8,0,a0);
        }
      }
      v12 = (void *)((uint8)v14 & 0xffffffff);
      *(void *)&v10[-0x1a8] = 0x401b0b;
      v16 = a0;
      v3 = pipe_lines(a0,v12,v7,v5);
      v18 = (uint8)v3;
    }
    else {
      v12 = (void *)((uint8)v14 & 0xffffffff);
      *(void *)&v10[-0x1a8] = 0x401b50;
      v16 = a0;
      v3 = start_lines(a0,v12,v7,v5);
      if (v3 == 0) {
        v16 = (void *)0x0;
        *(void *)&v10[-0x1a8] = 0x401bbb;
        v12 = a0;
        v4 = (int8)dump_remainder(0,a0,(uint8)v14 & 0xffffffff,0xffffffffffffffff);
        *v5 = *v5 + (int8)v4;
      }
      else {
        v3 = v3 >> 0x1f;
        v18 = (uint8)v3;
      }
    }
  }
  else {
    *(void *)&v10[-0x1a8] = 0x401b6d;
    v4 = (void *)quotearg_style(4,a0);
    a0 = (void *)v4;
    *(void *)&v10[-0x1a8] = 0x401b83;
    v4 = (unsigned long)dcgettext(0,0x40558d,5);
    v1 = v4;
    *(void *)&v10[-0x1a8] = 0x401b8b;
    v4 = (uint4 *)__errno_location();
    v16 = (void *)0x0;
    v12 = (void *)(uint8)*v4;
    v18 = 0;
    *(void *)&v10[-0x1a8] = 0x401b9f;
    error(0,v12,v1,a0);
  }
label_401b0e:
  if (*(int8 *)&v10[-0x108] == *(int8 *)(v22 + 0x28)) {
    v4 = (uint4 *)v18;
    return v4;
  }
  *(void *)&v10[-0x1a8] = 0x401c49;
  __stack_chk_fail();
  *(void **)&v10[-0x1a8] = a0;
  *(uint8 *)&v10[-0x1b0] = v18;
  *(uint8 *)&v10[-0x1b8] = (uint8)v14 & 0xffffffff;
  *(uint4 **)&v10[-0x1c0] = v8;
  v13 = &v10[-0x248];
  *(void *)&v10[-0x1d0] = *(void *)(v22 + 0x28);
  *(void *)&v10[-0x250] = 0x401c78;
  v3 = fstatfs();
  if (v3 == 0) {
    v16 = *(void **)&v10[-0x248];
    *(void *)&v10[-0x250] = 0x401cc9;
    v3 = is_local_fs_type();
    if (0 < (int4)v3) goto label_401cf8;
    if ((int4)v3 <= -2) {
      do {
        v13 = (void *)0x40559d;
        v16 = (void *)0x404690;
        *(void *)&v10[-0x250] = 0x401cf1;
        v3 = __assert_fail(0x404690,0x40559d,0x3cc,0x405aa8);
label_401cf8:
      } while (v3 != 1);
      v18 = 0;
    }
    else {
      v18 = 1;
    }
  }
  else {
    *(void *)&v10[-0x250] = 0x401c81;
    v4 = (uint4 *)__errno_location();
    v8 = v4;
    v18 = 1;
    if (*v4 != 0x26) {
      *(void *)&v10[-0x250] = 0x401d1d;
      v4 = (unsigned long)quotearg_style(4,v12);
      v1 = v4;
      *(void *)&v10[-0x250] = 0x401d33;
      v4 = (unsigned long)dcgettext(0,0x404658,5);
      v13 = (void *)(uint8)*v8;
      v16 = (void *)0x0;
      *(void *)&v10[-0x250] = 0x401d44;
      error(0,v13,v4,v1);
    }
  }
  if (*(int8 *)&v10[-0x1d0] == *(int8 *)(v22 + 0x28)) {
    v4 = (uint4 *)v18;
    return v4;
  }
  *(void *)&v10[-0x250] = 0x401d4e;
  __stack_chk_fail();
  *(uint8 *)&v10[-0x250] = v18;
  *(void **)&v10[-600] = v12;
  *(uint4 **)&v10[-0x260] = v8;
  v14 = &v16[(int8)v13 * 0xc];
  *(void *)&v10[-0x268] = *(void *)(v22 + 0x28);
  do {
    v1 = *v16;
    *(void *)&v10[-0x308] = 0x401d8b;
    v3 = lstat(v1,&v10[-0x300]);
    if ((v3 == 0) && (v3 = *(uint4 *)&v10[-0x2e8] & 0xf000, v3 == 0xa000)) {
      v4 = (uint4 *)0x1;
      goto label_401daa;
    }
    v16 = &v16[0xc];
  } while (v16 != v14);
  v4 = (uint4 *)0x0;
label_401daa:
  if (*(int8 *)&v10[-0x268] == *(int8 *)(v22 + 0x28)) {
    return v4;
  }
  *(void *)&v10[-0x308] = 0x401dd5;
  v4 = (unsigned long)__stack_chk_fail();
  *(uint4 **)&v10[-0x308] = v4;
  *(void *)&v10[-0x310] = 0x401df0;
  raise(0xd);
  v15 = 0;
  *(void *)&v10[-0x310] = 0x401dfa;
  exit(1);
  *(void *)&v10[-0x318] = *(void *)(v22 + 0x28);
  if (dat_40459f != '\0') {
    *(void *)&v10[-800] = 1;
    *(void *)&v10[-0x328] = 0x401e4f;
    v15 = (uint4)&v10[-800];
    v3 = poll(&v10[-800],1,0);
    if ((0 <= (int4)v3) && ((v10[-0x31a] & 0x18) != 0)) {
      *(void *)&v10[-0x328] = 0x401e5f;
      die_pipe();
      goto label_401e5f;
    }
  }
  if (*(int8 *)&v10[-0x318] == *(int8 *)(v22 + 0x28)) {
    v4 = (uint4 *)0x0;
    return v4;
  }
label_401e5f:
  *(void *)&v10[-0x328] = 0x401e64;
  v4 = (unsigned long)__stack_chk_fail();
  v4 = (uint8)CONCAT71(SUB87(v4,1),(v15 & 0xd000) == 0x8000);
  return v4;
}
kuna — after (option noreturn_extern on)
void * tail_bytes(unsigned long a0,unsigned int a1,uint8 a2,int8 *a3)

{
  unsigned long v1;
  int8 v10; // stack - 0x98
  int8 v12; // stack - 0x30
  unsigned long v2;
  char v3; // al
  int4 v4; // eax
  int8 v5; // rax
  int8 v6;
  char v7 [24];
  int8 v8; // fs_offset
  uint4 v9; // stack - 0xb0
  
  v12 = *(int8 *)(v8 + 0x28);
  v4 = fstat(a1,v7);
  if (v4 != 0) {
    v5 = (unsigned long)quotearg_style(4,a0);
    v1 = v5;
    v5 = (unsigned long)dcgettext(0,0x40558d,5);
    v2 = v5;
    v5 = (void *)__errno_location();
    error(0,*v5,v2,v1);
    v5 = (void *)0x0;
    goto label_401f39;
  }
  if (dat_40459e == '\0') {
    if ((dat_404595 == '\0') && (0 <= (int8)a2)) {
      v3 = usable_st_size.isra.0(v9);
      if (v3 == '\0') {
        v5 = (int8)lseek(a1,-a2,2);
        if (v5 == (void *)0xffffffffffffffff) goto label_402068;
        v6 = (int8)v5 + a2;
      }
      else {
        v5 = (void *)0xffffffffffffffff;
        v6 = v10;
      }
      if (0x2000000000000000 <= (uint8)(v11 - 1U)) {
        v11 = 0x200;
      }
      if (v11 < v6) {
        if (v5 == (void *)0xffffffffffffffff) {
          v5 = (int8)xlseek(a1,0,1,a0);
        }
        if (((int8)v5 < v6) && (a2 < (uint8)(v6 - (int8)v5))) {
          v6 = v6 - a2;
          xlseek(a1,v6,0,a0);
        }
        else {
          v6 = (int8)v5;
        }
        *a3 = v6;
        goto label_401f20;
      }
    }
label_402068:
    v5 = (uint8)pipe_bytes(a0,a1,a2,a3);
  }
  else {
    if (((dat_404595 == '\0') && (0 <= (int8)a2)) && (((v4 = v9 & 0xf000, v4 == 0x8000 && (v5 = (int8)xlseek(a1,a2,1,a0), 0 <= (int8)v5)) || (v5 = (int8)lseek(a1,a2,1), v5 != (void *)0xffffffffffffffff)))) {
      *a3 = *a3 + a2;
      a2 = 0xffffffffffffffff;
    }
    else {
      v4 = start_bytes(a0,a1,a2,a3);
      a2 = 0xffffffffffffffff;
      if (v4 != 0) {
        v4 = v4 >> 0x1f;
        v5 = (uint8)(uint8)v4;
        goto label_401f39;
      }
    }
label_401f20:
    v5 = (int8)dump_remainder(0,a0,a1,a2);
    *a3 = *a3 + (int8)v5;
    v5 = (void *)0x1;
  }
label_401f39:
  if (v12 != *(int8 *)(v8 + 0x28)) {
                    /* WARNING: Subroutine does not return */
    __stack_chk_fail();
  }
  return v5;
}
angr reference (the goal, v9.2.213)
typedef struct stat {
    unsigned int st_mode;
    char padding_4[4];
    unsigned int st_ino;
    char padding_c[4];
    char st_dev;
    char padding_11[7];
    unsigned int st_nlink;
    unsigned int st_uid;
    unsigned int st_gid;
    char padding_24[4];
    int st_size;
    char padding_2c[4];
    int st_atime;
    char padding_34[4];
    int st_mtime;
    char padding_3c[4];
    int st_ctime;
} stat;

extern char from_start;
extern char presume_input_pipe;

unsigned int tail_bytes(long long a0, int a1, long long a2, unsigned long long *ptr)
{
    long long v2;  // r12
    unsigned int v3;  // eax
    unsigned long v4;  // rbx
    unsigned long v5;  // rax
    unsigned long v6;  // rdx
    unsigned long long v7;  // rax
    char *v8;  // rax
    int *err;  // rax
    stat v0;  // [bp-0xc8]

    v2 = a2;
    if (fstat(a1, &v0))
    {
        quotearg_style(4, a0);
        v8 = dcgettext(NULL, "cannot fstat %s", 5);
        err = __errno_location();
        error(0, *(err), v8);
        return 0;
    }
    else if (from_start)
    {
        if (!presume_input_pipe && v2 >= 0 && (((unsigned short)v0.st_nlink & 0xf000) == 0x8000 && xlseek(a1, v2, 1, a0) >= 0 || lseek(a1, v2, 1) != 18446744073709551615))
        {
            *(ptr) = *(ptr) + v2;
            v7 = dump_remainder(0, a0, a1, -1);
            *(ptr) = *(ptr) + v7;
            return 1;
        }
        v3 = start_bytes(a0, a1, v2, ptr);
        if (v3)
            return v3 >> 31;
        v7 = dump_remainder(0, a0, a1, -1);
        *(ptr) = *(ptr) + v7;
        return 1;
    }
    else
    {
        if (presume_input_pipe || v2 < 0)
            return pipe_bytes(a0, a1, v2, ptr);
        if ((char)usable_st_size.isra.0(v0.st_nlink))
        {
            v4 = *((unsigned long long *)((void*)&v0 + 48));
            v5 = 18446744073709551615;
            goto LABEL_401f8e;
        }
        else
        {
            v5 = lseek(a1, -(v2), 2);
            if (v5 != 18446744073709551615)
            {
                v4 = v5 + v2;
LABEL_401f8e:
                v6 = *((unsigned long long *)((void*)&v0 + 56));
                if (*((unsigned long long *)((void*)&v0 + 56)) - 1 > 2305843009213693951)
                    v6 = 0x200;
                if (v4 > v6)
                {
                    if (v5 == 18446744073709551615)
                        v5 = xlseek(a1, 0, 1, a0);
                    if (v4 > v5 && v4 - v5 > v2)
                    {
                        v5 = v4 - v2;
                        xlseek(a1, v5, 0, a0);
                    }
                    *(ptr) = v5;
                    v7 = dump_remainder(0, a0, a1, v2);
                    *(ptr) = *(ptr) + v7;
                    return 1;
                }
            }
        }
        return pipe_bytes(a0, a1, v2, ptr);
    }
}

…(opt-in)

Closes the angr `test_tail_tail_bytes_ret_dup` gap on `tail.o::tail_bytes` (an
ELF relocatable object). kuna decompiled the 615-byte function as 326 lines / 9
gotos, running far past its end and swallowing adjacent functions after the
canary epilogue's `__stack_chk_fail()`; angr renders 96 lines / 1 goto.

Root cause: in a `.o`, `__stack_chk_fail` is an UNDEFINED external symbol (UND,
NOTYPE, size 0). The analysis-tier `noreturn_known` pass keys on the ADDRESS of a
*defined* FUNC symbol, so it never marks the UND extern; at flow time
`query_call_no_return` returns false, no artificial halt is planted, and flow
runs off the function's end.

Fix: a name-based fallback in the flow seam `ArchFlowEnv::query_call_no_return`
(infra/decompile_drive.rs): when the address-keyed check is false and the gate is
on, name-match the resolved callee against the known ELF no-return list
(kuna_noreturnextern::matches_noreturn_extern_name, mirroring the analysis-tier
name_matches). New module kuna_noreturnextern.rs (ElementId 4103), Architecture
flag noreturn_extern_calls modelled on tail_call_jumps. No new pass type, no S7.

`option noreturn_extern on` -> tail_bytes 326 -> 87 lines (37% faster). Kept
DEFAULT-OFF opt-in: the name match overlaps noreturn_known's for defined/imported
symbols, so default-on would change PE/ELF exit-family handling under
`noreturn_known off` (verify_multiformat_passes::pe_exit...). 675-datatest
ablation with the gate on is 0/675. Test tests/stages/ghangr-noreturn_extern.xml
(+2, baseline-stages 190 -> 192). Gates: make test PARITY OK 675/675,
make test-stages 192/192, catalog --check OK, make rust-test green except the
pre-existing verify_w10_proto_unlock oracle drift (unrelated, fails on branch HEAD).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@mahaloz

mahaloz commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

I approve this, but you should also note to future agents and start them up on fixing the following based on this case:

  1. Notice that angr has names for some global variables like presume_input_pipe, which shows either our DWARF or ELF parsing is flawed and not naming them. Chceck that another agent is not working on this before starting it. If they are, simply tell that agent they shoudl also use this as an additional testcase.
  2. Notice, we have lines like dat_40459e == '\0', which is overly complicated. It should either show !dat_40459e or flip the if-statement and do if(dat_40459e). Check that another agent is not working on this before starting it. If they are, simply tell that agent they shoudl also use this as an additional testcase.

Union-resolve the shared registration/count files so noreturn_extern
(ElementId 4103, default-off opt-in) coexists with main's advancement:
- stages.toml header settable=54->55 (32 stage-model knobs); +1 settable block
- kuna_stages/tests.rs: settable count 55, json-comma 54, live-value 24;
  test fns renamed settable_count_is_55 / live_value_present_for_24_suppressed_for_31
- catalog_bytecompat.rs: fixture_has_all_55_settables (32 stage + 20 analysis + 3 loader)
- kuna-base/xml.rs corpus count 146 (83 datatests + 63 stage tests)
- kuna-catalog.xml: source_decompiler angr count 15 (adds noreturn_extern)
- regenerated docs/assertions.md + docs/baseline-stages.json (205 keys)

Gates green: kuna catalog --check OK; make test 675/675 PARITY OK;
make test-stages 205/205 PARITY OK.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01PBrckq3YYAzBLq5k4KpWac
@mahaloz
mahaloz merged commit ad2a709 into main Jun 26, 2026
mahaloz added a commit that referenced this pull request Jun 26, 2026
)

Union-resolve so noreturn_externmatch coexists with #90's noreturn_extern
(both name-match the ELF no-return list at the same flow seam). Deconflicted:
- ElementId 4103 -> 4104 (4103 taken by #90's noreturn_extern on main)
- DIV-12 -> DIV-13 (DIV-12 taken by main's region structurer); renumbered in
  divergences.md, architecture.rs, stages.toml, the module, the testcase XML,
  UPSTREAM.md, stage-mapping.md, PROGRESS.md, feature record/plan/pr_body
- decompile_drive.rs query_call_no_return: BOTH gated checks kept
  (noreturn_extern_match + noreturn_extern_calls)
- s2_lift/mod.rs: both modules declared
- stages.toml header surface=95, settable=56 (33 stage-model knobs); +1 surface +1 settable
- kuna_stages/tests.rs: settable 56, surface 95, json-comma 55, live-value 25;
  test fns renamed (settable_count_is_56 / live_value_present_for_25_suppressed_for_31)
- catalog_bytecompat.rs: fixture_has_all_56_settables
- kuna-base/xml.rs corpus count 147 (83 datatests + 64 stage tests)
- kuna-catalog.xml: source_decompiler angr count 16 (both noreturn_extern + externmatch)
- #90's ghangr-noreturn_extern.xml: pass 1 now also sets `noreturn_externmatch off`
  to isolate the noreturn_extern toggle (externmatch default-on else bounds it first)
- regenerated stage_catalog.json fixture, docs/assertions.md, baseline-stages.json (208 keys)

Gates green: kuna catalog --check OK; make test 675/675 PARITY OK;
make test-stages 208/208 PARITY OK.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01PBrckq3YYAzBLq5k4KpWac
mahaloz added a commit that referenced this pull request Jun 26, 2026
Union-resolve so crossjumprevert (opt-in default-off) coexists with #90's
noreturn_extern and #91's noreturn_externmatch on main. Deconflicted:
- ElementId 4103 -> 4105 (4103=noreturn_extern, 4104=noreturn_externmatch on main)
- stages.toml header surface=95, settable=57 (34 stage-model knobs); +1 settable
- kuna_stages/tests.rs: settable 57, surface 95, json-comma 56, live-value 25
  (crossjumprevert has no live reader, in the suppressed allowlist);
  test fns renamed (settable_count_is_57 / live_value_present_for_25_suppressed_for_32)
- catalog_bytecompat.rs: fixture_has_all_57_settables
- kuna-base/xml.rs corpus count 148 (83 datatests + 65 stage tests)
- kuna-catalog.xml: source_decompiler angr 17, change_kind structure-recovery 9
  (both add crossjumprevert)
- verify_w8_fw_universalaction.rs auto-merged: 262 leaves (252 C++ + branchflip
  + gotoreduce + crossjumprevert + 7 headers); universalaction/seams/architecture/block
  wiring of revert_cross_jumps preserved alongside the noreturn_extern* additions
- regenerated stage_catalog.json fixture, docs/assertions.md, baseline-stages.json (212 keys)

Gates green: kuna catalog --check OK; make test 675/675 PARITY OK;
make test-stages 212/212 PARITY OK.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01PBrckq3YYAzBLq5k4KpWac
@mahaloz
mahaloz deleted the feat/angr-tail-tail-bytes-ret-dup-f79d1d branch July 29, 2026 08:01
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