| -- |
| -- Copyright 2023 Google LLC |
| -- |
| -- Licensed under the Apache License, Version 2.0 (the "License"); |
| -- you may not use this file except in compliance with the License. |
| -- You may obtain a copy of the License at |
| -- |
| -- http://www.apache.org/licenses/LICENSE-2.0 |
| -- |
| -- Unless required by applicable law or agreed to in writing, software |
| -- distributed under the License is distributed on an "AS IS" BASIS, |
| -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| -- See the License for the specific language governing permissions and |
| -- limitations under the License. |
| |
| set_project("CHERIoT buffer overflow avoidance demo") |
| |
| local shodan_dir = os.getenv("ROOTDIR") |
| if shodan_dir == nil or shodan_dir == '' then |
| raise("ROOTDIR not set") |
| end |
| |
| local sdkdir = path.join(shodan_dir, "sw/cheriot-rtos/sdk") |
| includes(sdkdir) |
| set_toolchains("cheriot-clang") |
| |
| option("board") |
| set_default("sencha") |
| |
| -- Support libraries |
| includes(path.join(sdkdir, "lib")) |
| includes(path.join(sdkdir, "lib/freestanding")) |
| |
| -- Application. |
| compartment("buffer_overflow") |
| add_files("buffer_overflow.cc") |
| add_deps("debug") |
| add_defines("CHERIOT_NO_AMBIENT_MALLOC") |
| |
| -- Firmware image. |
| firmware("buffer_overflow-firmware") |
| add_deps("buffer_overflow") |
| add_deps("freestanding") |
| on_load(function(target) |
| target:values_set("board", "$(board)") |
| local threads = { |
| { |
| compartment = "buffer_overflow", |
| priority = 1, |
| entry_point = "entry", |
| stack_size = 0x1000, -- 4KB |
| trusted_stack_frames = 1 |
| }, |
| } |
| target:values_set("threads", threads, {expand = false}) |
| end) |