Skip to content

ch32v: Fix _reset_vector in non-small release modes.#863

Merged
mattnite merged 3 commits intomainfrom
wch_fix
Jan 19, 2026
Merged

ch32v: Fix _reset_vector in non-small release modes.#863
mattnite merged 3 commits intomainfrom
wch_fix

Conversation

@Grazfather
Copy link
Collaborator

@Copper280z noticed that none of the examples worked when build in ReleaseSafe.

I took a look and noticed that the vector table started at 8 instead of 4:

pwndbg> x/2wx 4
0x4 <main.startup_logic._reset_vector+4>:       0x00000000      0x00000610

vs.

pwndbg> x/2wx 4
0x4warning: (Internal error: pc 0x4 in read in CU, but not in symtab.)
warning: (Error: pc 0x4 in address map, but not in symtab.)
 <vector_table>:        0x00000394      0x00000394

Looks like it was because _reset_vector was a function, the release mode was putting padding around it.

I am not sure if there's a nicer way to avoid this, but I worked around it by emitting the assembly directly.

Strangely, I now get a error

✦ ❯ zig build --release=small -Dexample=blinky
error: <inline asm>:4:1: unrecognized instruction mnemonic, did you mean: b?
j _start/8238] Linking
^  └─ LLVM Emit Object

I have no idea how this ever emitted a working binary at all.

That said, I came up with a different approach, where instead of trying to get the vector table to start at 4, I just adjust mtvec.base to configure the interrupts to start wherever that table lands.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Lint Results

@mattnite mattnite merged commit 1180e81 into main Jan 19, 2026
56 checks passed
@mattnite mattnite deleted the wch_fix branch January 19, 2026 15:38
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