From patchwork Sat Sep 23 00:03:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maciej W. Rozycki" X-Patchwork-Id: 23102 Received: (qmail 101744 invoked by alias); 23 Sep 2017 00:03:19 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 101723 invoked by uid 89); 23 Sep 2017 00:03:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy= X-Spam-User: qpsmtpd, 2 recipients X-HELO: mailapp01.imgtec.com Received: from mailapp01.imgtec.com (HELO mailapp01.imgtec.com) (195.59.15.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 23 Sep 2017 00:03:17 +0000 Received: from HHMAIL01.hh.imgtec.org (unknown [10.100.10.19]) by Forcepoint Email with ESMTPS id 000738D3F0C85; Sat, 23 Sep 2017 01:03:09 +0100 (IST) Received: from [10.20.78.84] (10.20.78.84) by HHMAIL01.hh.imgtec.org (10.100.10.21) with Microsoft SMTP Server id 14.3.361.1; Sat, 23 Sep 2017 01:03:13 +0100 Date: Sat, 23 Sep 2017 01:03:02 +0100 From: "Maciej W. Rozycki" To: , CC: Sergio Durigan Junior , Pedro Alves , Djordje Todorovic Subject: [PATCH 1/4] ELF/BFD: Fix padding in `elf_external_linux_prpsinfo64' In-Reply-To: Message-ID: References: User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) MIME-Version: 1.0 Fix commit 70a38d42c5b3 ("New entry points for writing Linux NT_PRPSINFO notes."), , 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];