[PATCH] D19668: [ubsan] Minimize size of data for type_mismatch
Filipe Cabecinhas via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 28 09:45:15 PDT 2016
We can think about adding a piece of data (we have 6 bytes which will
end up being used for padding) that tells us we have a "V2" struct
layout.
If we feel strongly about being able to use older objects, then we can
add an unsigned char after TypeCheckKind, for example. Since
TypeCheckKind can be 0, we have no reliable way to figure out if we're
looking at a new layout (we could see only one bit set in both chars.
This could be because we were looking at an old-style alignment
(uptr), or a new style (char) plus TCK set to 0).
Kostya: Any thoughts?
Thank you,
Filipe
On Thu, Apr 28, 2016 at 5:41 PM, Filipe Cabecinhas
<filcab+llvm.phabricator at gmail.com> wrote:
> filcab created this revision.
> filcab added reviewers: kcc, samsonov, rsmith.
> filcab added a subscriber: llvm-commits.
> Herald added a subscriber: kubabrecka.
>
> This is the compiler-rt side of D19667.
>
> http://reviews.llvm.org/D19668
>
> Files:
> lib/ubsan/ubsan_handlers.cc
> lib/ubsan/ubsan_handlers.h
>
> Index: lib/ubsan/ubsan_handlers.h
> ===================================================================
> --- lib/ubsan/ubsan_handlers.h
> +++ lib/ubsan/ubsan_handlers.h
> @@ -20,7 +20,7 @@
> struct TypeMismatchData {
> SourceLocation Loc;
> const TypeDescriptor &Type;
> - uptr Alignment;
> + unsigned char Alignment;
> unsigned char TypeCheckKind;
> };
>
> Index: lib/ubsan/ubsan_handlers.cc
> ===================================================================
> --- lib/ubsan/ubsan_handlers.cc
> +++ lib/ubsan/ubsan_handlers.cc
> @@ -46,9 +46,10 @@
> Location Loc = Data->Loc.acquire();
>
> ErrorType ET;
> + uptr Alignment = (uptr)1 << Data->Alignment;
> if (!Pointer)
> ET = ErrorType::NullPointerUse;
> - else if (Data->Alignment && (Pointer & (Data->Alignment - 1)))
> + else if (Alignment && (Pointer & (Alignment - 1)))
> ET = ErrorType::MisalignedPointerUse;
> else
> ET = ErrorType::InsufficientObjectSize;
> @@ -75,7 +76,7 @@
> Diag(Loc, DL_Error, "%0 misaligned address %1 for type %3, "
> "which requires %2 byte alignment")
> << TypeCheckKinds[Data->TypeCheckKind] << (void *)Pointer
> - << Data->Alignment << Data->Type;
> + << Alignment << Data->Type;
> break;
> case ErrorType::InsufficientObjectSize:
> Diag(Loc, DL_Error, "%0 address %1 with insufficient space "
>
>
More information about the llvm-commits
mailing list