Skip to content
This repository has been archived by the owner on Dec 9, 2018. It is now read-only.

Using lld as the linker #5

Open
japaric opened this issue Jul 30, 2016 · 2 comments
Open

Using lld as the linker #5

japaric opened this issue Jul 30, 2016 · 2 comments

Comments

@japaric
Copy link
Contributor

japaric commented Jul 30, 2016

$ xargo rustc --target x86_64 --release -- -C linker=false
$ ld.lld target/x86_64/release/kernel.0.o -o target/x86_64/release/kernel

Works and it doesn't implicitly link to libc or crt*.o like gcc does. But, because we didn't pass a linker script, the output binary doesn't have the right memory layout.

The problem is that lld doesn't support linker scripts as well as gcc/ld. In particular it doesn't support variables (e.g. header_start = .) or expressions (e.g. LONG(0)), though it does support "offsets" like . = 0x100000. This makes it impossible to implement the multiboot header in a linker script.

Update: Check the lld branch for more details.

@japaric
Copy link
Contributor Author

japaric commented Jul 30, 2016

This makes it impossible to implement the multiboot header in a linker script.

In the lld branch, I moved the multiboot header to an assembly file to be able to test linking with lld.

@japaric
Copy link
Contributor Author

japaric commented Aug 29, 2016

Sent PoC PR to the rust-lang/rust repo: rust-lang/rust#36120

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant