]> git.ipfire.org Git - thirdparty/valgrind.git/commit
Use a different way to tell where the syscall handler was interrupted on FreeBSD...
authorPaul Floyd <pjfloyd@wanadoo.fr>
Mon, 6 Jun 2022 13:18:29 +0000 (15:18 +0200)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Mon, 6 Jun 2022 13:18:29 +0000 (15:18 +0200)
commit6cc2d94d93fa5350355b8cedb0d6b5309fcc588c
tree5e3ea99a0828a0ab6d069b44dc7ae53bbb95714d
parenteeaf547e6c345834032c73f63595dc52a9fbf585
Use a different way to tell where the syscall handler was interrupted on FreeBSD and macOS

I was using a global variable. This would be set to '1' just before
calling the function to save cflags and cleared just after, then
using the variable to fill in the 'outside_rnage_ condition
in VG_(fixup_guest_state_after_syscall_interrupted)

Even though I haven't experienced any isseus with that, the comments just before
do_syscall_for_client made me want to try an alternative.

This code is very ugly and won't please the language lawyers.
Functions aren't guaranteed to have an address and there is no
guarantee that the binary layout will reflect the source layout.
Sadly C doesn't have something like "sizeof(*function)" to give
the size of a function in bytes. The next best that I could
manage was to use dummy 'marker' functions just after the
ones I want the end address of and then use the address of
'marker - 1'

I did think of one other way to do this. That would be to
generate a C file containing the function sizes. This would
require

1. "put_flag_size.c" would depend on the VEX guest_(x86|amd64)_helpers
   object files
2. Extract the sizes, for instance

echo -n "const size_t x86_put_eflag_c_size = 0x" > put_flag_size.c
nm -F sysv libvex_x86_freebsd_a-guest_x86_helpers.o | awk -F\| '/LibVEX_GuestX86_put_eflag_c/{print $5}' >> put_flag_size.c
echo ";" >> put_flag_size.c

That seems fairly difficult to do in automake and I'm not sure if
it would be robust.
VEX/priv/guest_amd64_helpers.c
VEX/priv/guest_x86_helpers.c
VEX/pub/libvex_guest_amd64.h
VEX/pub/libvex_guest_x86.h
coregrind/m_syswrap/syscall-amd64-darwin.S
coregrind/m_syswrap/syscall-amd64-freebsd.S
coregrind/m_syswrap/syscall-x86-darwin.S
coregrind/m_syswrap/syscall-x86-freebsd.S
coregrind/m_syswrap/syswrap-main.c