forked from xen-project/xen
-
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.
automation/eclair_analysis: deviate linker symbols for Rule 18.2
MISRA C Rule 18.2 states: "Subtraction between pointers shall only be applied to pointers that address elements of the same array". Subtractions between pointer where at least one symbol is a symbol defined by the linker are safe and thus deviated, because the compiler cannot exploit the undefined behaviour that would arise from violating the rules in this case. To create an ECLAIR configuration that contains the list of linker-defined symbols, the script "linker-symbols.sh" is used after a build of xen (without static analysis) is performed. The generated file "linker_symbols.ecl" is then used as part of the static analysis configuration. Additional changes to the ECLAIR integration are: - perform a build of xen without static analysis during prepare.sh - run the scripts to generated ECL configuration during the prepare.sh, rather than analysis.sh - export ECLAIR_PROJECT_ROOT earlier, to allow such generation Additionally, the macro page_to_mfn performs a subtraction that is safe, so its uses are deviated. No functional changes. Signed-off-by: Nicola Vetrini <[email protected]> Acked-by: Stefano Stabellini <[email protected]>
- Loading branch information
1 parent
4b3f30e
commit 33888e7
Showing
7 changed files
with
63 additions
and
7 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
31 changes: 31 additions & 0 deletions
31
automation/eclair_analysis/ECLAIR/generate-linker-symbols.sh
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,31 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
script_name="$(basename "$0")" | ||
script_dir="$( | ||
cd "$(dirname "$0")" | ||
echo "${PWD}" | ||
)" | ||
|
||
fatal() { | ||
echo "${script_name}: $*" >&2 | ||
exit 1 | ||
} | ||
|
||
arch="" | ||
if [ "${XEN_TARGET_ARCH}" == "x86_64" ]; then | ||
arch=x86 | ||
elif [ "${XEN_TARGET_ARCH}" == "arm64" ]; then | ||
arch=arm | ||
else | ||
fatal "Unknown configuration: $1" | ||
fi | ||
|
||
outfile=${script_dir}/linker_symbols.ecl | ||
|
||
( | ||
echo -n "-decl_selector+={linker_symbols, \"^(" >"${outfile}" | ||
"${script_dir}/../linker-symbols.sh" "${arch}" | sort -u | tr '\n' '|' | sed '$ s/|//' >>"${outfile}" | ||
echo -n ")$\"}" >>"${outfile}" | ||
) |
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