blob: e08fbe2a68d4f8a93aac1194f578851da0439a37 [file] [log] [blame]
Andrew Walbran15068b02022-03-22 15:57:34 +00001/*
2 * Copyright 2022 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17MEMORY
18{
19 dtb_region : ORIGIN = 0x80000000, LENGTH = 2M
20 image : ORIGIN = 0x80200000, LENGTH = 2M
21}
22
23/*
24 * Code will start running at this symbol which is placed at the start of the
25 * image.
26 */
27ENTRY(entry)
28
29/*
30 * The following would be useful to check that .init code is not called back
31 * into once it has completed but it isn't supported by ld.lld.
32 *
33 * NOCROSSREFS_TO(.init .text)
34 */
35
36SECTIONS
37{
38 .dtb (NOLOAD) : {
39 dtb_begin = .;
40 . += LENGTH(dtb_region);
41 dtb_end = .;
42 } >dtb_region
43
44 /*
45 * Collect together the code. This is page aligned so it can be mapped
46 * as executable-only.
47 */
48 .init : ALIGN(4096) {
49 text_begin = .;
50 *(.init.entry)
51 *(.init.*)
52 } >image
53 .text : {
54 *(.text.*)
55 } >image
56 text_end = .;
57
58 /*
59 * Collect together read-only data. This is page aligned so it can be
60 * mapped as read-only and non-executable.
61 */
62 .rodata : ALIGN(4096) {
63 rodata_begin = .;
64 *(.rodata.*)
65 } >image
66 .got : {
67 *(.got)
68 } >image
69 rodata_end = .;
70
71 /*
72 * Collect together the read-write data including .bss at the end which
73 * will be zero'd by the entry code. This is page aligned so it can be
74 * mapped as non-executable.
75 */
76 .data : ALIGN(4096) {
77 data_begin = .;
78 *(.data.*)
79 /*
80 * The entry point code assumes that .data is a multiple of 32
81 * bytes long.
82 */
83 . = ALIGN(32);
84 data_end = .;
85 } >image
86 /* Everything beyond this point will not be included in the binary. */
87 bin_end = .;
88
89 /* The entry point code assumes that .bss is 16-byte aligned. */
90 .bss : ALIGN(16) {
91 bss_begin = .;
92 *(.bss.*)
93 *(COMMON)
94 . = ALIGN(16);
95 bss_end = .;
96 } >image
97
98 .stack (NOLOAD) : ALIGN(4096) {
99 boot_stack_begin = .;
100 . += 40 * 4096;
101 . = ALIGN(4096);
102 boot_stack_end = .;
103 } >image
104
105 /*
106 * Remove unused sections from the image.
107 */
108 /DISCARD/ : {
109 /* The image loads itself so doesn't need these sections. */
110 *(.gnu.hash)
111 *(.hash)
112 *(.interp)
113 *(.eh_frame_hdr)
114 *(.eh_frame)
115 *(.note.gnu.build-id)
116 }
117}