Switching from LD to LLD causes QEMU to crash.
Posted: Wed Apr 23, 2025 11:26 pm
For reference, I am using Clang for my toolchain.
In my CMake file, I am currently using LD with: This works in QEMU.
I want to use LLD with: In my linker.ld, (default linker.ld from https://wiki.osdev.org/Bare_Bones#Linking_the_Kernel) LLD requires me to change the BLOCK(4K) directives to ALIGN(4K) directives because BLOCK() isn't supported by LLD (I have been told that BLOCK() and ALIGN() are equivalent) This completely bricks my kernel with the QEMU message:
How do I fix this error and utilize LLD without it bricking the kernel?
In my CMake file, I am currently using LD with:
Code: Select all
set_target_properties(${KERNEL_BIN} PROPERTIES LINK_FLAGS "-T ${CMAKE_SOURCE_DIR}/${LINKER} -ffreestanding -nostdlib")
I want to use LLD with:
Code: Select all
set_target_properties(${KERNEL_BIN} PROPERTIES LINK_FLAGS "-Wl,-T,${CMAKE_SOURCE_DIR}/${LINKER} -fuse-ld=lld -ffreestanding -nostdlib -static")
Code: Select all
qemu-system-i386: Error loading uncompressed kernel without PVH ELF Note logout