1package(default_visibility = ["//visibility:public"])
2
3exports_files(
4    [
5        "memmap_blocked_ram.ld",
6        "memmap_copy_to_ram.ld",
7        "memmap_default.ld",
8        "memmap_no_flash.ld",
9    ]
10)
11
12# It's possible to set linker scripts globally or on a per-binary basis.
13#
14# Setting globally:
15#   * Set --@pico-sdk//bazel/config:PICO_DEFAULT_LINKER_SCRIPT to point to your
16#     desired linker script.
17#
18# Setting per-binary:
19#   * Set --@pico-sdk//bazel/config:PICO_DEFAULT_LINKER_SCRIPT=@pico-sdk//bazel:empty_cc_lib
20#   * Manually add your desired linker script to each cc_binary.
21cc_library(
22    name = "default_linker_script",
23    linkopts = ["-T$(location memmap_default.ld)"],
24    target_compatible_with = ["//bazel/constraint:rp2040"],
25    deps = [
26        "memmap_default.ld",
27        "//src/rp2_common/pico_crt0:no_warn_rwx_flag",
28        "//src/rp2_common/pico_standard_link:default_flash_region",
29    ],
30)
31
32# PICO_BUILD_DEFINE: PICO_USE_BLOCKED_RAM, whether this is a 'blocked_ram' build, type=bool, default=0, but dependent on CMake options, group=pico_standard_link
33cc_library(
34    name = "blocked_ram_linker_script",
35    defines = ["PICO_USE_BLOCKED_RAM=1"],
36    linkopts = ["-T$(location memmap_blocked_ram.ld)"],
37    target_compatible_with = ["//bazel/constraint:rp2040"],
38    deps = [
39        "memmap_blocked_ram.ld",
40        "//src/rp2_common/pico_crt0:no_warn_rwx_flag",
41        "//src/rp2_common/pico_standard_link:default_flash_region",
42    ],
43)
44
45# PICO_BUILD_DEFINE: PICO_COPY_TO_RAM, whether this is a 'copy_to_ram' build, type=bool, default=0, but dependent on CMake options, group=pico_standard_link
46cc_library(
47    name = "copy_to_ram_linker_script",
48    defines = ["PICO_COPY_TO_RAM=1"],
49    linkopts = ["-T$(location memmap_copy_to_ram.ld)"],
50    target_compatible_with = ["//bazel/constraint:rp2040"],
51    deps = [
52        "memmap_copy_to_ram.ld",
53        "//src/rp2_common/pico_crt0:no_warn_rwx_flag",
54        "//src/rp2_common/pico_standard_link:default_flash_region",
55    ],
56)
57
58# PICO_BUILD_DEFINE: PICO_NO_FLASH, whether this is a 'no_flash' build, type=bool, default=0, but dependent on CMake options, group=pico_standard_link
59cc_library(
60    name = "no_flash_linker_script",
61    defines = ["PICO_NO_FLASH=1"],
62    linkopts = ["-T$(location memmap_no_flash.ld)"],
63    target_compatible_with = ["//bazel/constraint:rp2040"],
64    deps = [
65        "memmap_no_flash.ld",
66        "//src/rp2_common/pico_crt0:no_warn_rwx_flag",
67    ],
68)
69