• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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    /*
33     * Discard __cpu_indicator_init since we don't need it, and it touches
34     * xmm registers in clang-r530567 which we don't allow in the kernel
35     */
36    /DISCARD/ : {
37        *libclang_rt.builtins-x86_64-android.a:x86.c.o(
38            .text.__cpu_indicator_init
39            .rodata.__cpu_indicator_init
40            .init_array*
41        )
42    }
43
44    .text : AT(%MEMBASE% + %KERNEL_LOAD_OFFSET%) {
45        __code_start = .;
46        KEEP(*(.text.boot))
47        *(.text* .sram.text)
48        *(.gnu.linkonce.t.*)
49        __code_end = .;
50    } =0x9090
51
52    .rodata : ALIGN(4096) {
53        __rodata_start = .;
54        __fault_handler_table_start = .;
55        KEEP(*(.rodata.fault_handler_table))
56        __fault_handler_table_end = .;
57        *(.rodata .rodata.* .gnu.linkonce.r.*)
58        . = ALIGN(8);
59    }
60
61    .ctors : ALIGN(4) {
62        __ctor_list = .;
63        KEEP(*(SORT_BY_INIT_PRIORITY(.ctors.*) SORT_BY_INIT_PRIORITY(.init_array.*)))
64        KEEP(*(.ctors .init_array))
65        __ctor_end = .;
66    }
67    .dtors : ALIGN(4) {
68        __dtor_list = .;
69        KEEP(*(SORT_BY_INIT_PRIORITY(.dtors.*) SORT_BY_INIT_PRIORITY(.fini_array.*)))
70        KEEP(*(.dtors .fini_array))
71        __dtor_end = .;
72    }
73
74    /*
75     * .got and .dynamic need to follow .ctors and .dtors because the linker
76     * puts them all in the RELRO segment and wants them contiguous
77     */
78    .dynamic : { *(.dynamic) }
79    .got : { *(.got.plt) *(.got) }
80
81    /*
82     * extra linker scripts tend to insert sections just after .rodata,
83     * so we want to make sure this symbol comes after anything inserted above,
84     * but not aligned to the next section necessarily.
85     */
86    .fake_post_rodata : {
87        __rodata_end = .;
88    }
89
90    .data : ALIGN(4096) {
91        __data_start = .;
92        *(.data .data.* .gnu.linkonce.d.*)
93    }
94
95    .stab   : { *(.stab) }
96    .stabst : { *(.stabstr) }
97
98    /*
99     * extra linker scripts tend to insert sections just after .data,
100     * so we want to make sure this symbol comes after anything inserted above,
101     * but not aligned to the next section necessarily.
102     */
103    .fake_post_data : {
104        __data_end = .;
105    }
106
107    .bss : ALIGN(4096) {
108        __bss_start = .;
109        *(.bss*)
110        *(.gnu.linkonce.b.*)
111        *(COMMON)
112        . = ALIGN(8);
113        __bss_end = .;
114    }
115
116    _end = .;
117
118    /* put a symbol arbitrarily 4MB past the end of the kernel */
119    /* used by the heap and other early boot time allocators */
120    _end_of_ram = . + (4*1024*1024);
121
122    /DISCARD/ : { *(.comment .note .eh_frame) }
123}
124