mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-01-23 10:16:41 +00:00
compel: define arch_is_machine_supported
Check if ELF header complements ELF magic in per-arch way. Cc: Cyrill Gorcunov <gorcunov@openvz.org> Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com> Acked-by: Cyrill Gorcunov <gorcunov@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com> Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
parent
392469b697
commit
9efd30b6a1
5 changed files with 15 additions and 10 deletions
|
|
@ -4,6 +4,7 @@
|
|||
#include "uapi/elf64-types.h"
|
||||
|
||||
#define __handle_elf handle_elf_aarch64
|
||||
#define arch_is_machine_supported(e_machine) (e_machine == EM_AARCH64)
|
||||
|
||||
extern int handle_elf_aarch64(void *mem, size_t size);
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include "uapi/elf32-types.h"
|
||||
|
||||
#define __handle_elf handle_elf_arm
|
||||
#define arch_is_machine_supported(e_machine) (e_machine == EM_ARM)
|
||||
|
||||
extern int handle_elf_arm(void *mem, size_t size);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#define ELF_PPC64
|
||||
#define __handle_elf handle_elf_ppc64
|
||||
#define arch_is_machine_supported(e_machine) (e_machine == EM_PPC64)
|
||||
|
||||
extern int handle_elf_ppc64(void *mem, size_t size);
|
||||
|
||||
|
|
|
|||
|
|
@ -6,12 +6,14 @@
|
|||
#include "uapi/elf32-types.h"
|
||||
#define ELF_X86_32
|
||||
#define __handle_elf handle_elf_x86_32
|
||||
#define arch_is_machine_supported(e_machine) (e_machine == EM_386)
|
||||
|
||||
#else /* CONFIG_X86_64 */
|
||||
|
||||
#include "uapi/elf64-types.h"
|
||||
#define ELF_X86_64
|
||||
#define __handle_elf handle_elf_x86_64
|
||||
#define arch_is_machine_supported(e_machine) (e_machine == EM_X86_64)
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -61,6 +61,15 @@ static int do_relative_toc(long value, uint16_t *location,
|
|||
}
|
||||
#endif
|
||||
|
||||
static bool is_header_supported(Ehdr_t *hdr)
|
||||
{
|
||||
if (!arch_is_machine_supported(hdr->e_machine))
|
||||
return false;
|
||||
if (hdr->e_type != ET_REL || hdr->e_version != EV_CURRENT)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
int __handle_elf(void *mem, size_t size)
|
||||
{
|
||||
const char *symstrings = NULL;
|
||||
|
|
@ -83,19 +92,10 @@ int __handle_elf(void *mem, size_t size)
|
|||
pr_debug("\ttype 0x%x machine 0x%x version 0x%x\n",
|
||||
(unsigned)hdr->e_type, (unsigned)hdr->e_machine, (unsigned)hdr->e_version);
|
||||
|
||||
#ifdef ELF_X86_64
|
||||
if (hdr->e_type != ET_REL || hdr->e_machine != EM_X86_64 || hdr->e_version != EV_CURRENT) {
|
||||
if (!is_header_supported(hdr)) {
|
||||
pr_err("Unsupported header detected\n");
|
||||
goto err;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ELF_X86_32
|
||||
if (hdr->e_type != ET_REL || hdr->e_machine != EM_386 || hdr->e_version != EV_CURRENT) {
|
||||
pr_err("Unsupported header detected\n");
|
||||
goto err;
|
||||
}
|
||||
#endif
|
||||
|
||||
sec_hdrs = malloc(sizeof(*sec_hdrs) * hdr->e_shnum);
|
||||
if (!sec_hdrs) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue