qemu-arm-static has target_semd_ds too small vs. arm natives semid_ds

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

qemu-arm-static has target_semd_ds too small vs. arm natives semid_ds

freebsd-emulation mailing list
[The context here is FreeBSD head -r341836 based and ports head -r488859 based.]

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

For armv7 (and likely armv6) the following code:

        printf("sizeof(struct semid_ds) = %lu\n", (unsigned long) sizeof(struct semid_ds));
        printf("sem_perm %lu\n", (unsigned long) offsetof(struct semid_ds, sem_perm));
        printf("__sem_base %lu\n", (unsigned long) offsetof(struct semid_ds, __sem_base));
        printf("sem_nsems %lu\n", (unsigned long) offsetof(struct semid_ds, sem_nsems));
        printf("sem_otime %lu\n", (unsigned long) offsetof(struct semid_ds, sem_otime));
        printf("sem_ctime %lu\n", (unsigned long) offsetof(struct semid_ds, sem_ctime));

sizeof(struct semid_ds) = 48
sem_perm 0
__sem_base 24
sem_nsems 28
sem_otime 32
sem_ctime 40

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

(gdb) p/d sizeof(struct target_semid_ds)
$25 = 40
(gdb) p/d &((struct target_semid_ds *)0)->sem_perm
$26 = 0
(gdb) p/d &((struct target_semid_ds *)0)->sem_base  
$27 = 24
(gdb) p/d &((struct target_semid_ds *)0)->sem_nsems
$28 = 28
(gdb) p/d &((struct target_semid_ds *)0)->sem_otime
$29 = 32
(gdb) p/d &((struct target_semid_ds *)0)->sem_ctime
$30 = 36

so after sem_otime the offsets are different.

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

struct semid_ds {
        struct ipc_perm sem_perm;       /* operation permission struct */
        struct sem      *__sem_base;    /* pointer to first semaphore in set */
        unsigned short  sem_nsems;      /* number of sems in set */
        time_t          sem_otime;      /* last operation time */
        time_t          sem_ctime;      /* last change time */
                                        /* Times measured in secs since */
                                        /* 00:00:00 UTC, Jan. 1, 1970, without leap seconds */


struct target_semid_ds {
    struct target_ipc_perm sem_perm; /* operation permission struct */
    abi_ulong   sem_base;   /* pointer to first semaphore in set */
    uint16_t    sem_nsems;  /* number of sems in set */
    abi_ulong   sem_otime;  /* last operation time */
    abi_ulong   sem_ctime;  /* times measured in secs */

abi_ulong's for sem_otime, and sem_otime are the wrong
size for armv7: arm uses 64-bit time_t. As of 12+ only i386
uses 32-bit time_t if I understand right. In 11.x 32-bit powerpc
also uses 32-bit time_t.

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

[hidden email] mailing list
To unsubscribe, send any mail to "[hidden email]"