]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
RISC-V: correct alignment directive handling for text sections
authorJan Beulich <jbeulich@suse.com>
Fri, 27 Sep 2024 09:40:22 +0000 (11:40 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 27 Sep 2024 09:40:22 +0000 (11:40 +0200)
commit784e2ef54b443a4d0b95e97122934ca8eaa4155b
tree47ce6e69fc4c8d4c0c61c25003701236f65b8054
parentca6b6f9d6e65d27bc40c8f1e4c6d39fe04cfbdb2
RISC-V: correct alignment directive handling for text sections

.insn or data emitted inside text sections can lead to positions not
being at insn granularity. In such situations using alignment
directives should reliably enforce the requested alignment.
Specifically requests to align back to insn granularity may not be
ignored (where, as a subcase thereof, the ordering of ".option norvc"
and e.g. ".p2align 2" should not matter; so far the alignment directive
needs to come first to have any effect). Similarly ahead of emitting
NOPs alignment first needs to be forced back to insn granularity.

The new testcases actually point out a corner case issue in the
disassembler as well, which is being corrected at the same time: We
don't want to print "0x" without any subsequent digits.
gas/config/tc-riscv.c
gas/config/tc-riscv.h
gas/testsuite/gas/riscv/relax-align-2.d [new file with mode: 0644]
gas/testsuite/gas/riscv/relax-align-2.s [new file with mode: 0644]
gas/testsuite/gas/riscv/relax-align.d [new file with mode: 0644]
gas/testsuite/gas/riscv/relax-align.s [new file with mode: 0644]
opcodes/riscv-dis.c