<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/115589>115589</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            LLD linker script link non stantard sections at address 0x0
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            lld
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          AntoninRuan
      </td>
    </tr>
</table>

<pre>
    I was trying to link using a custom linker script that contains a non stantards sections for the output. And this sections always ends up at address ``0x0`` no matters where I put it in the script. Linking using gnu ld doesn't have this behavior and gives what seems the logical output for me. I realized I may not need these custom sections but I'm still curious why is it happening and if I'm missing something or if it is a bug

Here's my linking command

```
ld.lld -n -T kernel/arch/x86-64/linker.ld -o sysroot/boot/colibri.kernel  <all my objects files>  --Map build/kernel.map
```

<details><summary>My linker script</summary>
<p>

```
ENTRY(_start)

SECTIONS
{
        . = 2M;

      .protected_mode :
      {
 *(.protected_mode)
      }

        .text ALIGN(4K) :
        {
                *(.multiboot)
                *(.text)
        }

        /* Read-only data. */
        .rodata ALIGN(4K) :
        {
                *(.rodata)
        }

        /* Read-write data (initialized) */
        .data ALIGN(4K) :
        {
                *(.data)
        }

        /* Read-write data (uninitialized) and stack */
        .bss ALIGN(4K) :
        {
                *(COMMON)
                *(.bss)
        }
}
```
</p>
</details> 

Here the memory map output of both lld and gnu ld:

[lld.txt](https://github.com/user-attachments/files/17686350/lld.txt)

[gnu_ld.txt](https://github.com/user-attachments/files/17686349/gnu_ld.txt)

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyslUtv4zYQgH8NfRlYkCg_5IMOjh21RpMssLuXngJKHFtsKFIgh0ncX19QcmLHGxTdtoagBzmPb4aeGeG9OhjEks1v2Hw7EYFa68q1IWuU-RqEmdRWHssdvAgP5I7KHIAsaGWeIPj4JaAJnmw3rKED3zjVE1ArCBprSCjjQYCx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