Skip to content

Ubuntu22.04版本编译Linux内核5.4.34时遇到兼容性问题解决方案 #22

Description

@eagle-f

实验代码环境适配Ubuntu20.04及以下版本,使用Ubuntu22.04做的时候可能会出现兼容性问题,即make -j$(nproc)编译不通过等。可以通过以下方案解决,仅供参考:
新建一个文件thunkpatch.patch 填入:

 tools/objtool/elf.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
 
diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
index be89c741ba9a..2b0f4f52f7b5 100644
--- a/tools/objtool/elf.c
+++ b/tools/objtool/elf.c
@@ -380,8 +380,11 @@ static int read_symbols(struct elf *elf)
 
 	symtab = find_section_by_name(elf, ".symtab");
 	if (!symtab) {
-		WARN("missing symbol table");
-		return -1;
+		/*
+		 * A missing symbol table is actually possible if it's an empty
+		 * .o file.  This can happen for thunk_64.o.
+		 */
+		return 0;
 	}
 
 	symtab_shndx = find_section_by_name(elf, ".symtab_shndx");

--
2.29.2

然后在Linux源码目录下执行
patch -p1 < thunkpatch.patch所在目录/thunkpatch.patch
再次编译就可以解决问题。

该方案改变了elf.c文件中的read_symbols函数,使之忽略.o文件中缺少symbol table的情况,使得编译能顺利进行下去

转载自https://www.spinics.net/lists/kernel/msg3797871.html 详情可见该帖

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions