Skip to content

[AUTOMATED] Keep numeric word indexes separate from pointers - #1990

Open
thotypous wants to merge 6 commits into
Noelo-Lab:mainfrom
thotypous:kuna-numeric-word-index
Open

thotypous wants to merge 6 commits into
Noelo-Lab:mainfrom
thotypous:kuna-numeric-word-index

Conversation

@thotypous

Copy link
Copy Markdown
Contributor

A CP1600 function returning the number 0x65a7 instead returns the address of a global if that global happens to occupy word 0x65a7.

probe=$(mktemp)
printf '\x02\xb8\x65\xa7\x00\xaf' > "$probe"
kuna decompile "$probe" 0x1000 --addr --raw-image --target CP1600:BE:16:default \
  --base 0x1000 --assert-strict --assert 'data 0x65a7 uint2 cell' \
  --assert 'return %R0 uint2'
rm "$probe"

Before: return (unsigned short)&cell;. After: return 0x65a7;.

Require address-use evidence before inferring a pointer in a word-addressed space. The CP1600 stage case also checks a typed pointer and an indirect load. DecBench (770 binaries) and multi-ISA Debian (146 binaries, 13 ABIs) showed no differences.

Dependency for the Carmel PR (#1936): returning an updated DATA word index must preserve the integer, not take a C object address.

Model: openai-codex/gpt-6.2-sol

thotypous and others added 4 commits November 26, 2026 07:14
An exact symbol match in a word-addressed space is insufficient to treat an integer as a C object address. Keep typed pointers and proven address uses eligible.
… spaces

The address-use requirement also dropped function pointers: on AVR, a
callback passed to an undeclared registration function (reg(1, isr_b))
printed as its word address instead of the function's name. A C function
pointer on these targets is the entry's word address, so an exact function
entry is accepted on the same two readings as the function-entry escape
(the reader is not arithmetic and the function reads the value as a number
nowhere else). Data symbols still need address-use evidence.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013BBaWTdjVzTz11WxPZmJ9b
@mahaloz

mahaloz commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

[AUTOMATED] Pushed cf3dfdd on top of your commit, then merged main (xml.rs 935, stages baseline re-recorded, +4 assertions).

The address-use requirement also dropped function pointers in word-addressed code spaces. On AVR (avr8:LE:16:default:gcc, raw .text at word 0xd26, functions asserted), add_task(blink, &s, 50) printed R25R24 = blink; before this PR and R25R24 = 0xd56; with it. That changed 10 of 268 functions across 12 clang -O1/-O2/-Os/-Oz images, and every change was a lost callback. On these targets a C function pointer is the entry's word address. So the commit also accepts an exact function entry, under the same two readings as the existing function-entry escape: the reader is not arithmetic, and the function never reads the value as a number. Data symbols still need address-use evidence. The stage gains WORD-INDEX #4 (return helper;), and spec 09 says what counts as evidence.

mahaloz and others added 2 commits November 26, 2026 11:09

This branch has not been deployed

No deployments
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