-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[UBSan] [compiler-rt] [NFC] split minimal rt handlers into inc #168140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
fmayer
wants to merge
1
commit into
main
from
users/fmayer/spr/ubsan-compiler-rt-nfc-split-minimal-rt-handlers-into-inc
Closed
[UBSan] [compiler-rt] [NFC] split minimal rt handlers into inc #168140
fmayer
wants to merge
1
commit into
main
from
users/fmayer/spr/ubsan-compiler-rt-nfc-split-minimal-rt-handlers-into-inc
+58
−37
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Created using spr 1.3.7
Member
|
@llvm/pr-subscribers-compiler-rt-sanitizer Author: Florian Mayer (fmayer) Changes(A copy of) this will be used later to add the handlers to Full diff: https://github.com/llvm/llvm-project/pull/168140.diff 2 Files Affected:
diff --git a/compiler-rt/lib/ubsan_minimal/UbsanMinimalHandlers.inc b/compiler-rt/lib/ubsan_minimal/UbsanMinimalHandlers.inc
new file mode 100644
index 0000000000000..6d78bca0483cc
--- /dev/null
+++ b/compiler-rt/lib/ubsan_minimal/UbsanMinimalHandlers.inc
@@ -0,0 +1,45 @@
+/*===-- UbsanMinimalHandlers.inc - ubsan minimum handlers ------*- C++ -*-=== *\
+|*
+|* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+|* See https://llvm.org/LICENSE.txt for license information.
+|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+|*
+\*===----------------------------------------------------------------------===*/
+
+#ifndef UBSAN_HANDLER_PTR
+#define UBSAN_HANDLER_PTR(Enum, String)
+#endif
+
+#ifndef UBSAN_HANDLER
+#define UBSAN_HANDLER(Enum, String)
+#endif
+
+#ifndef UBSAN_HANDLER_RECOVER
+#define UBSAN_HANDLER_RECOVER(Enum, String)
+#endif
+
+UBSAN_HANDLER_PTR(type_mismatch, "type-mismatch")
+UBSAN_HANDLER(alignment_assumption, "alignment-assumption")
+UBSAN_HANDLER(add_overflow, "add-overflow")
+UBSAN_HANDLER(sub_overflow, "sub-overflow")
+UBSAN_HANDLER(mul_overflow, "mul-overflow")
+UBSAN_HANDLER(negate_overflow, "negate-overflow")
+UBSAN_HANDLER(divrem_overflow, "divrem-overflow")
+UBSAN_HANDLER(shift_out_of_bounds, "shift-out-of-bounds")
+UBSAN_HANDLER(out_of_bounds, "out-of-bounds")
+UBSAN_HANDLER(local_out_of_bounds, "local-out-of-bounds")
+UBSAN_HANDLER_RECOVER(builtin_unreachable, "builtin-unreachable")
+UBSAN_HANDLER_RECOVER(missing_return, "missing-return")
+UBSAN_HANDLER(vla_bound_not_positive, "vla-bound-not-positive")
+UBSAN_HANDLER(float_cast_overflow, "float-cast-overflow")
+UBSAN_HANDLER(load_invalid_value, "load-invalid-value")
+UBSAN_HANDLER(invalid_builtin, "invalid-builtin")
+UBSAN_HANDLER(invalid_objc_cast, "invalid-objc-cast")
+UBSAN_HANDLER(function_type_mismatch, "function-type-mismatch")
+UBSAN_HANDLER(implicit_conversion, "implicit-conversion")
+UBSAN_HANDLER(nonnull_arg, "nonnull-arg")
+UBSAN_HANDLER(nonnull_return, "nonnull-return")
+UBSAN_HANDLER(nullability_arg, "nullability-arg")
+UBSAN_HANDLER(nullability_return, "nullability-return")
+UBSAN_HANDLER(pointer_overflow, "pointer-overflow")
+UBSAN_HANDLER(cfi_check_fail, "cfi-check-fail")
diff --git a/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp b/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp
index a2a2e36e8523d..61d65d60369a9 100644
--- a/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp
+++ b/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp
@@ -127,28 +127,28 @@ void NORETURN CheckFailed(const char *file, int, const char *cond, u64, u64) {
#define INTERFACE extern "C" __attribute__((visibility("default")))
-#define HANDLER_RECOVER(name, kind) \
+#define UBSAN_HANDLER_RECOVER(name, kind) \
INTERFACE void __ubsan_handle_##name##_minimal() { \
__ubsan_report_error(kind, GET_CALLER_PC(), nullptr); \
}
-#define HANDLER_NORECOVER(name, kind) \
+#define UBSAN_HANDLER_NORECOVER(name, kind) \
INTERFACE void __ubsan_handle_##name##_minimal_abort() { \
uintptr_t caller = GET_CALLER_PC(); \
__ubsan_report_error_fatal(kind, caller, nullptr); \
abort_with_message(kind, caller, nullptr); \
}
-#define HANDLER(name, kind) \
- HANDLER_RECOVER(name, kind) \
- HANDLER_NORECOVER(name, kind)
+#define UBSAN_HANDLER(name, kind) \
+ UBSAN_HANDLER_RECOVER(name, kind) \
+ UBSAN_HANDLER_NORECOVER(name, kind)
-#define HANDLER_RECOVER_PTR(name, kind) \
+#define UBSAN_HANDLER_RECOVER_PTR(name, kind) \
INTERFACE void __ubsan_handle_##name##_minimal(const uintptr_t address) { \
__ubsan_report_error(kind, GET_CALLER_PC(), &address); \
}
-#define HANDLER_NORECOVER_PTR(name, kind) \
+#define UBSAN_HANDLER_NORECOVER_PTR(name, kind) \
INTERFACE void __ubsan_handle_##name##_minimal_abort( \
const uintptr_t address) { \
uintptr_t caller = GET_CALLER_PC(); \
@@ -156,33 +156,9 @@ void NORETURN CheckFailed(const char *file, int, const char *cond, u64, u64) {
abort_with_message(kind, caller, &address); \
}
-// A version of a handler that takes a pointer to a value.
-#define HANDLER_PTR(name, kind) \
- HANDLER_RECOVER_PTR(name, kind) \
- HANDLER_NORECOVER_PTR(name, kind)
-
-HANDLER_PTR(type_mismatch, "type-mismatch")
-HANDLER(alignment_assumption, "alignment-assumption")
-HANDLER(add_overflow, "add-overflow")
-HANDLER(sub_overflow, "sub-overflow")
-HANDLER(mul_overflow, "mul-overflow")
-HANDLER(negate_overflow, "negate-overflow")
-HANDLER(divrem_overflow, "divrem-overflow")
-HANDLER(shift_out_of_bounds, "shift-out-of-bounds")
-HANDLER(out_of_bounds, "out-of-bounds")
-HANDLER(local_out_of_bounds, "local-out-of-bounds")
-HANDLER_RECOVER(builtin_unreachable, "builtin-unreachable")
-HANDLER_RECOVER(missing_return, "missing-return")
-HANDLER(vla_bound_not_positive, "vla-bound-not-positive")
-HANDLER(float_cast_overflow, "float-cast-overflow")
-HANDLER(load_invalid_value, "load-invalid-value")
-HANDLER(invalid_builtin, "invalid-builtin")
-HANDLER(invalid_objc_cast, "invalid-objc-cast")
-HANDLER(function_type_mismatch, "function-type-mismatch")
-HANDLER(implicit_conversion, "implicit-conversion")
-HANDLER(nonnull_arg, "nonnull-arg")
-HANDLER(nonnull_return, "nonnull-return")
-HANDLER(nullability_arg, "nullability-arg")
-HANDLER(nullability_return, "nullability-return")
-HANDLER(pointer_overflow, "pointer-overflow")
-HANDLER(cfi_check_fail, "cfi-check-fail")
+// A version of a UBSAN_HANDLER that takes a pointer to a value.
+#define UBSAN_HANDLER_PTR(name, kind) \
+ UBSAN_HANDLER_RECOVER_PTR(name, kind) \
+ UBSAN_HANDLER_NORECOVER_PTR(name, kind)
+
+#include "UbsanMinimalHandlers.inc"
|
Contributor
Author
|
Actually, nevermind for now |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
(A copy of) this will be used later to add the handlers to
libfunc in llvm