]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
RISC-V: Fixed the missing $x+arch when adding odd paddings for alignment.
authorNelson Chu <nelson@rivosinc.com>
Tue, 1 Nov 2022 13:51:55 +0000 (21:51 +0800)
committerNelson Chu <nelson@rivosinc.com>
Wed, 2 Nov 2022 05:00:27 +0000 (13:00 +0800)
commitd918451a044821abd285f7a5bc5547ec9b50a118
tree97e48870f8708a9d00a4848e3686ef328e9c5c03
parent2188d6ea4f8300a688dc73c7a71881439d3ea49b
RISC-V: Fixed the missing $x+arch when adding odd paddings for alignment.

Consider the case,

.option arch, rv32i
.option norelax
.option arch, +c
.byte   1
.align  2
addi    a0, zero, 1

Assembler adds $d for the odd .byte, and then adds $x+arch for the
alignment.  Since norelax, riscv_add_odd_padding_symbol will add the
$d and $x for the odd alignment, but accidently remove the $x+arch because
it has the same address as $d.  Therefore, we will get the unexpected result
before applying this patch,

.byte   1            # $d
.align  2            # odd alignment, $xrv32ic replaced by $d + $x

After this patch, the expected result should be,

.byte   1            # $d
.align  2            # odd alignment, $xrv32ic replaced by $d + $xrv32ic

gas/
    * config/tc-riscv.c (make_mapping_symbol): If we are adding mapping symbol
    for odd alignment, then we probably will remove the $x+arch by accidently
    when it has the same address of $d.  Try to add the removed $x+arch back
    after the $d rather than just $x.
    (riscv_mapping_state): Updated since parameters of make_mapping_symbol are
    changed.
    (riscv_add_odd_padding_symbol): Likewise.
    (riscv_remove_mapping_symbol): Removed and moved the code into the
    riscv_check_mapping_symbols.
    (riscv_check_mapping_symbols): Updated.
    * testsuite/gas/riscv/mapping-dis.d: Updated and added new testcase.
    * testsuite/gas/riscv/mapping-symbols.d: Likewise.
    * testsuite/gas/riscv/mapping.s: Likewise.
gas/config/tc-riscv.c
gas/testsuite/gas/riscv/mapping-dis.d
gas/testsuite/gas/riscv/mapping-symbols.d
gas/testsuite/gas/riscv/mapping.s