Switching from LD to LLD causes QEMU to crash.

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
ffexl
Posts: 2
Joined: Wed Apr 23, 2025 11:16 pm

Switching from LD to LLD causes QEMU to crash.

Post by ffexl »

For reference, I am using Clang for my toolchain.

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")
This works in QEMU.

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")
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:

Code: Select all

qemu-system-i386: Error loading uncompressed kernel without PVH ELF Note logout
How do I fix this error and utilize LLD without it bricking the kernel?
ffexl
Posts: 2
Joined: Wed Apr 23, 2025 11:16 pm

Re: Switching from LD to LLD causes QEMU to crash.

Post by ffexl »

I actually used the ALIGN() replacements for BLOCK() with LD, and it still ran in QEMU. The problem seems to be with the arguments passed to LLD, not the replacements made in linker.ld.
Post Reply