diff options
author | Sergey Bugaev <bugaevc@gmail.com> | 2023-05-15 11:33:22 +0300 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2023-05-16 16:09:00 +0200 |
commit | e333759f7752593a69a8f9920a247ed3878fafef (patch) | |
tree | 0c307ea5d660fea298c4069b301863a38c84284f /sysdeps/mach/hurd/x86/trampoline.c | |
parent | ce96593c882b393461084048533120e9c1e9d328 (diff) | |
download | glibc-e333759f7752593a69a8f9920a247ed3878fafef.tar.gz glibc-e333759f7752593a69a8f9920a247ed3878fafef.tar.xz glibc-e333759f7752593a69a8f9920a247ed3878fafef.zip |
hurd: Fix sc_i386_thread_state layout
The real i386_thread_state Mach structure has an alignment of 8 on x86_64. However, in struct sigcontext, the compiler was packing sc_gs (which is the first member of sc_i386_thread_state) into the same 8-byte slot as sc_error; this resulted in the rest of sc_i386_thread_state members having wrong offsets relative to each other, and the overall sc_i386_thread_state layout mismatching that of i386_thread_state. Fix this by explicitly adding the required padding members, and statically asserting that this results in the desired alignment. The same goes for sc_i386_float_state. Checked on x86_64-gnu. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230515083323.1358039-4-bugaevc@gmail.com>
Diffstat (limited to 'sysdeps/mach/hurd/x86/trampoline.c')
-rw-r--r-- | sysdeps/mach/hurd/x86/trampoline.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/sysdeps/mach/hurd/x86/trampoline.c b/sysdeps/mach/hurd/x86/trampoline.c index 1f92064ebf..6318c9528a 100644 --- a/sysdeps/mach/hurd/x86/trampoline.c +++ b/sysdeps/mach/hurd/x86/trampoline.c @@ -242,11 +242,17 @@ _hurd_setup_sighandler (struct hurd_sigstate *ss, const struct sigaction *action /* struct sigcontext is laid out so that starting at sc_gs mimics a struct i386_thread_state. */ + _Static_assert (offsetof (struct sigcontext, sc_i386_thread_state) + % __alignof__ (struct i386_thread_state) == 0, + "sc_i386_thread_state layout mismatch"); memcpy (&scp->sc_i386_thread_state, &state->basic, sizeof (state->basic)); /* struct sigcontext is laid out so that starting at sc_fpkind mimics a struct i386_float_state. */ + _Static_assert (offsetof (struct sigcontext, sc_i386_float_state) + % __alignof__ (struct i386_float_state) == 0, + "sc_i386_float_state layout mismatch"); ok = machine_get_state (ss->thread, state, i386_FLOAT_STATE, &state->fpu, &scp->sc_i386_float_state, sizeof (state->fpu)); |