Issue 115589
Summary LLD linker script link non stantard sections at address 0x0
Labels lld
Assignees
Reporter AntoninRuan
    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)

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to