VM/VFS: align ELF header buffer
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
This commit is contained in:
parent
139ae0da30
commit
5ba2e6e6e8
2 changed files with 8 additions and 2 deletions
|
@ -740,7 +740,12 @@ static int map_header(struct vfs_exec_info *execi)
|
|||
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 */
|
||||
|
||||
|
|
|
@ -333,7 +333,8 @@ static void exec_bootproc(struct vmproc *vmp, struct boot_image *ip)
|
|||
{
|
||||
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. */
|
||||
|
|
Loading…
Reference in a new issue