Matthew Denton | bb0b03e | 2021-07-22 16:18:13 | [diff] [blame^] | 1 | // Copyright 2021 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "base/stack_canary_linux.h" |
| 6 | |
| 7 | #include "base/compiler_specific.h" |
| 8 | #include "build/build_config.h" |
| 9 | #include "testing/gtest/include/gtest/gtest.h" |
| 10 | |
| 11 | namespace base { |
| 12 | |
| 13 | #if defined(LIBC_GLIBC) && \ |
| 14 | (defined(ARCH_CPU_ARM_FAMILY) || defined(ARCH_CPU_X86_FAMILY)) |
| 15 | |
| 16 | namespace { |
| 17 | __attribute__((noinline, optnone)) void ResetCanaryAndReturn() { |
| 18 | // Create a buffer >=8 bytes to force the stack protector on this function, |
| 19 | // which should work as long as -fno-stack-protector isn't passed in the |
| 20 | // default options. We compile this file with -fstack-protector-all, but it |
| 21 | // may be overridden with -fstack-protector or -fstack-protector-strong. |
| 22 | char buffer[10]; |
| 23 | ALLOW_UNUSED_LOCAL(buffer); |
| 24 | ResetStackCanaryIfPossible(); |
| 25 | } |
| 26 | } // namespace |
|
|