Blame sysdeps/x86/check-cet.awk

Packit Service 82fcde
# Verify that all shared objects contain the CET property.
Packit Service 82fcde
# Copyright (C) 2018 Free Software Foundation, Inc.
Packit Service 82fcde
# This file is part of the GNU C Library.
Packit Service 82fcde
#
Packit Service 82fcde
# The GNU C Library is free software; you can redistribute it and/or
Packit Service 82fcde
# modify it under the terms of the GNU Lesser General Public
Packit Service 82fcde
# License as published by the Free Software Foundation; either
Packit Service 82fcde
# version 2.1 of the License, or (at your option) any later version.
Packit Service 82fcde
#
Packit Service 82fcde
# The GNU C Library is distributed in the hope that it will be useful,
Packit Service 82fcde
# but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 82fcde
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 82fcde
# Lesser General Public License for more details.
Packit Service 82fcde
#
Packit Service 82fcde
# You should have received a copy of the GNU Lesser General Public
Packit Service 82fcde
# License along with the GNU C Library; if not, see
Packit Service 82fcde
# <http://www.gnu.org/licenses/>.
Packit Service 82fcde
Packit Service 82fcde
# This awk script expects to get command-line files that are each
Packit Service 82fcde
# the output of 'readelf -n' on a single shared object.
Packit Service 82fcde
# It exits successfully (0) if all of them contained the CET property.
Packit Service 82fcde
# It fails (1) if any didn't contain the CET property
Packit Service 82fcde
# It fails (2) if the input did not take the expected form.
Packit Service 82fcde
Packit Service 82fcde
BEGIN { result = cet = sanity = 0 }
Packit Service 82fcde
Packit Service 82fcde
function check_one(name) {
Packit Service 82fcde
  if (!sanity) {
Packit Service 82fcde
    print name ": *** input did not look like readelf -n output";
Packit Service 82fcde
    result = 2;
Packit Service 82fcde
  } else if (cet) {
Packit Service 82fcde
    print name ": OK";
Packit Service 82fcde
  } else {
Packit Service 82fcde
    print name ": *** no CET property found";
Packit Service 82fcde
    result = result ? result : 1;
Packit Service 82fcde
  }
Packit Service 82fcde
Packit Service 82fcde
  cet = sanity = 0;
Packit Service 82fcde
}
Packit Service 82fcde
Packit Service 82fcde
FILENAME != lastfile {
Packit Service 82fcde
  if (lastfile)
Packit Service 82fcde
    check_one(lastfile);
Packit Service 82fcde
  lastfile = FILENAME;
Packit Service 82fcde
}
Packit Service 82fcde
Packit Service 82fcde
index ($0, "Displaying notes") != 0 { sanity = 1 }
Packit Service 82fcde
index ($0, "IBT") != 0 && index ($0, "SHSTK") != 0 { cet = 1 }
Packit Service 82fcde
Packit Service 82fcde
END {
Packit Service 82fcde
  check_one(lastfile);
Packit Service 82fcde
  exit(result);
Packit Service 82fcde
}