The libexec ELF parser expects to be given a word-aligned buffer,
but the ASR pass may cause VM and VFS to pass it an arbitrarily
aligned buffer, causing libexec to refuse loading the executable.
This patch aligns the buffers explicitly.
Change-Id: Ic2d5fd3a8f204c3e4f000cffdb7ac71c8339257a
int r;
size_t cum_io;
off_t pos, new_pos;
- static char hdr[PAGE_SIZE]; /* Assume that header is not larger than a page */
+ /* Assume that header is not larger than a page. Align the buffer reasonably
+ * well, because libexec casts it to a structure directly and therefore
+ * expects it to be aligned appropriately. From here we can only guess the
+ * proper alignment, but 64 bits should work for all versions of ELF..
+ */
+ static char hdr[PAGE_SIZE] __aligned(8);
pos = 0; /* Read from the start of the file */
{
struct vm_exec_info vmexeci;
struct exec_info *execi = &vmexeci.execi;
- char hdr[VM_PAGE_SIZE];
+ /* libexec need proper alignment for casting to structures */
+ char hdr[VM_PAGE_SIZE] __aligned(8);
size_t frame_size = 0; /* Size of the new initial stack. */
int argc = 0; /* Argument count. */