Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 5 Jan 2019 15:48:46 -0800
From:      Mark Millard <marklmi@yahoo.com>
To:        Kyle Evans <kevans@FreeBSD.org>, freebsd-emulation@freebsd.org, ports-list freebsd <freebsd-ports@freebsd.org>
Cc:        Sean Bruno <sbruno@freebsd.org>, freebsd-arm <freebsd-arm@freebsd.org>
Subject:   qemu-arm-static has target_prpsinfo missing pr_pid field so target_prpsinfo is too small
Message-ID:  <5C2E8937-23A5-4899-B3CE-8468697D8923@yahoo.com>

next in thread | raw e-mail | index | archive | help
[The context here is FreeBSD head -r341836 based and ports head -r488859 =
based.]

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

Note: struct target_prpsinfo is in (for my context):

=
/wrkdirs/usr/ports/emulators/qemu-user-static/work/qemu-bsd-user-4ef7d07/b=
sd-user/elfload.c

For armv7 (and likely armv6) the following code:

        printf("sizeof(struct prpsinfo) =3D %lu\n", (unsigned long) =
sizeof(struct prpsinfo));
        printf("pr_version %lu\n", (unsigned long) offsetof(struct =
prpsinfo, pr_version));
        printf("pr_psinfosz %lu\n", (unsigned long) offsetof(struct =
prpsinfo, pr_psinfosz));
        printf("pr_fname %lu\n", (unsigned long) offsetof(struct =
prpsinfo, pr_fname));
        printf("pr_psargs %lu\n", (unsigned long) offsetof(struct =
prpsinfo, pr_psargs));
        printf("pr_pid %lu\n", (unsigned long) offsetof(struct prpsinfo, =
pr_pid));

produces:

sizeof(struct prpsinfo) =3D 112
pr_version 0
pr_psinfosz 4
pr_fname 8
pr_psargs 25
pr_pid 108

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

(gdb) p/d sizeof(struct target_prpsinfo)
$7 =3D 108
(gdb) p/d &((struct target_prpsinfo *)0)->pr_version
$8 =3D 0
(gdb) p/d &((struct target_prpsinfo *)0)->pr_psinfosz
$9 =3D 4
(gdb) p/d &((struct target_prpsinfo *)0)->pr_fname  =20
$10 =3D 8
(gdb) p/d &((struct target_prpsinfo *)0)->pr_psargs
$11 =3D 25
(gdb) p/d &((struct target_prpsinfo *)0)->pr_pid  =20
There is no member named pr_pid.

So the fields prior to pr_pid have matching offsets and there
is no extra padding added before pr_pid for native armv7.


/usr/include/sys/procinfo.h has:

typedef struct prpsinfo {
    int         pr_version;     /* Version number of struct (1) */
    size_t      pr_psinfosz;    /* sizeof(prpsinfo_t) (1) */
    char        pr_fname[PRFNAMESZ+1];  /* Command name, null terminated =
(1) */
    char        pr_psargs[PRARGSZ+1];   /* Arguments, null terminated =
(1) */
    pid_t       pr_pid;         /* Process ID (1a) */
} prpsinfo_t;

pr_pid was added in -r308009 (2016-oct-28) and is in 11.2 .

=
/wrkdirs/usr/ports/emulators/qemu-user-static/work/qemu-bsd-user-4ef7d07/b=
sd-user/elfload.c
has:

typedef struct target_prpsinfo {
    int32_t     pr_version;     /* Version number of struct (1) */
    abi_ulong   pr_psinfosz;    /* sizeof(prpsinfo_t) (1) */
    char        pr_fname[TARGET_PRFNAMESZ+1]; /* Command name + NULL (1) =
*/
    char        pr_psargs[TARGET_PRARGSZ+1];  /* Arguments + NULL (1) */
} target_prpsinfo_t;


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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5C2E8937-23A5-4899-B3CE-8468697D8923>