2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-28 12:57:57 +00:00

58 Commits

Author SHA1 Message Date
Dmitry Safonov
12ca38255c compel: remove not needed from uapi
Delete plugins/include/asm/std directory - let it be without plugin name.
Make symlinks to reuse criu's files, except those, which will
be deleted after libcompel from criu (like syscalls).

Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:09 +03:00
Cyrill Gorcunov
a437c2d969 compel: Add plugins header
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:09 +03:00
Cyrill Gorcunov
3b0c8dbd48 compel: Reshuffle the directories structure
Here we rather suffle source code into directories
preparing ground for future work.

Basically all this files movements should end up in the
following compel/ tree structure

compel/
├── arch
│   ├── aarch64
│   │   ├── plugins
│   │   │   └── std
│   │   └── src
│   │       └── lib
│   ├── arm
	...
│   ├── ppc64
	...
│   └── x86
	...

	This is architectural part, where each arch consists of
	plugins/, and src/. src/ stands for code needed by compel
	cli + lib

├── include
│   ├── compiler.h -> ../../criu/include/compiler.h
│   ├── elf32-types.h
│   ├── elf64-types.h
│   ├── int.h -> ../../criu/include/asm-generic/int.h
│   ├── piegen.h
│   ├── shmem.h
│   └── uapi
│       ├── compel.h
│       └── plugins.h

	Common includes + uapi

├── plugins
│   ├── fds
│   ├── shmem
│   └── std

	Plugins source code

└── src
    ├── lib
    │   ├── handle-elf-32.c -> handle-elf.c
    │   ├── handle-elf-32-host.c -> handle-elf-32.c
    │   ├── handle-elf.c
    │   └── handle-elf-host.c -> handle-elf.c

	compel library

    ├── main.c
    ├── main-host.c -> main.c

	compel cli

    └── shared
        └── fds.c

	shared code between plugins and compel cli

Note: cross-compile won't work for a while.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:09 +03:00
Cyrill Gorcunov
596767d5f7 compel: uapi -- Add standalone headers
Will be used later.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 23:58:08 +03:00
Dmitry Safonov
3c966037d8 compel/tests: add sections table & string section tests
Now it has 4 new tests:
ok 4 - section table start oob (64-bit ELF)
ok 5 - too many sections in table (64-bit ELF)
ok 6 - strings section's header oob of section table (64-bit ELF)
ok 7 - strings section oob (64-bit ELF)

I.e, if we forget to test string section's header oob with the next diff:
>--- a/compel/handle-elf.c
>+++ b/compel/handle-elf.c
>@@ -122,7 +122,7 @@ static const char *get_strings_section(Ehdr_t *hdr, uintptr_t mem,
>                pr_err("String section @%#zx size %#lx is out of [%#zx, %#zx)\n",
>                        addr, (unsigned long)secstrings_hdr->sh_size,
>                        mem, mem + size);
>-               return NULL;
>+               return (void*)addr;
>        }
>
>        return (void*)addr;

It will yell with:
ok 1 - zero ELF header (64-bit ELF)
...
not ok 6 - strings section's header oob of section table (64-bit ELF), expected -4 but ret is -1
...
not ok 12 - strings section's header oob of section table (32-bit ELF), expected -4 but ret is -1

Should be more useful when I add relocations tests after all.
(but this seems for me useful too).

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Reviewed-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 21:03:30 +03:00
Dmitry Safonov
89978b5b1d compel: add error constants
For tests, we need to know if elf file parsing was interrupted
in a proper place (and thus meaningful error numbers).

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 21:03:29 +03:00
Dmitry Safonov
427f68f0a3 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: 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>
2017-03-14 21:03:22 +03:00
Cyrill Gorcunov
acfa85ba5a compel: Initial commit for standalone tool
The compel component is a replacement for several aspects of CRIU
functionality: binary blobs generation for PIE parasite/restore code,
and a library for parasite code injection and execution (to be implemented).

In the commit we rather shuffle compel into own directory and
use it for

1) Fetching cflags when compiling PIE blobs
2) Use its "piegen" functionality to generate blobs themselves.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-14 21:03:20 +03:00