qemu-arm-static has target_sigframe missing sf_fvp field so target_sigframe is too small

Mark Millard marklmi at yahoo.com
Sat Jan 5 23:22:14 UTC 2019


[The context here is FreeBSD head -r341836 based and ports head -r488859 based.]

Note: I assume that "struct target_sigframe" is meant to match the memory layout
of the target's native "struct sigframe". Otherwise the reported differences
below could be irrelevant.

For armv7 (and likely armv6) the following code:

        printf("sizeof(struct sigframe) = %lu\n", (unsigned long) sizeof(struct sigframe));

        // arm:
        printf("sf_si %lu\n", (unsigned long) offsetof(struct sigframe, sf_si));
        printf("sf_uc %lu\n", (unsigned long) offsetof(struct sigframe, sf_uc));
        printf("sf_vfp %lu\n", (unsigned long) offsetof(struct sigframe, sf_vfp));

produces:

sizeof(struct sigframe) = 592
sf_si 0
sf_uc 64
sf_vfp 328

However gdb reports for qemu-arm-static (on amd64):

(gdb) p/d sizeof(struct target_sigframe)
$3 = 324
(gdb) p/d &((struct target_sigframe *)0)->sf_si
$4 = 0
(gdb) p/d &((struct target_sigframe *)0)->sf_uc
$5 = 64
(gdb) p/d &((struct target_sigframe *)0)->sf_vfp
There is no member named sf_vfp.

So the first two fields have matching offsets.

But note: sf_vfp is at 328, after the size of target_sigframe (324).
It looks like both contexts have 260 for the size of sf_uc so the
difference is padding before sf_vfp .


/usr/include/machine/frame.h has:

struct sigframe {
        siginfo_t       sf_si;          /* actual saved siginfo */
        ucontext_t      sf_uc;          /* actual saved ucontext */
        mcontext_vfp_t  sf_vfp;         /* actual saved VFP context */
};

sf_vfp was added in -r315947 (2017-Mar-26) and is in 11.2 .

/wrkdirs/usr/ports/emulators/qemu-user-static/work/qemu-bsd-user-4ef7d07/bsd-user/arm/target_arch_signal.h
has:

struct target_sigframe {
    target_siginfo_t    sf_si;  /* saved siginfo */
    target_ucontext_t   sf_uc;  /* saved ucontext */
};


===
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)



More information about the freebsd-ports mailing list