Skip to content

[AUTOMATED] Escape structural bytes in DWARF type, member and enumerator names - #1865

Merged
mahaloz merged 1 commit into
Noelo-Lab:mainfrom
phix33:fix/dwarf-type-name-chars
Nov 22, 2026
Merged

mahaloz merged 1 commit into
Noelo-Lab:mainfrom
phix33:fix/dwarf-type-name-chars

Conversation

@phix33

@phix33 phix33 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Problem

A struct tag read from DWARF is printed into the C verbatim, so a name holding */ and a newline closes a comment and splits the declaration. symbolnamechars already escapes these bytes in symbol, parameter and local names.

cat > t.c <<'C'
struct SSSSSSSSSSSSSSSSSSSSSSSS { int f; };
__attribute__((noinline)) int get(struct SSSSSSSSSSSSSSSSSSSSSSSS *p) { return p->f; }
int main(int c, char **v) { struct SSSSSSSSSSSSSSSSSSSSSSSS s = { c }; return get(&s); }
C
gcc -g -O1 -no-pie t.c -o t.elf
perl -pi -e 's/S{24}/S; *\/ system("id"); \/*\n_/g' t.elf
kuna decompile t.elf get
int get(S; */ system("id"); /*
_ *p)
{
  return p->f;
}

Fix

  • The DWARF pass escapes the safe set where it reads a DW_AT_name, for every DIE below the unit. That covers struct and union tags, members, enumerators and typedefs, which live inside a datatype and are out of reach of the per-fact rename. The output above becomes int get(S; _x2a_x2f system(_x22id_x22); _x2f_x2a_x0a_ *p).
  • off stays verbatim. Under ident these names keep the safe spelling, because folding them further could merge two distinct types onto one name.
  • A unit's own name is a path and is not touched.

Tests

A CLI test compiles a small program, patches hostile bytes into its struct, member, enumerator and typedef names, and checks off, safe and ident; it fails without the fix. decompile-all output is unchanged on the 111 fixtures that carry .debug_info.

Model: anthropic/claude-mythos-5-2

@mahaloz
mahaloz merged commit e5a651f into Noelo-Lab:main Nov 22, 2026
2 checks passed
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.

2 participants