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

Submitted by Dmitry Safonov on March 28, 2018, 4:19 p.m.

Details

Message ID 20180328161953.16776-8-dima@arista.com
State New
Series "Large pages support for aarch64/ppc64"
Headers show

Commit Message

Dmitry Safonov March 28, 2018, 4:19 p.m.
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@openvz.org>
Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 compel/src/lib/handle-elf.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Patch hide | download patch | download mbox

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;