-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c83af88
commit 0fc55bb
Showing
20 changed files
with
250 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Asserts | ||
|
||
An assert ensures that a given condition is satified by the linking process, | ||
otherwise fail the link. | ||
|
||
GNU LD documentation for | ||
[`ASSERT`](https://sourceware.org/binutils/docs/ld/Miscellaneous-Commands.html#index-ASSERT) | ||
|
||
Every attribute listed is optional unless explicitly stated. | ||
|
||
## Table of contents | ||
|
||
- [Asserts](#asserts) | ||
- [Table of contents](#table-of-contents) | ||
- [`check`](#check) | ||
- [Example](#example) | ||
- [Valid values](#valid-values) | ||
- [error\_message](#error_message) | ||
- [Example](#example-1) | ||
- [Valid values](#valid-values-1) | ||
- [`include_if_any`, `include_if_all`, `exclude_if_any` and `exclude_if_all`](#include_if_any-include_if_all-exclude_if_any-and-exclude_if_all) | ||
|
||
## `check` | ||
|
||
This field is **required**. | ||
|
||
The actual condition to check. If this check evaluates to zero then the linker | ||
exits with an error code and prints [`error_message`](#error_message). | ||
|
||
### Example | ||
|
||
```yaml | ||
asserts: | ||
- check: boot_ROM_END <= 0x101000 | ||
error_message: boot segment is larger than 1 MiB | ||
``` | ||
### Valid values | ||
Non empty string. | ||
## error_message | ||
The error message to show if [`check`](#check) is not satisfied. | ||
|
||
### Example | ||
|
||
```yaml | ||
asserts: | ||
- check: boot_VRAM_END <= 0x80400000 | ||
error_message: VRAM is larger than 4 MiB | ||
include_if_any: [[ram_size, 4]] | ||
``` | ||
|
||
### Valid values | ||
|
||
Non empty string. | ||
|
||
## `include_if_any`, `include_if_all`, `exclude_if_any` and `exclude_if_all` | ||
|
||
These fields allow to conditionally include or exclude a given segment depending | ||
on the current [custom options](custom_options.md). | ||
|
||
Their syntax is the same as their [`file`](file.md#include_if_any) counterparts. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* SPDX-FileCopyrightText: © 2024 decompals */ | ||
/* SPDX-License-Identifier: MIT */ | ||
|
||
use serde::Deserialize; | ||
|
||
use crate::{absent_nullable::AbsentNullable, traits::Serial, Settings, SlinkyError}; | ||
|
||
#[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)] | ||
pub struct AssertEntry { | ||
pub check: String, | ||
pub error_message: String, | ||
|
||
pub include_if_any: Vec<(String, String)>, | ||
pub include_if_all: Vec<(String, String)>, | ||
pub exclude_if_any: Vec<(String, String)>, | ||
pub exclude_if_all: Vec<(String, String)>, | ||
} | ||
|
||
#[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd, Deserialize)] | ||
#[serde(deny_unknown_fields)] | ||
pub(crate) struct AssertEntrySerial { | ||
pub check: String, | ||
pub error_message: String, | ||
|
||
#[serde(default)] | ||
pub include_if_any: AbsentNullable<Vec<(String, String)>>, | ||
#[serde(default)] | ||
pub include_if_all: AbsentNullable<Vec<(String, String)>>, | ||
#[serde(default)] | ||
pub exclude_if_any: AbsentNullable<Vec<(String, String)>>, | ||
#[serde(default)] | ||
pub exclude_if_all: AbsentNullable<Vec<(String, String)>>, | ||
} | ||
|
||
impl Serial for AssertEntrySerial { | ||
type Output = AssertEntry; | ||
|
||
fn unserialize(self, _settings: &Settings) -> Result<Self::Output, SlinkyError> { | ||
if self.check.is_empty() { | ||
return Err(SlinkyError::EmptyValue { | ||
name: "check".to_string(), | ||
}); | ||
} | ||
let check = self.check; | ||
|
||
if self.error_message.is_empty() { | ||
return Err(SlinkyError::EmptyValue { | ||
name: "error_message".to_string(), | ||
}); | ||
} | ||
let error_message = self.error_message; | ||
|
||
let include_if_any = self | ||
.include_if_any | ||
.get_non_null_not_empty("include_if_any", Vec::new)?; | ||
let include_if_all = self | ||
.include_if_all | ||
.get_non_null_not_empty("include_if_all", Vec::new)?; | ||
let exclude_if_any = self | ||
.exclude_if_any | ||
.get_non_null_not_empty("exclude_if_any", Vec::new)?; | ||
let exclude_if_all = self | ||
.exclude_if_all | ||
.get_non_null_not_empty("exclude_if_all", Vec::new)?; | ||
|
||
Ok(Self::Output { | ||
check, | ||
error_message, | ||
include_if_any, | ||
include_if_all, | ||
exclude_if_any, | ||
exclude_if_all, | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -348,3 +348,5 @@ SECTIONS | |
} | ||
|
||
ENTRY(ENTRYPOINT); | ||
|
||
ASSERT((main_VRAM_END <= 0x80400000), "Error: VRAM is larger than 4 MiB"); |
Oops, something went wrong.