check-endbr.sh works well with gawk, but fails with mawk. The produced
$ALL file is smaller, it is missing 0x$vma_lo on every line. On mawk,
int(0x2A) just produce 0, instead of the expected value.
The use of hexadecimal-constant in awk is an optional part of the
posix spec, and mawk doesn't seems to implemented.
There is a way to convert an hexadecimal to a number be putting it in
a string, and awk as I understand is supposed to use strtod() to
convert the string to a number when needed. The expression
'int("0x15") + 21' would produce the expected value in `mawk` but now
`gawk` won't convert the string to a number unless we use the option
"--non-decimal-data".
So let's convert the hexadecimal number before using it in the awk
script. The shell as no issue with dealing with hexadecimal-constant
so we'll simply use the expression "$(( 0x15 ))" to convert the value
before using it in awk.
Fixes: 4d037425dc ("x86: Build check for embedded endbr64 instructions")
Reported-by: Luca Fancellu <[email protected]>
Reported-by: Mathieu Tarral <[email protected]>
Signed-off-by: Anthony PERARD <[email protected]>
---
xen/tools/check-endbr.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/xen/tools/check-endbr.sh b/xen/tools/check-endbr.sh
index 552f233912..64fa9a56b7 100755
--- a/xen/tools/check-endbr.sh
+++ b/xen/tools/check-endbr.sh
@@ -78,7 +78,7 @@ then
else
grep -aob -e "$(printf '\363\17\36\372')" -e "$(printf '\363\17\36\373')" \
-e "$(printf '\146\17\37\1')" $TEXT_BIN
-fi | awk -F':' '{printf "%s%x\n", "'$vma_hi'", int(0x'$vma_lo') + $1}' > $ALL
+fi | awk -F':' '{printf "%s%x\n", "'$vma_hi'", int('$((0x$vma_lo))') + $1}' >
$ALL
# Wait for $VALID to become complete
wait
--
Anthony PERARD