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
22 SignalTrampoline(int aSignal
, siginfo_t
* aInfo
, void* aContext
)
28 // Because the assembler may generate additional insturctions below, we
29 // need to ensure NOPs are inserted first by separating them out above.
34 : "r"(H
), "l"(aSignal
), "l"(aInfo
), "l"(aContext
)
38 # define MOZ_SIGNAL_TRAMPOLINE(h) (mozilla::SignalTrampoline<h>)
42 # define MOZ_SIGNAL_TRAMPOLINE(h) (h)
46 } // namespace mozilla
48 #endif // mozilla_LinuxSignal_h