Angel Pons has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/43975 )
Change subject: lib/ubsan.c: Fix build errors ......................................................................
lib/ubsan.c: Fix build errors
Looks like this isn't being build-tested. A config will be added later.
Change-Id: I5980730d8d22fa1d0512846c203004723847cc6d Signed-off-by: Angel Pons th3fanbus@gmail.com --- M src/lib/ubsan.c 1 file changed, 19 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/75/43975/1
diff --git a/src/lib/ubsan.c b/src/lib/ubsan.c index 8c1f64d..6873f7e 100644 --- a/src/lib/ubsan.c +++ b/src/lib/ubsan.c @@ -68,7 +68,7 @@ unsigned char type_check_kind; };
-void __ubsan_handle_type_mismatch(void *data_raw, void *pointer_raw) +void __ubsan_handle_type_mismatch_v1(void *data_raw, void *pointer_raw) { const struct ubsan_type_mismatch_data *data = (struct ubsan_type_mismatch_data *)data_raw; @@ -81,7 +81,7 @@ ubsan_abort(&data->location, violation); }
-ABORT_VARIANT_VP_VP(type_mismatch); +ABORT_VARIANT_VP_VP(type_mismatch_v1);
struct ubsan_overflow_data { struct ubsan_source_location location; @@ -156,6 +156,23 @@
ABORT_VARIANT_VP_VP_VP(divrem_overflow);
+struct ubsan_pointer_overflow_data { + struct ubsan_source_location location; +}; + +void __ubsan_handle_pointer_overflow(void *data_raw, void *base_raw, void *result_raw) +{ + const struct ubsan_pointer_overflow_data *data = + (struct ubsan_pointer_overflow_data *)data_raw; + ubsan_value_handle_t base = (ubsan_value_handle_t)base_raw; + ubsan_value_handle_t result = (ubsan_value_handle_t)result_raw; + (void)base; + (void)result; + ubsan_abort(&data->location, "pointer overflow"); +} + +ABORT_VARIANT_VP_VP_VP(pointer_overflow); + struct ubsan_shift_out_of_bounds_data { struct ubsan_source_location location; struct ubsan_type_descriptor *lhs_type;
Tim Wawrzynczak has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/43975 )
Change subject: lib/ubsan.c: Fix build errors ......................................................................
Patch Set 1:
(1 comment)
https://review.coreboot.org/c/coreboot/+/43975/1//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/43975/1//COMMIT_MSG@10 PS1, Line 10: Surely adding `__ubsan_handle_pointer_overflow` is more than just a build error? Isn't that adding a new handler for UBSan?
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/43975 )
Change subject: lib/ubsan.c: Fix build errors ......................................................................
Patch Set 1:
(1 comment)
https://review.coreboot.org/c/coreboot/+/43975/1//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/43975/1//COMMIT_MSG@10 PS1, Line 10:
Surely adding `__ubsan_handle_pointer_overflow` is more than just a build error? Isn't that adding a […]
Yes, but when it's missing UBSan doesn't build. It was probably introduced with a GCC update.
Tim Wawrzynczak has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/43975 )
Change subject: lib/ubsan.c: Fix build errors ......................................................................
Patch Set 1: Code-Review+2
(1 comment)
https://review.coreboot.org/c/coreboot/+/43975/1//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/43975/1//COMMIT_MSG@10 PS1, Line 10:
Yes, but when it's missing UBSan doesn't build. It was probably introduced with a GCC update.
I see, I thought it was optional to define handlers.
Hello build bot (Jenkins), Patrick Georgi, Tim Wawrzynczak,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/43975
to look at the new patch set (#2).
Change subject: lib/ubsan.c: Update error handlers for current toolchain's GCC ......................................................................
lib/ubsan.c: Update error handlers for current toolchain's GCC
Looks like UBSan isn't being build-tested, and the toolchain has been updated several times since UBSan support was added. Unexpectedly, it no longer builds when using GCC from the current toolchain version.
To fix this, rename an error handler and add a newly-introduced handler for `__ubsan_handle_pointer_overflow`, which works like the existing handlers. A config file to allow build-testing UBSan is added later.
Change-Id: I5980730d8d22fa1d0512846c203004723847cc6d Signed-off-by: Angel Pons th3fanbus@gmail.com --- M src/lib/ubsan.c 1 file changed, 19 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/75/43975/2
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/43975 )
Change subject: lib/ubsan.c: Update error handlers for current toolchain's GCC ......................................................................
Patch Set 2:
(1 comment)
https://review.coreboot.org/c/coreboot/+/43975/1//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/43975/1//COMMIT_MSG@10 PS1, Line 10:
I see, I thought it was optional to define handlers.
I've expanded the commit message
Angel Pons has submitted this change. ( https://review.coreboot.org/c/coreboot/+/43975 )
Change subject: lib/ubsan.c: Update error handlers for current toolchain's GCC ......................................................................
lib/ubsan.c: Update error handlers for current toolchain's GCC
Looks like UBSan isn't being build-tested, and the toolchain has been updated several times since UBSan support was added. Unexpectedly, it no longer builds when using GCC from the current toolchain version.
To fix this, rename an error handler and add a newly-introduced handler for `__ubsan_handle_pointer_overflow`, which works like the existing handlers. A config file to allow build-testing UBSan is added later.
Change-Id: I5980730d8d22fa1d0512846c203004723847cc6d Signed-off-by: Angel Pons th3fanbus@gmail.com Reviewed-on: https://review.coreboot.org/c/coreboot/+/43975 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Tim Wawrzynczak twawrzynczak@chromium.org --- M src/lib/ubsan.c 1 file changed, 19 insertions(+), 2 deletions(-)
Approvals: build bot (Jenkins): Verified Tim Wawrzynczak: Looks good to me, approved
diff --git a/src/lib/ubsan.c b/src/lib/ubsan.c index 8c1f64d..6873f7e 100644 --- a/src/lib/ubsan.c +++ b/src/lib/ubsan.c @@ -68,7 +68,7 @@ unsigned char type_check_kind; };
-void __ubsan_handle_type_mismatch(void *data_raw, void *pointer_raw) +void __ubsan_handle_type_mismatch_v1(void *data_raw, void *pointer_raw) { const struct ubsan_type_mismatch_data *data = (struct ubsan_type_mismatch_data *)data_raw; @@ -81,7 +81,7 @@ ubsan_abort(&data->location, violation); }
-ABORT_VARIANT_VP_VP(type_mismatch); +ABORT_VARIANT_VP_VP(type_mismatch_v1);
struct ubsan_overflow_data { struct ubsan_source_location location; @@ -156,6 +156,23 @@
ABORT_VARIANT_VP_VP_VP(divrem_overflow);
+struct ubsan_pointer_overflow_data { + struct ubsan_source_location location; +}; + +void __ubsan_handle_pointer_overflow(void *data_raw, void *base_raw, void *result_raw) +{ + const struct ubsan_pointer_overflow_data *data = + (struct ubsan_pointer_overflow_data *)data_raw; + ubsan_value_handle_t base = (ubsan_value_handle_t)base_raw; + ubsan_value_handle_t result = (ubsan_value_handle_t)result_raw; + (void)base; + (void)result; + ubsan_abort(&data->location, "pointer overflow"); +} + +ABORT_VARIANT_VP_VP_VP(pointer_overflow); + struct ubsan_shift_out_of_bounds_data { struct ubsan_source_location location; struct ubsan_type_descriptor *lhs_type;