1# Verify that all shared objects contain the CET property. 2# Copyright (C) 2018-2021 Free Software Foundation, Inc. 3# This file is part of the GNU C Library. 4# 5# The GNU C Library is free software; you can redistribute it and/or 6# modify it under the terms of the GNU Lesser General Public 7# License as published by the Free Software Foundation; either 8# version 2.1 of the License, or (at your option) any later version. 9# 10# The GNU C Library is distributed in the hope that it will be useful, 11# but WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13# Lesser General Public License for more details. 14# 15# You should have received a copy of the GNU Lesser General Public 16# License along with the GNU C Library; if not, see 17# <https://www.gnu.org/licenses/>. 18 19# This awk script expects to get command-line files that are each 20# the output of 'readelf -n' on a single shared object. 21# It exits successfully (0) if all of them contained the CET property. 22# It fails (1) if any didn't contain the CET property 23# It fails (2) if the input did not take the expected form. 24 25BEGIN { result = cet = sanity = 0 } 26 27function check_one(name) { 28 if (!sanity) { 29 print name ": *** input did not look like readelf -n output"; 30 result = 2; 31 } else if (cet) { 32 print name ": OK"; 33 } else { 34 print name ": *** no CET property found"; 35 result = result ? result : 1; 36 } 37 38 cet = sanity = 0; 39} 40 41FILENAME != lastfile { 42 if (lastfile) 43 check_one(lastfile); 44 lastfile = FILENAME; 45} 46 47index ($0, "Displaying notes") != 0 { sanity = 1 } 48index ($0, "IBT") != 0 && index ($0, "SHSTK") != 0 { cet = 1 } 49 50END { 51 check_one(lastfile); 52 exit(result); 53} 54