Message ID | 20240812043511.3148242-1-quic_apinski@quicinc.com |
---|---|
State | New |
Headers | show |
Series | [v2] ASAN: call initialize_sanitizer_builtins for hwasan [PR115205] | expand |
On Sun, Aug 11, 2024 at 9:36 PM Andrew Pinski <quic_apinski@quicinc.com> wrote: > > Sometimes initialize_sanitizer_builtins is not called before emitting > the asan builtins with hwasan. In the case of the bug report, there > was a path with the fortran front-end where it was not called. > So let's call it in asan_instrument before calling transform_statements > and from hwasan_finish_file. > > Built and tested for aarch64-linux-gnu with no regressions. I pushed this in the end as obvious since other places call initialize_sanitizer_builtins without any extra checks. Thanks, Andrew Pinski > > Changes since v1: > * v2: Add call of asan_instrument to hwasan_finish_file also. > > gcc/ChangeLog: > > PR sanitizer/115205 > * asan.cc (asan_instrument): Call initialize_sanitizer_builtins > for hwasan. > (hwasan_finish_file): Likewise. > > Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com> > --- > gcc/asan.cc | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/gcc/asan.cc b/gcc/asan.cc > index 9e0f51b1477..5f262d54a3a 100644 > --- a/gcc/asan.cc > +++ b/gcc/asan.cc > @@ -4276,6 +4276,7 @@ asan_instrument (void) > { > if (hwasan_sanitize_p ()) > { > + initialize_sanitizer_builtins (); > transform_statements (); > return 0; > } > @@ -4694,6 +4695,8 @@ hwasan_finish_file (void) > if (flag_sanitize & SANITIZE_KERNEL_HWADDRESS) > return; > > + initialize_sanitizer_builtins (); > + > /* Avoid instrumenting code in the hwasan constructors/destructors. */ > flag_sanitize &= ~SANITIZE_HWADDRESS; > int priority = MAX_RESERVED_INIT_PRIORITY - 1; > -- > 2.43.0 >
diff --git a/gcc/asan.cc b/gcc/asan.cc index 9e0f51b1477..5f262d54a3a 100644 --- a/gcc/asan.cc +++ b/gcc/asan.cc @@ -4276,6 +4276,7 @@ asan_instrument (void) { if (hwasan_sanitize_p ()) { + initialize_sanitizer_builtins (); transform_statements (); return 0; } @@ -4694,6 +4695,8 @@ hwasan_finish_file (void) if (flag_sanitize & SANITIZE_KERNEL_HWADDRESS) return; + initialize_sanitizer_builtins (); + /* Avoid instrumenting code in the hwasan constructors/destructors. */ flag_sanitize &= ~SANITIZE_HWADDRESS; int priority = MAX_RESERVED_INIT_PRIORITY - 1;
Sometimes initialize_sanitizer_builtins is not called before emitting the asan builtins with hwasan. In the case of the bug report, there was a path with the fortran front-end where it was not called. So let's call it in asan_instrument before calling transform_statements and from hwasan_finish_file. Built and tested for aarch64-linux-gnu with no regressions. Changes since v1: * v2: Add call of asan_instrument to hwasan_finish_file also. gcc/ChangeLog: PR sanitizer/115205 * asan.cc (asan_instrument): Call initialize_sanitizer_builtins for hwasan. (hwasan_finish_file): Likewise. Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com> --- gcc/asan.cc | 3 +++ 1 file changed, 3 insertions(+)