Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Maciej W. Rozycki" <macro@imgtec.com>
To: <binutils@sourceware.org>, <gdb-patches@sourceware.org>
Cc: Sergio Durigan Junior <sergiodj@redhat.com>,
	Pedro Alves	<palves@redhat.com>,
	Djordje Todorovic <djordje.todorovic@rt-rk.com>
Subject: [PATCH 1/4] ELF/BFD: Fix padding in `elf_external_linux_prpsinfo64'
Date: Sat, 23 Sep 2017 00:03:00 -0000	[thread overview]
Message-ID: <alpine.DEB.2.00.1709221409510.16752@tp.orcam.me.uk> (raw)
In-Reply-To: <alpine.DEB.2.00.1709220216120.16752@tp.orcam.me.uk>

Fix commit 70a38d42c5b3 ("New entry points for writing Linux NT_PRPSINFO 
notes."), <https://sourceware.org/ml/binutils/2013-02/msg00023.html>, 
and move the padding of the `elf_external_linux_prpsinfo64' structure to 
match the corresponding 64-bit Linux kernel `elf_prpsinfo' structure.

The 64-bit kernel structure is defined as follows:

(gdb) ptype struct elf_prpsinfo
type = struct elf_prpsinfo {
    char pr_state;
    char pr_sname;
    char pr_zomb;
    char pr_nice;
    unsigned long pr_flag;
    __kernel_uid_t pr_uid;
    __kernel_gid_t pr_gid;
    pid_t pr_pid;
    pid_t pr_ppid;
    pid_t pr_pgrp;
    pid_t pr_sid;
    char pr_fname[16];
    char pr_psargs[80];
}
(gdb) print /x &((struct elf_prpsinfo *)0)->pr_nice
$1 = 0x3
(gdb) print /x &((struct elf_prpsinfo *)0)->pr_flag
$2 = 0x8
(gdb) print /x &((struct elf_prpsinfo *)0)->pr_uid
$3 = 0x10
(gdb) print sizeof(((struct elf_prpsinfo *)0)->pr_flag)
$4 = 8
(gdb)

with implicit padding present before the `pr_flag' member, to correctly 
align it to a multiple of 8.  Conversely `elf_external_linux_prpsinfo64' 
has padding after its `pr_flag' member:

(top-gdb) ptype struct elf_external_linux_prpsinfo64
type = struct elf_external_linux_prpsinfo64 {
    char pr_state;
    char pr_sname;
    char pr_zomb;
    char pr_nice;
    char pr_flag[8];
    char gap[4];
    char pr_uid[4];
    char pr_gid[4];
    char pr_pid[4];
    char pr_ppid[4];
    char pr_pgrp[4];
    char pr_sid[4];
    char pr_fname[16];
    char pr_psargs[80];
}
(top-gdb) print /x &((struct elf_external_linux_prpsinfo64 *)0)->pr_nice
$1 = 0x3
(top-gdb) print /x &((struct elf_external_linux_prpsinfo64 *)0)->pr_flag
$2 = 0x4
(top-gdb) print /x &((struct elf_external_linux_prpsinfo64 *)0)->pr_uid
$3 = 0x10
(top-gdb)

and consequently `pr_flag' is misplaced.  Move `gap' ahead of `pr_flag'
then.

	bfd/
	* elf-linux-core.h (elf_external_linux_prpsinfo64): Move the 
	`gap' member ahead of `pr_flag'.
---
 bfd/elf-linux-core.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: binutils/bfd/elf-linux-core.h
===================================================================
--- binutils.orig/bfd/elf-linux-core.h	2017-07-31 09:18:48.000000000 +0100
+++ binutils/bfd/elf-linux-core.h	2017-09-19 15:49:09.859093825 +0100
@@ -85,8 +85,8 @@ struct elf_external_linux_prpsinfo64
     char pr_sname;			/* Char for pr_state.  */
     char pr_zomb;			/* Zombie.  */
     char pr_nice;			/* Nice val.  */
-    char pr_flag[8];			/* Flags.  */
     char gap[4];
+    char pr_flag[8];			/* Flags.  */
     char pr_uid[4];
     char pr_gid[4];
     char pr_pid[4];


  reply	other threads:[~2017-09-23  0:03 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-23  0:02 [PATCH 0/4] Fix issues with Linux core PRPSINFO note definitions Maciej W. Rozycki
2017-09-23  0:03 ` Maciej W. Rozycki [this message]
2017-09-23  0:04 ` [PATCH 3/4] ELF/BFD: Handle both variants of the 64-bit Linux core PRPSINFO note Maciej W. Rozycki
2017-09-23  2:05   ` Sergio Durigan Junior
2017-09-24 22:19     ` Maciej W. Rozycki
2017-09-24 23:32       ` Sergio Durigan Junior
2017-09-25  9:48         ` Maciej W. Rozycki
2017-09-25 16:49           ` Sergio Durigan Junior
2017-09-23  0:04 ` [PATCH 2/4] ELF/BFD,GDB: Handle both variants of the 32-bit " Maciej W. Rozycki
2017-09-23  0:05 ` [PATCH 4/4] GDB: Remove Linux core PRPSINFO note writer override Maciej W. Rozycki
2017-09-23  2:10 ` [PATCH 0/4] Fix issues with Linux core PRPSINFO note definitions Sergio Durigan Junior
2017-09-24 23:46 ` Alan Modra
2017-09-29 21:11 ` [PING][PATCH " Maciej W. Rozycki
2017-10-11  0:32   ` [PING^2][PATCH " Maciej W. Rozycki
2017-10-11  9:41     ` Pedro Alves
2017-10-11 14:06       ` Maciej W. Rozycki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.00.1709221409510.16752@tp.orcam.me.uk \
    --to=macro@imgtec.com \
    --cc=binutils@sourceware.org \
    --cc=djordje.todorovic@rt-rk.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    --cc=sergiodj@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox