The ELF spec says:<br><br><blockquote style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;" class="gmail_quote">All data structures that the object file format defines follow the "natural'' size and alignment guidelines for the relevant class. If necessary, data structures contain explicit padding to ensure 4-byte alignment for 4-byte objects, to force structure sizes to a multiple of 4, and so on. Data also have suitable alignment from the beginning of the file. Thus, for example, a structure containing an Elf32_Addr member will be aligned on a 4-byte boundary within the file.<br>


</blockquote><br>1. ELFObjectWriter doesn't write the following objects with correct file alignment: symtab, relocation sections, section headers. It probably goes unnoticed because most CPUs support unaligned memory accesses and get to the data without a problem plus linkers tend to fix things up too.  CPUs without unaligned accesses don't fare as well.<br>
<br>2. gas goes a step further than the rules above and ensures that even in relocatable output that a section's file offset is also a multiple of the section alignment. This behaviour falls out of the patch as well.<br>

<br>Krister<br><br>