libelf: fix symtab/strtab loading for 32bit domains
authorRoger Pau Monne <roger.pau@citrix.com>
Wed, 23 Nov 2016 12:27:38 +0000 (12:27 +0000)
committerWei Liu <wei.liu2@citrix.com>
Wed, 23 Nov 2016 12:59:47 +0000 (12:59 +0000)
commite5745b86e6e114f0e5b15bf67ed8d37a3d019f66
treeac216dbeb147ba002ac572567714c5d5bf2b44ba
parent986f790e0184d4bf575462077378e14fa9f85aa9
libelf: fix symtab/strtab loading for 32bit domains

Commit ed04ca introduced a bug in the symtab/strtab loading for 32bit
guests, that corrupted the section headers array due to the padding
introduced by the elf_shdr union.

The Elf section header array on 32bit should be accessible as an array of
Elf32_Shdr elements, and the union with Elf64_Shdr done in elf_shdr was
breaking this due to size differences between Elf32_Shdr and Elf64_Shdr.

Fix this by copying each section header one by one, and using the proper
size depending on the bitness of the guest kernel. While there, also fix
a couple of consistency issues, by making sure we always use the sizes of
our local versions of the ELF header and the ELF sections headers.

Reported-by: Brian Marcotte <marcotte@panix.com>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Release-acked-by: Wei Liu <wei.liu2@citrix.com>
xen/common/libelf/libelf-loader.c