On Sun, Jul 14, 2013 at 07:39:38AM +0200, Marek Polacek wrote: > This patch implements sanitizing of the __builtin_unreachable call. > A call to __builtin_unreachable only emits BARRIER, if we actually get to it, > the behavior is undefined. So, we just replace the call with a call to > the ubsan library, it then issues an error and dies. > > The patch is long because I had to pluck some code out of c-family/c-ubsan.c > (otherwise we couldn't call ubsan_* routines from builtins.c), I've put > the code into ubsan.c. > > Commited to ubsan branch. Comments? > > (I think I'm going to solve the ubsan testsuite now.) > > 2013-07-14 Marek Polacek <pola...@redhat.com> > > * builtins.c: Include ubsan.h. > (fold_builtin_0): Instrument __builtin_unreachable. > * c-family/c-ubsan.c (struct ubsan_typedesc): Move to ubsan.c. > (struct ubsan_typedesc_hasher): Likewise. > (ubsan_typedesc_hasher::hash): Likewise. > (ubsan_typedesc_hasher::equal): Likewise. > (ubsan_typedesc_init): Likewise. > (ubsan_typedesc_get_alloc_pool): Likewise. > (get_typedesc_hash_table): Likewise. > (ubsan_typedesc_new): Likewise. > (empty_ubsan_typedesc_hash_table): Likewise. > (uptr_type): Likewise. > (ubsan_encode_value): Likewise. > (ubsan_type_descriptor_type): Likewise. > (ubsan_source_location_type): Likewise. > (ubsan_source_location): Likewise. > (get_tinfo_for_type): Likewise. > (ubsan_type_descriptor): Likewise. > (ubsan_create_data): Likewise. > * c-family/c-ubsan.h: Rename GCC_UBSAN_H to GCC_C_UBSAN_H. > * sanitizer.def (BUILT_IN_UBSAN_HANDLE_BUILTIN_UNREACHABLE): Define. > * Makefile.in: Add ubsan.c. > * ubsan.h: New file. > * ubsan.c: New file.
I've noticed that the parts of the CL should go into c-family/, fixed before commiting. Marek