diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2024-01-09 12:23:26 -0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2024-01-10 05:20:16 -0800 |
commit | 7d544dd049a2e3f1480b668f51b72dcc89e376ab (patch) | |
tree | 9418b350bb32cc02b052b35159d6ac181787a4ba /sysdeps/x86_64 | |
parent | a1bbee9fd17a84d4b550f8405d5e4d31ff24f87d (diff) | |
download | glibc-7d544dd049a2e3f1480b668f51b72dcc89e376ab.tar.gz glibc-7d544dd049a2e3f1480b668f51b72dcc89e376ab.tar.xz glibc-7d544dd049a2e3f1480b668f51b72dcc89e376ab.zip |
x86-64/cet: Move check-cet.awk to x86_64
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Diffstat (limited to 'sysdeps/x86_64')
-rw-r--r-- | sysdeps/x86_64/Makefile | 2 | ||||
-rw-r--r-- | sysdeps/x86_64/check-cet.awk | 53 |
2 files changed, 54 insertions, 1 deletions
diff --git a/sysdeps/x86_64/Makefile b/sysdeps/x86_64/Makefile index 98f0e04f90..e8babc9a4e 100644 --- a/sysdeps/x86_64/Makefile +++ b/sysdeps/x86_64/Makefile @@ -468,7 +468,7 @@ $(cet-built-dso:=.note): %.note: % mv -f $@T $@ common-generated += $(cet-built-dso:$(common-objpfx)%=%.note) -$(objpfx)check-cet.out: $(..)sysdeps/x86/check-cet.awk \ +$(objpfx)check-cet.out: $(..)sysdeps/x86_64/check-cet.awk \ $(cet-built-dso:=.note) LC_ALL=C $(AWK) -f $^ > $@; \ $(evaluate-test) diff --git a/sysdeps/x86_64/check-cet.awk b/sysdeps/x86_64/check-cet.awk new file mode 100644 index 0000000000..ede16bdf1d --- /dev/null +++ b/sysdeps/x86_64/check-cet.awk @@ -0,0 +1,53 @@ +# Verify that all shared objects contain the CET property. +# Copyright (C) 2018-2024 Free Software Foundation, Inc. +# This file is part of the GNU C Library. +# +# The GNU C Library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# The GNU C Library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with the GNU C Library; if not, see +# <https://www.gnu.org/licenses/>. + +# This awk script expects to get command-line files that are each +# the output of 'readelf -n' on a single shared object. +# It exits successfully (0) if all of them contained the CET property. +# It fails (1) if any didn't contain the CET property +# It fails (2) if the input did not take the expected form. + +BEGIN { result = cet = sanity = 0 } + +function check_one(name) { + if (!sanity) { + print name ": *** input did not look like readelf -n output"; + result = 2; + } else if (cet) { + print name ": OK"; + } else { + print name ": *** no CET property found"; + result = result ? result : 1; + } + + cet = sanity = 0; +} + +FILENAME != lastfile { + if (lastfile) + check_one(lastfile); + lastfile = FILENAME; +} + +index ($0, "Displaying notes") != 0 { sanity = 1 } +index ($0, "IBT") != 0 && index ($0, "SHSTK") != 0 { cet = 1 } + +END { + check_one(lastfile); + exit(result); +} |