Dear All,
I've been trying to rebuild the X86 Bare Bones tutorial, but this time using LLVM toolchain instead of using GCC. Boot.s & kernel.c compiled, but when using linker (ld.lld), it says it doesn't understand BLOCK(4K). I've tried removing the BLOCK(4K) to just ALIGN (4K) in the linker.ld, which compiled this time, but when booted by QEMU (using GRUB) it's not recognized as multiboot and not loaded.
PS: Building it all using GCC cross-compile i686-elf was successful, not fuss on that, and booted correctly. Only using LLVM toolchain (clang & ld.lld) didn't end up as well as GCC.
2nd note: I used ld.lld directly (and indeed ld when compiling with GCC) instead via clang because my clang keeps using the native linker (ld.lld) and not the directed one (using GCC_EXEC_PREFIX, using PATH, using -B, all to no avail).
Has anyone experience compiling with LLVM before? Any help I can get? Thanks.
LLVM's LD.LLD Doesn't Understand BLOCK(4K)
-
- Posts: 2
- Joined: Thu Dec 10, 2020 10:51 am
Re: LLVM's LD.LLD Doesn't Understand BLOCK(4K)
For one thing, to make clang use LLD, pass -fuse-ld=lld to clang. Also, try this
That's what I use, and it works everywhere for me.
Code: Select all
ENTRY(_start)
SECTIONS
{
. = 0x100000;
.multiboot : {
*(.multiboot)
}
.text ALIGN (4096) : {
*(.text)
}
.data ALIGN (4096) : {
*(.data)
}
.rodata ALIGN (4096) : {
*(.rodata)
}
.bss ALIGN (4096) : {
*(COMMON)
*(.bss)
}
end = .; _end = .;
}
-
- Posts: 2
- Joined: Thu Dec 10, 2020 10:51 am
Re: LLVM's LD.LLD Doesn't Understand BLOCK(4K)
OK, now that confirms that it wasn't the linker file, it was how my clang's compile args getting messed up. Since I've messed up the whole toolchain (that's why I can't just use --fuse-ld=lld, it just use the native one and not my "specially-built" llvm in a separate folder, as is the GCC and the bits of libraries here and there) and basically confused myself, I'll retry with new, fresh debian VM (instead of WSL) and get back to square one first. I'll setup a new toolchain, and then report to see if the whole thing is fixed.nexos wrote:For one thing, to make clang use LLD, pass -fuse-ld=lld to clang. Also, try thisThat's what I use, and it works everywhere for me.Code: Select all
ENTRY(_start) SECTIONS { . = 0x100000; .multiboot : { *(.multiboot) } .text ALIGN (4096) : { *(.text) } .data ALIGN (4096) : { *(.data) } .rodata ALIGN (4096) : { *(.rodata) } .bss ALIGN (4096) : { *(COMMON) *(.bss) } end = .; _end = .; }
Thanks, Nexos
Re: LLVM's LD.LLD Doesn't Understand BLOCK(4K)
Your welcome! Personally, I would stick to GNU. I ran into more LLD problems a little bit ago, so I'll focus on supporting GNU .