[llvm-dev] Default linker script used by lld

Fāng-ruì Sòng via llvm-dev llvm-dev at lists.llvm.org
Mon Oct 25 10:18:46 PDT 2021


On Mon, Oct 25, 2021 at 9:19 AM Peter Smith via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
>
> 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
>
>
>
> Peter

I noted down some linker script differences in
https://maskray.me/blog/2020-12-19-lld-and-gnu-linker-incompatibilities

There was a feature request about dumping an internal linker script
https://bugs.llvm.org/show_bug.cgi?id=51309 but it would significantly
increase complexity without justifiable benefit. In addition, some
built-in processing cannot be serialized into a linker script. So I
closed it :)

>
>
> 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
>
>
>
> Hi,
>
>
>
> 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…
>
>
>
> Thanks,
>
> Duanyang
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev



-- 
宋方睿


More information about the llvm-dev mailing list