Commit 427f68f0 authored by Dmitry Safonov's avatar Dmitry Safonov Committed by Andrei Vagin

compel: shuffle skeleton a bit

I propose to change compel directory structure:
- if we want support more arch's than x86/ppc66, it seems
  worth to add arch/ folder
- move all sources from src/ folder up
- to have headers and build additional object with CFLAGS for
  a symlink seems for me less hacky way than mess around
  with .c files cross-linking
- I made handle-elf.h header for arch helpers code. I may named
  that just "elf.h", but that may confuse, as there are <elf.h>
  system header
- I would like to drop those ELF_PPC64/ELF_X86_32/ELF_X86_64
  defines and use CONFIG_X86_64 and whatnot

After this patch compel directory become:
compel/
├── arch
│   ├── ppc64
│   │   └── include
│   │       └── handle-elf.h
│   └── x86
│       └── include
│           └── handle-elf.h
├── handle-elf-32.c -> handle-elf.c
├── handle-elf.c
├── include
│   ├── piegen.h
│   └── uapi
│       ├── elf32-types.h
│       ├── elf64-types.h
│       └── types.h
├── main.c
└── Makefile

Note: temporary I make value32 and addend32 for compilation on arm/aarch64

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarDmitry Safonov <dsafonov@virtuozzo.com>
Acked-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 4bccd6a6
......@@ -2,6 +2,7 @@ include $(SRC_DIR)/Makefile.versions
ccflags-y += -iquote criu/include
ccflags-y += -iquote compel/include
ccflags-y += -iquote compel/arch/$(ARCH)/include
ccflags-y += -DCOMPEL_VERSION=\"$(COMPEL_SO_VERSION_MAJOR).$(COMPEL_SO_VERSION_MINOR)\"
host-ccflags-y += $(filter-out -pg $(CFLAGS-GCOV),$(ccflags-y))
......@@ -9,12 +10,19 @@ HOSTCFLAGS += $(filter-out -pg $(CFLAGS-GCOV),$(WARNINGS) $(DEFINES))
HOSTLDFLAGS += $(filter-out -pg $(CFLAGS-GCOV),$(LDFLAGS))
hostprogs-y += compel
compel-objs += src/main.o
compel-objs += main.o
compel-objs += handle-elf.o
ifneq ($(filter ia32 x86, $(ARCH)),)
compel-objs += src/elf-x86-32.o
compel-objs += src/elf-x86-64.o
endif
ifeq ($(SRCARCH),ppc64)
compel-objs += src/elf-ppc64.o
# Add $(DEFINES) to CFLAGS of compel-objs.
# We can't do ccflags-y += $(DEFINES)
# as we need to build handle-elf-32.o
# with -DCONFIG_X86_32
define ccflags-defines
HOSTCFLAGS_$(1) += $(DEFINES)
endef
$(eval $(call map,ccflags-defines,$(compel-objs)))
ifeq ($(ARCH),x86)
compel-objs += handle-elf-32.o
HOSTCFLAGS_handle-elf-32.o += -DCONFIG_X86_32
endif
#ifndef __COMPEL_HANDLE_ELF_H__
#define __COMPEL_HANDLE_ELF_H__
#include "uapi/elf32-types.h"
#define ELF_PPC64
#define handle_elf handle_elf_ppc64
#endif /* __COMPEL_HANDLE_ELF_H__ */
#ifndef __COMPEL_HANDLE_ELF_H__
#define __COMPEL_HANDLE_ELF_H__
#ifdef CONFIG_X86_32
#include "uapi/elf32-types.h"
#define ELF_X86_32
#define handle_elf handle_elf_x86_32
#else /* CONFIG_X86_64 */
#include "uapi/elf64-types.h"
#define ELF_X86_64
#define handle_elf handle_elf_x86_64
#endif
#endif /* __COMPEL_HANDLE_ELF_H__ */
handle-elf.c
\ No newline at end of file
......@@ -16,6 +16,7 @@
#include "common/compiler.h"
#include "piegen.h"
#include "handle-elf.h"
static bool __ptr_oob(const void *ptr, const void *start, const size_t size)
{
......@@ -219,7 +220,7 @@ int handle_elf(void *mem, size_t size)
for (k = 0; k < sh->sh_size / sh->sh_entsize; k++) {
s64 __maybe_unused addend64, __maybe_unused value64;
s32 addend32, value32;
s32 __maybe_unused addend32, __maybe_unused value32;
unsigned long place;
const char *name;
void *where;
......
#define ELF_X86_32
#define handle_elf handle_elf_x86_32
#ifndef __COMPEL_ELF32_TYPES_H__
#define __COMPEL_ELF32_TYPES_H__
#define Ehdr_t Elf32_Ehdr
#define Shdr_t Elf32_Shdr
......@@ -13,4 +13,4 @@
#define ELF_R_SYM ELF32_R_SYM
#define ELF_R_TYPE ELF32_R_TYPE
#include "elf.c"
#endif /* __COMPEL_ELF32_TYPES_H__ */
#define ELF_PPC64
#define handle_elf handle_elf_ppc64
#ifndef __COMPEL_ELF64_TYPES_H__
#define __COMPEL_ELF64_TYPES_H__
#define Ehdr_t Elf64_Ehdr
#define Shdr_t Elf64_Shdr
......@@ -13,4 +13,4 @@
#define ELF_R_SYM ELF64_R_SYM
#define ELF_R_TYPE ELF64_R_TYPE
#include "elf.c"
#endif /* __COMPEL_ELF64_TYPES_H__ */
#define ELF_X86_64
#define handle_elf handle_elf_x86_64
#define Ehdr_t Elf64_Ehdr
#define Shdr_t Elf64_Shdr
#define Sym_t Elf64_Sym
#define Rel_t Elf64_Rel
#define Rela_t Elf64_Rela
#define ELF_ST_TYPE ELF64_ST_TYPE
#define ELF_ST_BIND ELF64_ST_BIND
#define ELF_R_SYM ELF64_R_SYM
#define ELF_R_TYPE ELF64_R_TYPE
#include "elf.c"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment