Support C libraries without System V shared memory/ipc
Some systems (like Bionic) omit support for SysV related code. That means no C library headers for strace to include. Add configure tests to probe the headers from the kernel and use them when they are available. It might make more sense to never rely on the C library's headers as there is no guarantee or requirement that the structure layout between apps and the C library match that what is passed to the kernel. * configure.ac (AC_CHECK_HEADERS): Check for linux/ipc.h, linux/mqueue.h, linux/msg.h, linux/sem.h, linux/shm.h, sys/ipc.h, sys/msg.h, sys/sem.h, and sys/shm.h. * ipc_defs.h: Include <sys/ipc.h> or <linux/ipc.h> depending on what is available. * ipc_msg.c: Replace <sys/ipc.h> with "ipc_defs.h". Fallback to <linux/msg.h> when available. * ipc_msgctl.c: Include <sys/msg.h>, <asm/msgbuf.h>, or <linux/msg.h> based on what is available. Note missing support for old ipc structs. * ipc_sem.c: Include <sys/sem.h> or <linux/sem.h> depending on what is available. Only decode sembuf when available. * ipc_shm.c: Fallback to <linux/shm.h> when available. * ipc_shmctl.c: Include <sys/shm.h>, <asm/shmbuf.h>, or <linux/shm.h> based on what is available. Note missing support for old ipc structs. * print_mq_attr.c: Fallback to <linux/mqueue.h> when available.
This commit is contained in:
parent
3422849673
commit
ba10a421b8
@ -269,10 +269,14 @@ AC_CHECK_HEADERS(m4_normalize([
|
||||
linux/filter.h
|
||||
linux/hiddev.h
|
||||
linux/ip_vs.h
|
||||
linux/ipc.h
|
||||
linux/mmtimer.h
|
||||
linux/msg.h
|
||||
linux/perf_event.h
|
||||
linux/seccomp.h
|
||||
linux/securebits.h
|
||||
linux/sem.h
|
||||
linux/shm.h
|
||||
linux/utsname.h
|
||||
mqueue.h
|
||||
netinet/sctp.h
|
||||
@ -283,11 +287,16 @@ AC_CHECK_HEADERS(m4_normalize([
|
||||
sys/eventfd.h
|
||||
sys/fanotify.h
|
||||
sys/ioctl.h
|
||||
sys/ipc.h
|
||||
sys/msg.h
|
||||
sys/reg.h
|
||||
sys/sem.h
|
||||
sys/shm.h
|
||||
sys/signalfd.h
|
||||
sys/vfs.h
|
||||
sys/xattr.h
|
||||
]))
|
||||
AC_CHECK_HEADERS([linux/mqueue.h],,, [#include <linux/types.h>])
|
||||
AC_CHECK_HEADERS([linux/icmp.h linux/in6.h linux/netlink.h linux/if_packet.h],
|
||||
[], [], [#include <stddef.h>
|
||||
#include <sys/socket.h>
|
||||
|
@ -25,7 +25,13 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/ipc.h>
|
||||
#ifdef HAVE_SYS_IPC_H
|
||||
# include <sys/ipc.h>
|
||||
#elif defined HAVE_LINUX_IPC_H
|
||||
# include <linux/ipc.h>
|
||||
/* While glibc uses __key, the kernel uses key. */
|
||||
# define __key key
|
||||
#endif
|
||||
|
||||
#if !defined IPC_64
|
||||
# define IPC_64 0x100
|
||||
|
@ -31,9 +31,13 @@
|
||||
*/
|
||||
|
||||
#include "defs.h"
|
||||
#include "ipc_defs.h"
|
||||
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/msg.h>
|
||||
#ifdef HAVE_SYS_MSG_H
|
||||
# include <sys/msg.h>
|
||||
#elif defined HAVE_LINUX_MSG_H
|
||||
# include <linux/msg.h>
|
||||
#endif
|
||||
|
||||
#include "xlat/ipc_msg_flags.h"
|
||||
#include "xlat/resource_flags.h"
|
||||
|
15
ipc_msgctl.c
15
ipc_msgctl.c
@ -31,11 +31,21 @@
|
||||
*/
|
||||
|
||||
#include "defs.h"
|
||||
|
||||
#include DEF_MPERS_TYPE(msqid_ds_t)
|
||||
|
||||
#include "ipc_defs.h"
|
||||
|
||||
#include <sys/msg.h>
|
||||
#include DEF_MPERS_TYPE(msqid_ds_t)
|
||||
#ifdef HAVE_SYS_MSG_H
|
||||
/* The C library generally exports the struct the current kernel expects. */
|
||||
# include <sys/msg.h>
|
||||
typedef struct msqid_ds msqid_ds_t;
|
||||
#elif defined HAVE_LINUX_MSG_H
|
||||
/* The linux header might provide the right struct. */
|
||||
# include <linux/msg.h>
|
||||
typedef struct msqid64_ds msqid_ds_t;
|
||||
#endif
|
||||
|
||||
#include MPERS_DEFS
|
||||
|
||||
#include "xlat/msgctl_flags.h"
|
||||
@ -43,6 +53,7 @@ typedef struct msqid_ds msqid_ds_t;
|
||||
static void
|
||||
print_msqid_ds(struct tcb *tcp, const long addr, int cmd)
|
||||
{
|
||||
/* TODO: We don't properly decode old compat ipc calls. */
|
||||
if (cmd & IPC_64)
|
||||
cmd &= ~IPC_64;
|
||||
msqid_ds_t msqid_ds;
|
||||
|
12
ipc_sem.c
12
ipc_sem.c
@ -33,11 +33,16 @@
|
||||
#include "defs.h"
|
||||
#include "ipc_defs.h"
|
||||
|
||||
#include <sys/sem.h>
|
||||
#ifdef HAVE_SYS_SEM_H
|
||||
# include <sys/sem.h>
|
||||
#elif defined HAVE_LINUX_SEM_H
|
||||
# include <linux/sem.h>
|
||||
#endif
|
||||
|
||||
#include "xlat/semctl_flags.h"
|
||||
#include "xlat/semop_flags.h"
|
||||
|
||||
#if defined HAVE_SYS_SEM_H || defined HAVE_LINUX_SEM_H
|
||||
static void
|
||||
tprint_sembuf(const struct sembuf *sb)
|
||||
{
|
||||
@ -45,10 +50,12 @@ tprint_sembuf(const struct sembuf *sb)
|
||||
printflags(semop_flags, sb->sem_flg, "SEM_???");
|
||||
tprints("}");
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
tprint_sembuf_array(struct tcb *tcp, const long addr, const unsigned long count)
|
||||
{
|
||||
#if defined HAVE_SYS_SEM_H || defined HAVE_LINUX_SEM_H
|
||||
unsigned long max_count;
|
||||
struct sembuf sb;
|
||||
|
||||
@ -78,6 +85,9 @@ tprint_sembuf_array(struct tcb *tcp, const long addr, const unsigned long count)
|
||||
|
||||
tprints("]");
|
||||
}
|
||||
#else
|
||||
printaddr(addr);
|
||||
#endif
|
||||
tprintf(", %lu", count);
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,11 @@
|
||||
|
||||
#include "defs.h"
|
||||
|
||||
#include <sys/shm.h>
|
||||
#ifdef HAVE_SYS_SHM_H
|
||||
# include <sys/shm.h>
|
||||
#elif defined HAVE_LINUX_SHM_H
|
||||
# include <linux/shm.h>
|
||||
#endif
|
||||
|
||||
#include "xlat/shm_resource_flags.h"
|
||||
#include "xlat/shm_flags.h"
|
||||
|
17
ipc_shmctl.c
17
ipc_shmctl.c
@ -31,13 +31,21 @@
|
||||
*/
|
||||
|
||||
#include "defs.h"
|
||||
#include "ipc_defs.h"
|
||||
|
||||
#include <sys/shm.h>
|
||||
|
||||
#include DEF_MPERS_TYPE(shmid_ds_t)
|
||||
#include <sys/shm.h>
|
||||
|
||||
#include "ipc_defs.h"
|
||||
|
||||
#ifdef HAVE_SYS_SHM_H
|
||||
/* The C library generally exports the struct the current kernel expects. */
|
||||
# include <sys/shm.h>
|
||||
typedef struct shmid_ds shmid_ds_t;
|
||||
#elif defined HAVE_LINUX_SHM_H
|
||||
/* The linux header might provide the right struct. */
|
||||
# include <linux/shm.h>
|
||||
typedef struct shmid64_ds shmid_ds_t;
|
||||
#endif
|
||||
|
||||
#include MPERS_DEFS
|
||||
|
||||
#include "xlat/shmctl_flags.h"
|
||||
@ -45,6 +53,7 @@ typedef struct shmid_ds shmid_ds_t;
|
||||
static void
|
||||
print_shmid_ds(struct tcb *tcp, const long addr, int cmd)
|
||||
{
|
||||
/* TODO: We don't properly decode old compat ipc calls. */
|
||||
if (cmd & IPC_64)
|
||||
cmd &= ~IPC_64;
|
||||
shmid_ds_t shmid_ds;
|
||||
|
@ -29,17 +29,21 @@
|
||||
#include "defs.h"
|
||||
|
||||
#include DEF_MPERS_TYPE(mq_attr_t)
|
||||
|
||||
#ifdef HAVE_MQUEUE_H
|
||||
# include <mqueue.h>
|
||||
typedef struct mq_attr mq_attr_t;
|
||||
#elif defined HAVE_LINUX_MQUEUE_H
|
||||
# include <linux/types.h>
|
||||
# include <linux/mqueue.h>
|
||||
typedef struct mq_attr mq_attr_t;
|
||||
#endif
|
||||
|
||||
#include MPERS_DEFS
|
||||
|
||||
MPERS_PRINTER_DECL(void, printmqattr)(struct tcb *tcp, const long addr)
|
||||
{
|
||||
# ifndef HAVE_MQUEUE_H
|
||||
printaddr(addr);
|
||||
# else
|
||||
#if defined HAVE_MQUEUE_H || defined HAVE_LINUX_MQUEUE_H
|
||||
mq_attr_t attr;
|
||||
if (umove_or_printaddr(tcp, addr, &attr))
|
||||
return;
|
||||
@ -48,5 +52,7 @@ MPERS_PRINTER_DECL(void, printmqattr)(struct tcb *tcp, const long addr)
|
||||
tprintf(", mq_maxmsg=%ld, mq_msgsize=%ld, mq_curmsg=%ld}",
|
||||
(long) attr.mq_maxmsg, (long) attr.mq_msgsize,
|
||||
(long) attr.mq_curmsgs);
|
||||
# endif
|
||||
#else
|
||||
printaddr(addr);
|
||||
#endif
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user