xref: /aosp_15_r20/external/pigweed/pw_build/bazel_internal/linker_script.ld (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1/*
2 * Copyright 2022 The Pigweed Authors
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License. You may obtain a copy of
6 * 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, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
14 * the License.
15 */
16
17/* This linker script is for test purposes only and should not be used in a
18 * production environment.
19*/
20#ifndef PW_BOOT_VECTOR_TABLE_BEGIN
21#error "PW_BOOT_VECTOR_TABLE_BEGIN is not defined, and is required to use pw_boot_cortex_m"
22#endif  // PW_BOOT_VECTOR_TABLE_BEGIN
23
24#include "header_test.h"
25#include "pw_build/must_place.ld.h"
26
27#ifndef SOME_USEFUL_LINKER_SCRIPT_MACRO
28#error "Header include test failed"
29#endif
30
31 /* Note: This technically doesn't set the firmware's entry point. Setting the
32 *       firmware entry point is done by setting vector_table[1]
33 *       (Reset_Handler). However, this DOES tell the compiler how to optimize
34 *       when --gc-sections is enabled.
35 */
36ENTRY(pw_boot_Entry)
37
38MEMORY
39{
40  /* TODO: b/234892223 - Make it possible for projects to freely customize
41   * memory regions.
42   */
43
44  /* Vector Table (typically in flash) */
45  VECTOR_TABLE(rx) : \
46    ORIGIN = PW_BOOT_VECTOR_TABLE_BEGIN, \
47    LENGTH = PW_BOOT_VECTOR_TABLE_SIZE
48  /* Internal Flash */
49  FLASH(rx) : \
50    ORIGIN = PW_BOOT_FLASH_BEGIN, \
51    LENGTH = PW_BOOT_FLASH_SIZE
52  /* Internal SRAM */
53  RAM(rwx) : \
54    ORIGIN = PW_BOOT_RAM_BEGIN, \
55    LENGTH = PW_BOOT_RAM_SIZE
56}
57
58/* Define a symbol used in the test source to verify that this linker script is
59 * actually used
60 */
61_linker_defined_symbol = 0xDEADBEEF;
62
63SECTIONS
64{
65  .code :
66  {
67    /* Exercise PW_MUST_PLACE macro on our test object file */
68    PW_MUST_PLACE(*/test.pic.o);
69  }
70}
71