check-cet.awk 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # Verify that all shared objects contain the CET property.
  2. # Copyright (C) 2018-2019 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. # <http://www.gnu.org/licenses/>.
  18. # This awk script expects to get command-line files that are each
  19. # the output of 'readelf -n' on a single shared object.
  20. # It exits successfully (0) if all of them contained the CET property.
  21. # It fails (1) if any didn't contain the CET property
  22. # It fails (2) if the input did not take the expected form.
  23. BEGIN { result = cet = sanity = 0 }
  24. function check_one(name) {
  25. if (!sanity) {
  26. print name ": *** input did not look like readelf -n output";
  27. result = 2;
  28. } else if (cet) {
  29. print name ": OK";
  30. } else {
  31. print name ": *** no CET property found";
  32. result = result ? result : 1;
  33. }
  34. cet = sanity = 0;
  35. }
  36. FILENAME != lastfile {
  37. if (lastfile)
  38. check_one(lastfile);
  39. lastfile = FILENAME;
  40. }
  41. index ($0, "Displaying notes") != 0 { sanity = 1 }
  42. index ($0, "IBT") != 0 && index ($0, "SHSTK") != 0 { cet = 1 }
  43. END {
  44. check_one(lastfile);
  45. exit(result);
  46. }