[CRIU] [PATCHv2 7/9] compel: Show descriptive error on common symbols

Dmitry Safonov dima at arista.com
Wed Mar 28 19:19:51 MSK 2018


So, I've added a global variable with name `pekaboo' and compiled
without -fno-common.

Before:
  GEN      criu/pie/parasite-blob.h
Error (compel/src/lib/handle-elf-host.c:359): Unexpected symbol section index 65522/9
make[2]: *** [criu/pie/Makefile:51: criu/pie/parasite-blob.h] Error 255
make[1]: *** [criu/Makefile:61: pie] Error 2
make: *** [Makefile:229: criu] Error 2

After:
  GEN      criu/pie/parasite-blob.h
Error (compel/src/lib/handle-elf-host.c:358): Common symbol: `pekaboo'
Error (compel/src/lib/handle-elf-host.c:359): Please, compile with -fno-common
make[2]: *** [criu/pie/Makefile:51: criu/pie/parasite-blob.h] Error 255
make[1]: *** [criu/Makefile:61: pie] Error 2
make: *** [Makefile:229: criu] Error 2

Cc: Cyrill Gorcunov <gorcunov at openvz.org>
Signed-off-by: Dmitry Safonov <dima at arista.com>
---
 compel/src/lib/handle-elf.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/compel/src/lib/handle-elf.c b/compel/src/lib/handle-elf.c
index f1cf74ff4f98..84f0be95900b 100644
--- a/compel/src/lib/handle-elf.c
+++ b/compel/src/lib/handle-elf.c
@@ -351,6 +351,14 @@ int __handle_elf(void *mem, size_t size)
 			if (sym->st_shndx == SHN_ABS) {
 				value32 = (int32_t)sym->st_value;
 				value64 = (int64_t)sym->st_value;
+			} else if (sym->st_shndx == SHN_COMMON) {
+				/*
+				 * We compiled with -fcommon.
+				 * This is not supposed to happen.
+				 */
+				pr_err("Common symbol: `%s'\n", name);
+				pr_err("Please, compile with -fno-common\n");
+				goto err;
 			} else {
 				Elf_Shdr *sh_src;
 
-- 
2.13.6



More information about the CRIU mailing list