aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/development/ld/link-nomem.ld
blob: 32b7f3cf37e7f3db6812e329e9cd04ea93a4ccf1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
OUTPUT_FORMAT(elf64-x86-64)
ENTRY(_entry)

SECTIONS {
    /* Set the initial location counter (vaddr) */
    . = 0x00800000;

    /* Create .text output section at current vaddr */
    .text : {
        *(.text*)
    }

    ASSERT(. == 0x00800000 + SIZEOF(.text), "inc loc counter automatically")

    /* Create .data section at location counter aligned to the next 0x100 (vaddr) */
    /* Set the load address to  0x00100000 (paddr) */
    .data ALIGN(0x100) : AT(0x00100000) {
        HIDDEN(_data_vaddr = .);
        HIDDEN(_data_paddr = LOADADDR(.data));
        *(.data*)
    }

    /* Create .rodata with explicit vaddr */
    /* Re-adjust the paddr location counter */
    .rodata 0x00804000 : AT(ADDR(.rodata)) {
        *(.rodata*)
    }

    ASSERT(. == 0x00804000 + SIZEOF(.rodata), "inc loc counter automatically")

    .stack ALIGN (0x1000) : {
        . += 0x1000;
        HIDDEN(_stack_top = .);
    }

    /DISCARD/ : {
        *(.*)
    }
}

/* Some example assertions */
ASSERT(ADDR(.data) != LOADADDR(.data), "DATA vaddr and paddr must be different")
ASSERT(SIZEOF(.stack) == 0x1000, "STACK section must be 0x1000")