gpt4 book ai didi

compiler-errors - 问题编译内核

转载 作者:行者123 更新时间:2023-12-02 10:55:57 25 4
gpt4 key购买 nike

我在构建Linux内核版本3.16时遇到问题。我在5.8.9-zen上构建。
这是make ARCH=x86_64的输出:

HOSTLD  arch/x86/tools/relocs
/usr/bin/ld: arch/x86/tools/relocs_64.o:(.bss+0x0): multiple definition of `per_cpu_load_addr'; arch/x86/tools/relocs_32.o:(.bss+0x0): first defined here
collect2: error: ld returned 1 exit status
make[1]: *** [scripts/Makefile.host:127: arch/x86/tools/relocs] Error 1
make: *** [arch/x86/Makefile:189: archscripts] Error 2

最佳答案

从内核3.18中 cherry-pick 提交eeeda4cd06e828b331b15741a204ff9f5874d28d(或应用patch)似乎可以解决问题。

From eeeda4cd06e828b331b15741a204ff9f5874d28d Mon Sep 17 00:00:00 2001
From: Ben Hutchings <ben@decadent.org.uk>
Date: Wed, 24 Sep 2014 13:30:12 +0100
Subject: x86/relocs: Make per_cpu_load_addr static

per_cpu_load_addr is only used for 64-bit relocations, but is
declared in both configurations of relocs.c - with different
types. This has undefined behaviour in general. GNU ld is
documented to use the larger size in this case, but other tools
may differ and some warn about this.

References: https://bugs.debian.org/748577
Reported-by: Michael Tautschnig <mt@debian.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Cc: 748577@bugs.debian.org
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: http://lkml.kernel.org/r/1411561812.3659.23.camel@decadent.org.uk
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/x86/tools/relocs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
index bbb1d2259ecf5..a5efb21d5228b 100644
--- a/arch/x86/tools/relocs.c
+++ b/arch/x86/tools/relocs.c
@@ -695,7 +695,7 @@ static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel,
*
*/
static int per_cpu_shndx = -1;
-Elf_Addr per_cpu_load_addr;
+static Elf_Addr per_cpu_load_addr;

static void percpu_init(void)
{

关于compiler-errors - 问题编译内核,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64130032/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com