ubsan.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _LIB_UBSAN_H
  3. #define _LIB_UBSAN_H
  4. enum {
  5. type_kind_int = 0,
  6. type_kind_float = 1,
  7. type_unknown = 0xffff
  8. };
  9. struct type_descriptor {
  10. u16 type_kind;
  11. u16 type_info;
  12. char type_name[1];
  13. };
  14. struct source_location {
  15. const char *file_name;
  16. union {
  17. unsigned long reported;
  18. struct {
  19. u32 line;
  20. u32 column;
  21. };
  22. };
  23. };
  24. struct overflow_data {
  25. struct source_location location;
  26. struct type_descriptor *type;
  27. };
  28. struct type_mismatch_data {
  29. struct source_location location;
  30. struct type_descriptor *type;
  31. unsigned long alignment;
  32. unsigned char type_check_kind;
  33. };
  34. struct type_mismatch_data_v1 {
  35. struct source_location location;
  36. struct type_descriptor *type;
  37. unsigned char log_alignment;
  38. unsigned char type_check_kind;
  39. };
  40. struct type_mismatch_data_common {
  41. struct source_location *location;
  42. struct type_descriptor *type;
  43. unsigned long alignment;
  44. unsigned char type_check_kind;
  45. };
  46. struct nonnull_arg_data {
  47. struct source_location location;
  48. struct source_location attr_location;
  49. int arg_index;
  50. };
  51. struct out_of_bounds_data {
  52. struct source_location location;
  53. struct type_descriptor *array_type;
  54. struct type_descriptor *index_type;
  55. };
  56. struct shift_out_of_bounds_data {
  57. struct source_location location;
  58. struct type_descriptor *lhs_type;
  59. struct type_descriptor *rhs_type;
  60. };
  61. struct unreachable_data {
  62. struct source_location location;
  63. };
  64. struct invalid_value_data {
  65. struct source_location location;
  66. struct type_descriptor *type;
  67. };
  68. struct alignment_assumption_data {
  69. struct source_location location;
  70. struct source_location assumption_location;
  71. struct type_descriptor *type;
  72. };
  73. #if defined(CONFIG_ARCH_SUPPORTS_INT128)
  74. typedef __int128 s_max;
  75. typedef unsigned __int128 u_max;
  76. #else
  77. typedef s64 s_max;
  78. typedef u64 u_max;
  79. #endif
  80. #endif