link kernel时出错

ld的报错如下

Linking kernel...
ld -b elf64-x86-64 -z muldefs  -o kernel  ../target/x86_64-unknown-none/release/libdragonos_kernel.a -T arch/x86_64/link.lds --no-relax
ld: warning: bea14715b6ee797b-entry.o: missing .note.GNU-stack section implies executable stack
ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
../target/x86_64-unknown-none/release/libdragonos_kernel.a(8637ce008291fa2d-libunwind.o): in function `libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_x86_64>::getRegisterName(int)':
libunwind.cpp:(.text._ZN9libunwind12UnwindCursorINS_17LocalAddressSpaceENS_16Registers_x86_64EE15getRegisterNameEi[_ZN9libunwind12UnwindCursorINS_17LocalAddressSpaceENS_16Registers_x86_64EE15getRegisterNameEi]+0x4): relocation truncated to fit: R_X86_64_32 against `.rodata._ZN9libunwind12UnwindCursorINS_17LocalAddressSpaceENS_16Registers_x86_64EE15getRegisterNameEi.str1.1'
libunwind.cpp:(.text._ZN9libunwind12UnwindCursorINS_17LocalAddressSpaceENS_16Registers_x86_64EE15getRegisterNameEi[_ZN9libunwind12UnwindCursorINS_17LocalAddressSpaceENS_16Registers_x86_64EE15getRegisterNameEi]+0x11): relocation truncated to fit: R_X86_64_32S against `.rodata.CSWTCH.239'
../target/x86_64-unknown-none/release/libdragonos_kernel.a(8637ce008291fa2d-libunwind.o): in function `libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_x86_64>::getFunctionName(char*, unsigned long, unsigned long*)':
libunwind.cpp:(.text._ZN9libunwind12UnwindCursorINS_17LocalAddressSpaceENS_16Registers_x86_64EE15getFunctionNameEPcmPm[_ZN9libunwind12UnwindCursorINS_17LocalAddressSpaceENS_16Registers_x86_64EE15getFunctionNameEPcmPm]+0x9): relocation truncated to fit: R_X86_64_32S against symbol `libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_x86_64>::getReg(int)' defined in .text._ZN9libunwind12UnwindCursorINS_17LocalAddressSpaceENS_16Registers_x86_64EE6getRegEi[_ZN9libunwind12UnwindCursorINS_17LocalAddressSpaceENS_16Registers_x86_64EE6getRegEi] section in ../target/x86_64-unknown-none/release/libdragonos_kernel.a(8637ce008291fa2d-libunwind.o)
../target/x86_64-unknown-none/release/libdragonos_kernel.a(8637ce008291fa2d-libunwind.o): in function `libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_x86_64>::setReg(int, unsigned long)':
libunwind.cpp:(.text._ZN9libunwind12UnwindCursorINS_17LocalAddressSpaceENS_16Registers_x86_64EE6setRegEim[_ZN9libunwind12UnwindCursorINS_17LocalAddressSpaceENS_16Registers_x86_64EE6setRegEim]+0xf): relocation truncated to fit: R_X86_64_32S against `.rodata._ZN9libunwind12UnwindCursorINS_17LocalAddressSpaceENS_16Registers_x86_64EE6setRegEim'
../target/x86_64-unknown-none/release/libdragonos_kernel.a(8637ce008291fa2d-libunwind.o): in function `libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_x86_64>::getReg(int)':
libunwind.cpp:(.text._ZN9libunwind12UnwindCursorINS_17LocalAddressSpaceENS_16Registers_x86_64EE6getRegEi[_ZN9libunwind12UnwindCursorINS_17LocalAddressSpaceENS_16Registers_x86_64EE6getRegEi]+0xf): relocation truncated to fit: R_X86_64_32S against `.rodata._ZN9libunwind12UnwindCursorINS_17LocalAddressSpaceENS_16Registers_x86_64EE6getRegEi'
../target/x86_64-unknown-none/release/libdragonos_kernel.a(8637ce008291fa2d-libunwind.o): in function `libunwind::CFI_Parser<libunwind::LocalAddressSpace>::parseFDEInstructions(libunwind::LocalAddressSpace&, libunwind::CFI_Parser<libunwind::LocalAddressSpace>::FDE_Info const&, libunwind::CFI_Parser<libunwind::LocalAddressSpace>::CIE_Info const&, unsigned long, int, libunwind::CFI_Parser<libunwind::LocalAddressSpace>::PrologInfo*) [clone .isra.0]':
libunwind.cpp:(.text._ZN9libunwind10CFI_ParserINS_17LocalAddressSpaceEE20parseFDEInstructionsERS1_RKNS2_8FDE_InfoERKNS2_8CIE_InfoEmiPNS2_10PrologInfoE.isra.0+0xd4): relocation truncated to fit: R_X86_64_32S against `.rodata._ZN9libunwind10CFI_ParserINS_17LocalAddressSpaceEE20parseFDEInstructionsERS1_RKNS2_8FDE_InfoERKNS2_8CIE_InfoEmiPNS2_10PrologInfoE.isra.0'
libunwind.cpp:(.text._ZN9libunwind10CFI_ParserINS_17LocalAddressSpaceEE20parseFDEInstructionsERS1_RKNS2_8FDE_InfoERKNS2_8CIE_InfoEmiPNS2_10PrologInfoE.isra.0+0x1a26): relocation truncated to fit: R_X86_64_32S against `.rodata._ZN9libunwind10CFI_ParserINS_17LocalAddressSpaceEE20parseFDEInstructionsERS1_RKNS2_8FDE_InfoERKNS2_8CIE_InfoEmiPNS2_10PrologInfoE.isra.0'
../target/x86_64-unknown-none/release/libdragonos_kernel.a(8637ce008291fa2d-libunwind.o): in function `libunwind::CFI_Parser<libunwind::LocalAddressSpace>::parseCIE(libunwind::LocalAddressSpace&, unsigned long, libunwind::CFI_Parser<libunwind::LocalAddressSpace>::CIE_Info*) [clone .isra.0]':
libunwind.cpp:(.text._ZN9libunwind10CFI_ParserINS_17LocalAddressSpaceEE8parseCIEERS1_mPNS2_8CIE_InfoE.isra.0+0x451): relocation truncated to fit: R_X86_64_32 against `.rodata._ZN9libunwind12UnwindCursorINS_17LocalAddressSpaceENS_16Registers_x86_64EE15getRegisterNameEi.str1.1'
libunwind.cpp:(.text._ZN9libunwind10CFI_ParserINS_17LocalAddressSpaceEE8parseCIEERS1_mPNS2_8CIE_InfoE.isra.0+0x461): relocation truncated to fit: R_X86_64_32 against `.rodata._ZN9libunwind12UnwindCursorINS_17LocalAddressSpaceENS_16Registers_x86_64EE15getRegisterNameEi.str1.1'
libunwind.cpp:(.text._ZN9libunwind10CFI_ParserINS_17LocalAddressSpaceEE8parseCIEERS1_mPNS2_8CIE_InfoE.isra.0+0x5a9): relocation truncated to fit: R_X86_64_32S against `.rodata._ZN9libunwind10CFI_ParserINS_17LocalAddressSpaceEE8parseCIEERS1_mPNS2_8CIE_InfoE.isra.0'
../target/x86_64-unknown-none/release/libdragonos_kernel.a(8637ce008291fa2d-libunwind.o): in function `libunwind::DwarfInstructions<libunwind::LocalAddressSpace, libunwind::Registers_x86_64>::evaluateExpression(unsigned long, libunwind::LocalAddressSpace&, libunwind::Registers_x86_64 const&, unsigned long) [clone .isra.0]':
libunwind.cpp:(.text._ZN9libunwind17DwarfInstructionsINS_17LocalAddressSpaceENS_16Registers_x86_64EE18evaluateExpressionEmRS1_RKS2_m.isra.0+0x158): additional relocation overflows omitted from the output
make: *** [Makefile:77: __link_x86_64_kernel] Error 1

我在 ff76b0f中仍会出现该问题
OS: Ubuntu 24.04.1 LTS on Windows 10 x86_64
Kernel: 5.15.153.1-microsoft-standard-WSL2

这个问题在CentOS、TencentOS上面也会出现。我估计是链接器配置有点不一样。

原生的ubuntu24是无问题的。

主要错误出在了mini-backtrace这个库里面,引用了llvm unwind.
我在想,如果可以实现新的backtrace库(同时支持x86_64和rv64的),应该这个问题就不存在了?

cc @linfeng @Chiichen

我研究研究这个mini-backtrace,应该可以换掉

1 个赞

在最新的master中,能成功编译了
但一进系统就卡住了,什么都没打印,serial_opt里也是空的

make clean了吗

是的 (凑8个字)

如果我没记错的话,在ubuntu22的时候还是能跑的

同样的unwinding库,在asterinas中是能正常进系统的,不知道为什么在DragonOS中不行