Skip to content

avr: preserve symbols after byte selectors - #209

Open
Firat17aze wants to merge 1 commit into
EmbLinkOs:mainfrom
Firat17aze:fix/avr-inline-asm-symbols
Open

Firat17aze wants to merge 1 commit into
EmbLinkOs:mainfrom
Firat17aze:fix/avr-inline-asm-symbols

Conversation

@Firat17aze

Copy link
Copy Markdown

Fixes #205.

AVR whole-template assembly treated lo8, hi8, and the related byte-selection operators as undefined symbols. In a multi-statement inline-assembly block, that occupied the external-symbol slot before a following call or jmp, so the real target could not be relocated. The 16-character text in the diagnostic was its display limit rather than a shortened symbol in the object.

This classifies the AVR expression operators as assembler words, alongside the numeric I/O register names. The regression uses EmbLinkRTOS's emb_arch_switch_to and embk_thread_launch entry points and verifies that both complete names reach the relocation table.

Validation:

  • regression confirmed to fail before the fix
  • make -j8 embcc embld — passed with the default -std=c99 -Wall -Wextra -Werror build
  • PATH=/opt/homebrew/opt/llvm/bin:$PATH sh tests/golden/avr-inline-asm.sh — passed, including LLVM byte comparisons and QEMU ATmega328P execution at -O0, -O1, -O2, and -Os
  • git diff --check and sh -n tests/golden/avr-inline-asm.sh — passed
  • make check could not run the execution corpus because the configured x86-64 newlib and reference libstdc++ trees are absent; it skipped the corpus and exited with no tests found

No physical AVR board was available. The attempted current EmbLinkRTOS integration configure was also blocked locally because the Python >=3.10 installation lacks PyYAML, while the Python installation with PyYAML is 3.9; the exact RTOS entry points are covered by the relocation regression above.

LLMs were used for review and code generation in some parts of this pull request.

The whole-template assembler treated lo8 and the other AVR byte-selection operators as undefined symbols. In a multi-statement inline asm block, that occupied the external-symbol slot before a following call or jump and left its real target unrelocatable.

Classify the AVR expression operators as assembler words, alongside the numeric I/O register names. The regression uses the two 18-character EmbLinkRTOS entry points, failed before this change, and now verifies that both full names reach the relocation table.

Validation: PATH=/opt/homebrew/opt/llvm/bin:$PATH sh tests/golden/avr-inline-asm.sh (passed, including QEMU at -O0/-O1/-O2/-Os). Host build passed with -std=c99 -Wall -Wextra -Werror. make check could not run the corpus because the configured x86-64 newlib and reference libstdc++ trees are absent.

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.

avr: inline assembly with lo8()/hi8() cuts symbols longer than 16 characters

1 participant