aboutsummaryrefslogtreecommitdiff
path: root/linker.ld
blob: 7b585dcc64a4cbe3bc2546c0198125dd9d85c9ef (plain)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
ENTRY(_boot) /* defined in boot.S; qemu needs it to run elf file */
 
SECTIONS
{
    /* Starts at  0x8000 - that's where RPis in 32-bit mode load */
    /* kernel at. My experiments do, however, show, that qemu */
    /* emulating RPi2 loads the kernel at 0x10000! (took some pain */
    /* to find out). rpi-open-firmware, on the other hand, loads */
    /* kernel at 0x2000000! */
    /* This is not really a problem, since: */
    /*   1. We can use our bootloader to load the kernel at 0x8000 */
    /*   2. We compile kernel with -fPIC, so it should be able to */
    /*      work with any load addr. */
    /*   3. In qemu, we can load kernel.elf instead of raw binary */
    /*      (qemu will do the right thing then) */

    . = 0x8000;

    /* RPi in 64-bit mode uses address 0x80000 instead */
    
    __start = .;
    .kernel :
    {
        __kernel_start = .;
	KEEP(boot.o)
	*(EXCLUDE_FILE (ramfs_embeddable.o libkernel.o interrupt_vector.o interrupts.o) *)
	. = ALIGN(4);
	ramfs_embeddable.o
	__kernel_end = .;
    }
    __kernel_size = __kernel_end - __kernel_start;


    /* libkernel */
    .libkernel :
    {
	__libkernel_start = .;
	libkernel.o
	__libkernel_end = .;
    }
    __libkernel_size = __libkernel_end - __libkernel_start;


    .interrupts :
    {
	__interrupts_start = .;
	KEEP(*(.interrupts.vector))
	interrupt_vector.o
	interrupts.o
    	__interrupts_end = .;
    }
    __interrupts_size = __interrupts_end - __interrupts_start;
    
    __end = .;

    _stack_top = __start;
}