[llvm-dev] Default linker script used by lld

Peter Smith via llvm-dev llvm-dev at lists.llvm.org
Mon Oct 25 09:19:30 PDT 2021

LLD, doesn't have a built-in linker script in the same way as GNU ld.bfd does.

Input Sections are mapped to OutputSections via a simple function https://github.com/llvm/llvm-project/blob/main/lld/ELF/Writer.cpp#L98 then sections are sorted according to rank in https://github.com/llvm/llvm-project/blob/main/lld/ELF/Writer.cpp#L98 hopefully the comments in those files will help reverse engineer a script that looks similar.

In practice the default linker behaviour will most significantly differ from ld.bfd by sorting ro-data before ro-code rather than after. This tends towards 3 PT_LOAD program headers ro, ro+exec, rw.

Hope that helps


From: llvm-dev <llvm-dev-bounces at lists.llvm.org> On Behalf Of jingduanyang via llvm-dev
Sent: 25 October 2021 12:54
To: llvm-dev at lists.llvm.org
Cc: Weiwei (weiwei, Compiler) <weiwei64 at huawei.com>; Zhangwen(Esan) <zwzhangwen.zhang at huawei.com>
Subject: [llvm-dev] Default linker script used by lld


Does anyone know the default linker script used by lld? This might be a silly question but I googled everywhere and couldn't find an answer...

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20211025/cdffda69/attachment.html>

More information about the llvm-dev mailing list