[CRIU] [PATCH 2/5] pie: relocs -- Fix compilation on ARM
Cyrill Gorcunov
gorcunov at openvz.org
Thu Jun 11 11:22:19 PDT 2015
Otherwise getting
| parasite-syscall.c: In function ‘parasite_infect_seized’:
| parasite-syscall.c:1222:5: error: ‘elf_relocs’ undeclared (first use in this function)
Note we can't simply define some global @elf_relocs global variable
and reuse it inside elf_relocs_apply helper body. This is common
service routine which operates on both parasite code and restorer
code.
While @elf_relocs variable itself is defined in headers
(parasite-blob.h and restorer-blob.h) even if we define
them different names (saye @elf_relocs_parasite and
@elf_relocs_restorer) they simply can't be reffered
from common @elf_relocs_apply service routine at once.
Thus simply wrap the @elf_relocs_apply with macros.
Reported-by: Andrey Vagin <avagin at openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
cr-restore.c | 4 +---
parasite-syscall.c | 3 +--
pie/pie-relocs.h | 13 +++++++++++--
3 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/cr-restore.c b/cr-restore.c
index fbf80024da01..f254b46cc7a2 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -2390,9 +2390,7 @@ static int remap_restorer_blob(void *addr)
return -1;
}
- elf_relocs_apply(addr, addr, sizeof(restorer_blob),
- elf_relocs, ARRAY_SIZE(elf_relocs));
-
+ ELF_RELOCS_APPLY_RESTORER(addr, addr, restorer_blob);
return 0;
}
diff --git a/parasite-syscall.c b/parasite-syscall.c
index d6e9ce069c92..7b2a1b126734 100644
--- a/parasite-syscall.c
+++ b/parasite-syscall.c
@@ -1218,8 +1218,7 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item,
pr_info("Putting parasite blob into %p->%p\n", ctl->local_map, ctl->remote_map);
memcpy(ctl->local_map, parasite_blob, sizeof(parasite_blob));
- elf_relocs_apply(ctl->local_map, ctl->remote_map, sizeof(parasite_blob),
- elf_relocs, ARRAY_SIZE(elf_relocs));
+ ELF_RELOCS_APPLY_PARASITE(ctl->local_map, ctl->remote_map, parasite_blob);
/* Setup the rest of a control block */
ctl->parasite_ip = (unsigned long)parasite_sym(ctl->remote_map, __export_parasite_head_start);
diff --git a/pie/pie-relocs.h b/pie/pie-relocs.h
index 96f2bc9f2044..a3fabd41c6ac 100644
--- a/pie/pie-relocs.h
+++ b/pie/pie-relocs.h
@@ -7,11 +7,20 @@
#include "config.h"
#if defined(CONFIG_X86_64) || defined(CONFIG_X86_32) || defined(CONFIG_PPC64)
-#define PIE_SIZE(__blob_name) (round_up(sizeof(__blob_name) + nr_gotpcrel * sizeof(long), PAGE_SIZE))
+
extern __maybe_unused void elf_relocs_apply(void *mem, void *vbase, size_t size, elf_reloc_t *elf_relocs, size_t nr_relocs);
+#define PIE_SIZE(__blob_name) (round_up(sizeof(__blob_name) + nr_gotpcrel * sizeof(long), PAGE_SIZE))
+#define ELF_RELOCS_APPLY_PARASITE(mem, vbase, __blob_name) \
+ elf_relocs_apply(mem, vbase, sizeof(__blob_name), elf_relocs, ARRAY_SIZE(elf_relocs))
+#define ELF_RELOCS_APPLY_RESTORER(mem, vbase, __blob_name) \
+ elf_relocs_apply(mem, vbase, sizeof(__blob_name), elf_relocs, ARRAY_SIZE(elf_relocs))
+
#else
+
#define PIE_SIZE(__blob_name) (round_up(sizeof(__blob_name), PAGE_SIZE))
-static always_inline void elf_relocs_apply(void *mem, void *vbase, size_t size, elf_reloc_t *elf_relocs, size_t nr_relocs) { }
+#define ELF_RELOCS_APPLY_PARASITE(mem, vbase, __blob_name)
+#define ELF_RELOCS_APPLY_RESTORER(mem, vbase, __blob_name)
+
#endif
#endif /* __PIE_RELOCS_H__ */
--
2.4.2
More information about the CRIU
mailing list