1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef mozilla_LinuxSignal_h
6 #define mozilla_LinuxSignal_h
12 // Some (old) Linux kernels on ARM have a bug where a signal handler
13 // can be called without clearing the IT bits in CPSR first. The result
14 // is that the first few instructions of the handler could be skipped,
15 // ultimately resulting in crashes. To workaround this bug, the handler
16 // on ARM is a trampoline that starts with enough NOP instructions, so
17 // that even if the IT bits are not cleared, only the NOP instructions
18 // will be skipped over.
20 template <void (*H
)(int, siginfo_t
*, void*)>
21 __attribute__((naked
)) void SignalTrampoline(int aSignal
, siginfo_t
* aInfo
,
23 asm volatile("nop; nop; nop; nop" : : : "memory");
25 asm volatile("b %0" : : "X"(H
) : "memory");
28 # define MOZ_SIGNAL_TRAMPOLINE(h) (mozilla::SignalTrampoline<h>)
32 # define MOZ_SIGNAL_TRAMPOLINE(h) (h)
36 } // namespace mozilla
38 #endif // mozilla_LinuxSignal_h