This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] RISC-V: Fix .p2align is not at smallest instruction
- From: Nelson Chu <nelson dot chu at sifive dot com>
- To: Palmer Dabbelt <palmerdabbelt at google dot com>
- Cc: Binutils <binutils at sourceware dot org>, Kuan-Lin Chen <kuanlinchentw at gmail dot com>
- Date: Wed, 11 Dec 2019 10:47:05 +0800
- Subject: Re: [PATCH] RISC-V: Fix .p2align is not at smallest instruction
- References: <CAJr6u0j9Q7HRJtU=exMmQq-3pEHtE2DPOMq7hoNy9KOBBn8YXg@mail.gmail.com> <mhng-2a133120-cf37-475d-9a1e-021a121e5844@palmerdabbelt-glaptop>
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