Commit 6bd491da authored by Michael Forney's avatar Michael Forney Committed by Commit Bot

Avoid using glibc internals for SIGSYS handler

SIGSYS fields were added to siginfo_t on glibc in version 2.17,
which is quite old now. Additionally, musl libc uses a different
name (__si_fields) for its internal struct members.

To fix this, use the libc-defined members if they are available,
otherwise fall back to _sifields, as is done currently.

Change-Id: I6a542a1817df7e31309a1043b899328a50834f7d
Bug: 1045069
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2015735Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Commit-Queue: Robert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#734970}
parent dffb4aca
...@@ -164,11 +164,18 @@ void Trap::SigSys(int nr, LinuxSigInfo* info, ucontext_t* ctx) { ...@@ -164,11 +164,18 @@ void Trap::SigSys(int nr, LinuxSigInfo* info, ucontext_t* ctx) {
} }
// Obtain the siginfo information that is specific to SIGSYS. Unfortunately, // Obtain the siginfo information that is specific to SIGSYS.
// most versions of glibc don't include this information in siginfo_t. So,
// we need to explicitly copy it into a arch_sigsys structure.
struct arch_sigsys sigsys; struct arch_sigsys sigsys;
#if defined(si_call_addr) && !defined(__native_client_nonsfi__)
sigsys.ip = info->si_call_addr;
sigsys.nr = info->si_syscall;
sigsys.arch = info->si_arch;
#else
// If the version of glibc doesn't include this information in
// siginfo_t (older than 2.17), we need to explicitly copy it
// into an arch_sigsys structure.
memcpy(&sigsys, &info->_sifields, sizeof(sigsys)); memcpy(&sigsys, &info->_sifields, sizeof(sigsys));
#endif
#if defined(__mips__) #if defined(__mips__)
// When indirect syscall (syscall(__NR_foo, ...)) is made on Mips, the // When indirect syscall (syscall(__NR_foo, ...)) is made on Mips, the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment