]> git.ipfire.org Git - thirdparty/gcc.git/commit
AVR: AVR-SD: Put a valid opcode prior to gs() table in .subsection 1.
authorGeorg-Johann Lay <avr@gjlay.de>
Thu, 6 Nov 2025 18:59:48 +0000 (19:59 +0100)
committerGeorg-Johann Lay <avr@gjlay.de>
Thu, 6 Nov 2025 19:06:11 +0000 (20:06 +0100)
commitd79d12d3faea6c4472ede35e4b66a68cf1f85f77
tree4adf1906e3b5128abad002a6375bbd010265c97f
parent5e93ab0da7a700371a72683ea6c7a1fd2bc23907
AVR: AVR-SD: Put a valid opcode prior to gs() table in .subsection 1.

On functional safety devices (AVR-SD), each executed instruction must
be followed by a valid opcode.  This is because instruction fetch and
decode for the next instruction runs while the 2-stage pipeline is
executing the current instruction.

There is only one case where avr-gcc generates code interspersed with
data, which is when a switch/case table is generated for a function
with a "section" attribute and AVR_HAVE_JMP_CALL.  In that case, the
table with the gs() code label addresses is put in .subsection 1 so
that it belongs to the section as specified by the "section" attribute.

gcc/
* config/avr/avr.cc (avr_output_addr_vec): Output
a valid opcode prior to the first gs() label provided:
- The code is compiled for an arch that has AVR-SD mcus, and
- the function has a "section" attribute, and
- the function has a gs() label addresses switch/case table.
gcc/config/avr/avr.cc