2

我正在从一个大的 C 文件(>50 000 LOC)构建 Linux 内核模块(LKM)。这是一些生成的 RAID 计算代码。当我尝试从 kbuild 构建它时,gcc 会吃掉所有内存并崩溃,而手动调用 gcc 可以正常工作。

从手动 gcc 和 kbuild 检查目标文件后,我发现 kbuild 目标文件比手动 gcc 对象大 20-30 倍(900k vs 30M)。原因是 kbuild 目标文件包含带有大量数据的巨大部分 debug_info。

这是来自的片段objdump -x

RELOCATION RECORDS FOR [.debug_info]:
OFFSET           TYPE              VALUE 
0000000000000006 R_X86_64_32       .debug_abbrev
000000000000000c R_X86_64_32       .debug_str+0x0000000000000c41
0000000000000011 R_X86_64_32       .debug_str+0x0000000000000e26
0000000000000015 R_X86_64_32       .debug_str+0x0000000000000544
0000000000000019 R_X86_64_64       .text 
0000000000000021 R_X86_64_64       .text+0x0000000000060957
0000000000000029 R_X86_64_32       .debug_line
0000000000000030 R_X86_64_32       .debug_str+0x0000000000000b78
0000000000000037 R_X86_64_32       .debug_str+0x000000000000011e
0000000000000040 R_X86_64_32       .debug_str+0x000000000000066b
0000000000000047 R_X86_64_32       .debug_str+0x0000000000000d38
000000000000004e R_X86_64_32       .debug_str+0x0000000000000bef
                  ... another 60000 records ...
00000000000a0c8d R_X86_64_32       .debug_str+0x0000000000000add
00000000000a0ca0 R_X86_64_32       .debug_str+0x0000000000000526
00000000000a0cae R_X86_64_64       Calculation_1s_Func_Buf

我已经试过EXTRA_CFLAG += -S了,没有运气。

那么有什么方法可以避免在使用 kbuild 构建时在我的目标文件中创建调试信息?

4

1 回答 1

2

您是否尝试过关闭 CONFIG_DEBUG_INFO?

在 menuconfig 中的 'Kernel Hacking' -> 'Compile-time checks and compiler options' -> 'Compile the kernel with debug info' 中查找它。

于 2013-11-20T10:32:57.140 回答