<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Jul 12, 2017 at 10:26 AM, PkmX via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Note that RISC-V also handles alignment as part of relaxation, so it<br>
isn't really optional. For example:<br>
<br>
_start:<br>
mv a0, a0<br>
.p2align 2<br>
li a0, 0<br>
<br>
The assembler inserts a 3-byte padding (note: this behavior isn't<br>
merged yet, see: <a href="https://github.com/riscv/riscv-binutils-gdb/pull/88" rel="noreferrer" target="_blank">https://github.com/riscv/<wbr>riscv-binutils-gdb/pull/88</a>):<br>
<br>
00000000 <_start>:<br>
0: 852a mv a0,a0<br>
2: 00 01 00 # R_RISCV_ALIGN<br>
2: R_RISCV_ALIGN *ABS*+0x3<br>
5: 4501 li a0,0<br>
<br>
The linker then remove 1 byte from padding to align to the desired width:<br></blockquote><div><br></div><div>This seems ... pessimised :-)</div><div><br></div><div>At least output 4 bytes not 3! To keep it legal before the linker changes sizes.<br></div><div><br></div><div>The assembler can easily keep track of the current alignment as it generates the code, and create an object file that is correct assuming no size changes by the linker.</div><div><br></div><div>If there is, say, a .byte literal of length one then the ".p2align 2" should perhaps emit 7 bytes? Then it is legal as-is if the linker doesn't change the size of anything, or the linker can delete as much as possible if it is adjusting sizes.</div><div><br></div><div><br></div></div></div></div>