binutils Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
loongarch

LoongArch: Enforce 4-byte alignment for machine instructions.

The LoongArch backend in GNU assembler now enforces 4-byte alignment for machine instructions to prevent instruction fetch errors.

The LoongArch backend in GNU assembler now enforces 4-byte alignment for machine instructions. This ensures that instructions are properly aligned when linked into executables or shared objects, even when no explicit alignment is specified in the assembly source. Without this, instruction fetch errors may occur, especially when generating shared objects with the -nostdlib option.

In Details

The GNU assembler's LoongArch backend (gas/config/tc-loongarch.c) now calls record_alignment (now_seg, 2) when emitting instructions to enforce 4-byte alignment. This prevents instruction fetch errors that can occur when linking object files where alignment wasn't explicitly specified. A new test case (gas/testsuite/gas/loongarch/insn_align_4.s) validates this.

For Context

The GNU assembler (gas) translates assembly code into machine code. LoongArch is a RISC instruction set architecture (ISA). This change ensures that LoongArch instructions are aligned on 4-byte boundaries in the assembled output. Unaligned instructions can cause crashes or performance problems on some architectures, as the CPU may only fetch instructions from aligned addresses. The assembler must take care to insert padding bytes when necessary to maintain alignment.

Filed Under: loongarchalignmentassembler