vtv_utils.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* Copyright (C) 2012-2022 Free Software Foundation, Inc.
  2. This file is part of GCC.
  3. GCC is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 3, or (at your option)
  6. any later version.
  7. GCC is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. Under Section 7 of GPL version 3, you are granted additional
  12. permissions described in the GCC Runtime Library Exception, version
  13. 3.1, as published by the Free Software Foundation.
  14. You should have received a copy of the GNU General Public License and
  15. a copy of the GCC Runtime Library Exception along with this program;
  16. see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  17. <http://www.gnu.org/licenses/>. */
  18. #ifndef _VTV_UTILS_H
  19. #define _VTV_UTILS_H 1
  20. #include <stdlib.h>
  21. #include "../include/vtv-change-permission.h"
  22. static inline void
  23. VTV_not_an_error (void)
  24. {
  25. }
  26. /* Handler for verification runtime errors. */
  27. #define VTV_error abort
  28. /* Assertion macros used in vtable verification runtime. */
  29. #define VTV_ASSERT(EXPR) \
  30. if (!(EXPR)) VTV_error();
  31. #ifdef VTV_DEBUG
  32. #define VTV_DEBUG_ASSERT(EXPR) \
  33. ((bool) (!(EXPR)) ? VTV_error() : (void) 0)
  34. #else
  35. #define VTV_DEBUG_ASSERT(EXPR) ((void) 0)
  36. #endif
  37. /* Name of the section where we put general VTV variables for protection */
  38. #define VTV_PROTECTED_VARS_SECTION ".vtable_map_vars"
  39. #define VTV_PROTECTED_VAR \
  40. __attribute__ ((section (VTV_PROTECTED_VARS_SECTION)))
  41. /* The following logging routines try to use low level file access
  42. routines and avoid calling malloc. We need this so that we dont
  43. disturb the order of calls to dlopen. Changing the order of dlopen
  44. calls may lead to deadlocks */
  45. int __vtv_open_log (const char * name);
  46. int __vtv_add_to_log (int log, const char * format, ...);
  47. void __vtv_log_verification_failure (const char *, bool);
  48. #endif /* VTV_UTILS_H */