libelf: rewrite symtab/strtab loading
authorRoger Pau Monne <roger.pau@citrix.com>
Thu, 31 Mar 2016 16:00:22 +0000 (18:00 +0200)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Fri, 1 Apr 2016 14:02:52 +0000 (15:02 +0100)
commited04ca95981f539fec7b9d242d0ca0176e92cc23
treee61cbee41f55d5519cdd9773e0a08e5d8641b6bf
parentf31c790d45df9f587becc282dd6a7ec292a2fb6d
libelf: rewrite symtab/strtab loading

Current implementation of elf_load_bsdsyms is broken when loading inside of
a HVM guest, because it assumes elf_memcpy_safe is able to write into guest
memory space, which it is not.

Take the oportunity to do some cleanup and properly document how
elf_{parse/load}_bsdsyms works. The new implementation uses elf_load_image
when dealing with data that needs to be copied to the guest memory space.
Also reduce the number of section headers copied to the minimum necessary.

This patch also removes the duplication of code found in the libxc ELF
loader, since the libelf symtab/strtab loading code will also handle this
case without having to duplicate it.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/libxc/xc_dom_elfloader.c
xen/common/libelf/libelf-loader.c