1/*
2 * Copyright (c) 2009 Corey Tabaka
3 * Copyright (c) 2013 Travis Geiselbrecht
4 * Copyright (c) 2015 Intel Corporation
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files
8 * (the "Software"), to deal in the Software without restriction,
9 * including without limitation the rights to use, copy, modify, merge,
10 * publish, distribute, sublicense, and/or sell copies of the Software,
11 * and to permit persons to whom the Software is furnished to do so,
12 * subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be
15 * included in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 */
25
26_start_phys = _start - %KERNEL_BASE% + %MEMBASE%;
27ENTRY(_start_phys)
28SECTIONS
29{
30    . = %KERNEL_BASE% + %KERNEL_LOAD_OFFSET%;
31
32    .text : AT(%MEMBASE% + %KERNEL_LOAD_OFFSET%) {
33        __code_start = .;
34        KEEP(*(.text.boot))
35        *(.text* .sram.text)
36        *(.gnu.linkonce.t.*)
37        __code_end = .;
38    } =0x9090
39
40    .rodata : ALIGN(4096) {
41        __rodata_start = .;
42        __fault_handler_table_start = .;
43        KEEP(*(.rodata.fault_handler_table))
44        __fault_handler_table_end = .;
45        *(.rodata .rodata.* .gnu.linkonce.r.*)
46        . = ALIGN(8);
47    }
48
49    .ctors : ALIGN(4) {
50        __ctor_list = .;
51        KEEP(*(SORT_BY_INIT_PRIORITY(.ctors.*) SORT_BY_INIT_PRIORITY(.init_array.*)))
52        KEEP(*(.ctors .init_array))
53        __ctor_end = .;
54    }
55    .dtors : ALIGN(4) {
56        __dtor_list = .;
57        KEEP(*(SORT_BY_INIT_PRIORITY(.dtors.*) SORT_BY_INIT_PRIORITY(.fini_array.*)))
58        KEEP(*(.dtors .fini_array))
59        __dtor_end = .;
60    }
61
62    /*
63     * .got and .dynamic need to follow .ctors and .dtors because the linker
64     * puts them all in the RELRO segment and wants them contiguous
65     */
66    .dynamic : { *(.dynamic) }
67    .got : { *(.got.plt) *(.got) }
68
69    /*
70     * extra linker scripts tend to insert sections just after .rodata,
71     * so we want to make sure this symbol comes after anything inserted above,
72     * but not aligned to the next section necessarily.
73     */
74    .fake_post_rodata : {
75        __rodata_end = .;
76    }
77
78    .data : ALIGN(4096) {
79        __data_start = .;
80        *(.data .data.* .gnu.linkonce.d.*)
81    }
82
83    .stab   : { *(.stab) }
84    .stabst : { *(.stabstr) }
85
86    /*
87     * extra linker scripts tend to insert sections just after .data,
88     * so we want to make sure this symbol comes after anything inserted above,
89     * but not aligned to the next section necessarily.
90     */
91    .fake_post_data : {
92        __data_end = .;
93    }
94
95    .bss : ALIGN(4096) {
96        __bss_start = .;
97        *(.bss*)
98        *(.gnu.linkonce.b.*)
99        *(COMMON)
100        . = ALIGN(8);
101        __bss_end = .;
102    }
103
104    _end = .;
105
106    /* put a symbol arbitrarily 4MB past the end of the kernel */
107    /* used by the heap and other early boot time allocators */
108    _end_of_ram = . + (4*1024*1024);
109
110    /DISCARD/ : { *(.comment .note .eh_frame) }
111}
112