<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/117103>117103</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Sections containing instructions should be aligned to the architecture's instruction alignment
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
pcc
</td>
</tr>
</table>
<pre>
When assembling the following for AArch64:
```
.section .text.unlikely,"ax",@progbits
.Ltmp4:
b .Ltmp4
```
LLVM's section headers:
```
Section Headers:
[Nr] Name Type Address Off Size ES Flg Lk Inf Al
[ 0] NULL 0000000000000000 000000 000000 00 0 0 0
[ 1] .strtab STRTAB 0000000000000000 000078 000029 00 0 0 1
[ 2] .text PROGBITS 0000000000000000 000040 000000 00 AX 0 0 4
[ 3] .text.unlikely PROGBITS 0000000000000000 000040 000004 00 AX 0 0 1
[ 4] .symtab SYMTAB 0000000000000000 000048 000030 18 1 2 8
```
GNU as section headers:
```
Section Headers:
[Nr] Name Type Address Off Size ES Flg Lk Inf Al
[ 0] NULL 0000000000000000 000000 000000 00 0 0 0
[ 1] .text PROGBITS 0000000000000000 000040 000000 00 AX 0 0 1
[ 2] .data PROGBITS 0000000000000000 000040 000000 00 WA 0 0 1
[ 3] .bss NOBITS 0000000000000000 000040 000000 00 WA 0 0 1
[ 4] .text.unlikely PROGBITS 0000000000000000 000040 000004 00 AX 0 0 4
[ 5] .symtab SYMTAB 0000000000000000 000048 000090 18 6 6 8
[ 6] .strtab STRTAB 0000000000000000 0000d8 000004 00 0 0 1
[ 7] .shstrtab STRTAB 0000000000000000 0000dc 00003b 00 0 0 1
```
As a result of the LLVM behavior, we can end up misaligning the `.text.unlikely` section (e.g. if a preceding section contains data of size not a multiple of 4) and causing a crash at runtime.
I think the GNU as behavior makes more sense, and we should adopt that behavior.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVt9znDY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