Page 1 of 1

Section LMA overlap

Posted: Sun May 27, 2018 1:11 pm
by TopSekret
Hey everybody!

I am trying to develop a kernel. I use advanced linker scripting, because I want it to be debuggable both before and after higher half switch. Thus, I use the AT() parameter extensibly. However, I am getting a strange linker error:

Code: Select all

/home/jakub/.local/stow/i686-elf-toolchain/lib/gcc/i686-elf/9.0.0/../../../../i686-elf/bin/ld: section .rodata LMA [ffffffff40000000,ffffffff40000017] overlaps section .text LMA [ffffffff40000000,ffffffff4000004d]
The full linker script is:

Code: Select all

ENTRY (_start);

SECTIONS
{
  . = 0x00100000;

  PROVIDE (_begin = .);

  .text.early BLOCK (4K) : ALIGN (4K)
  {
    *(.text.early);
  }

  . += 0xC0000000;

  .text BLOCK (4K) : AT (. - 0xC0000000) ALIGN (4K)
  {
    *(.text);
  }

  .rodata BLOCK (4K) : AT (. - 0xC0000000) ALIGN (4K)
  {
    *(.rodata);
  }

  .data BLOCK (4K) : AT (. - 0xC0000000) ALIGN (4K)
  {
    *(.data);

    . = ALIGN (4K);
  }

  PROVIDE (_edata = .);

  .bss BLOCK (4K) : AT (. - 0xC0000000) ALIGN (4K)
  {
    *(COMMON);
    *(.bss);

    /*
     * PABSS is Page Aligned BSS.
     *
     * Everything in PABSS has to be aligned to 4K.
     */
    . = ALIGN (4K);
    *(.pabss);

    . = ALIGN (4K);
  }

  PROVIDE (_end = .);
}
Am I missing something or is this a bug?

Thanks in advance!

Re: Section LMA overlap

Posted: Sun May 27, 2018 1:35 pm
by TopSekret
OK, I figured it out by myself.

The section should look like:

Code: Select all

.somesection BLOCK (4K) : AT (ADDR (.somesection) - 0xC0000000) ALIGN (4K)