[llvm-commits] [PATCH] ELF file alignments

Roman Divacky rdivacky at freebsd.org
Tue Sep 7 13:31:43 PDT 2010


On Mon, Sep 06, 2010 at 05:48:06PM +0800, Krister Wombell wrote:
> The ELF spec says:
> 
> 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.
> >
> 
> 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.
> 
> 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.

hi, great patch!

I wonder - are you interested in working on the MC-ELF some more?

thank you, roman



More information about the llvm-commits mailing list