[PATCH] RISC-V: Fix .p2align is not at smallest instruction

Nelson Chu nelson.chu@sifive.com
Wed Dec 11 02:47:00 GMT 2019


Hi Palmer,


On Wed, Dec 11, 2019 at 10:25 AM Palmer Dabbelt via binutils
<binutils@sourceware.org> wrote:
>     .text
>     .globl _start
>     .globl aligned1
>     .globl aligned2
>     .option relax
>     .option norvc
>     _start:
>             .p2align 4
>     aligned1:
>             xori x0, x0, 1
>             .byte 0xAA
>             .byte 0xAB
>             .byte 0xAC
>             .byte 0xAD
>     .p2align 3
>     aligned2:
>             xori x0, x0, 2
>             xori x0, x0, 3
>             xori x0, x0, 4
>             xori x0, x0, 5
>
>     align-6.o:     file format elf64-littleriscv
>
>
>     Disassembly of section .text:
>
>     0000000000000000 <_start>:
>             ...
>                             0: R_RISCV_ALIGN        *ABS*+0xc
>
>     000000000000000c <aligned1>:
>        c:   00104013                xori    zero,zero,1
>       10:   abaa                    fsd     fa0,464(sp)
>       12:   adac                    fsd     fa1,88(a1)
>       14:   0000                    unimp
>                             14: R_RISCV_ALIGN       *ABS*+0x4
>             ...
>
>     0000000000000018 <aligned2>:
>       18:   00204013                xori    zero,zero,2
>       1c:   00304013                xori    zero,zero,3
>       20:   00404013                xori    zero,zero,4
>       24:   00504013                xori    zero,zero,5
>       28:   00000013                nop
>       2c:   00000013                nop
>
>     align-6:     file format elf64-littleriscv
>
>
>     Disassembly of section .text:
>
>     0000000000010080 <_start>:
>        10080:       00104013                xori    zero,zero,1
>        10084:       abaa                    fsd     fa0,464(sp)
>        10086:       adac                    fsd     fa1,88(a1)
>
>     0000000000010088 <aligned2>:
>        10088:       00204013                xori    zero,zero,2
>        1008c:       00304013                xori    zero,zero,3
>        10090:       00404013                xori    zero,zero,4
>        10094:       00504013                xori    zero,zero,5
>        10098:       00000013                nop
>        1009c:       00000013                nop

I think this is caused by the text section's alignment.  There is a
".p2align 4" in the text section, so the default alignment will be set
to largest alignment in the section.

Thanks and Regards
Nelson



More information about the Binutils mailing list