Return-Path: yishimat@redhat.com
Received: from zmta04.collab.prod.int.phx2.redhat.com (LHLO
zmta04.collab.prod.int.phx2.redhat.com) (10.5.81.11) by
zmail24.collab.prod.int.phx2.redhat.com with LMTP; Thu, 2 Jul 2015 01:14:06
-0400 (EDT)
Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23])
by zmta04.collab.prod.int.phx2.redhat.com (Postfix) with ESMTP id 08529DA114;
Thu, 2 Jul 2015 01:14:06 -0400 (EDT)
Received: from [10.3.112.13] ([10.3.112.13])
by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t625E1nH006506;
Thu, 2 Jul 2015 01:14:03 -0400
Subject: [RHEL7.2 PATCH resend v3 1/4] Make get_elf64_phdr()/get_elf32_phdr()
public.
To: kexec-kdump-list@redhat.com
References: <55929BD5.7050709@redhat.com> <5594C856.6050503@redhat.com>
Cc: Minfei Huang <mhuang@redhat.com>, bhe@redhat.com, yishimat@redhat.com
From: Yasuaki Ishimatsu <yishimat@redhat.com>
Message-ID: <5594C899.1070106@redhat.com>
Date: Thu, 2 Jul 2015 01:14:01 -0400
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101
Thunderbird/38.0.1
MIME-Version: 1.0
In-Reply-To: <5594C856.6050503@redhat.com>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23
Content-Length: 3805
https://bugzilla.redhat.com/show_bug.cgi?id=1182377
The patch is back ported directory from the following upstream commit:
commit 3182be907d27584cd04dfb03d0ec5bf7134da87f
Author: Wang Xiao <wangx.fnst@cn.fujitsu.com>
Date: Mon Oct 20 13:38:45 2014 +0900
[PATCH v4 1/4] Make get_elf64_phdr()/get_elf32_phdr() public.
Move the following two functions from internal function to external
function.
get_elf64_phdr(int fd, char *filename, int index, Elf64_Phdr *phdr)
get_elf32_phdr(int fd, char *filename, int index, Elf32_Phdr *phdr)
Signed-of-by: Wang Xiao <wangx.fnst@cn.fujitsu.com>
Resolves: rhbz#1182377
Signed-off-by: Yasuaki Ishimatsu <yishimat@redhat.com>
Acked-by: Minfei Huang <mhuang@redhat.com>
---
makedumpfile-1.5.7/elf_info.c | 71 ++++++++++++++++++++---------------------
makedumpfile-1.5.7/elf_info.h | 2 +
2 files changed, 37 insertions(+), 36 deletions(-)
diff --git a/makedumpfile-1.5.7/elf_info.c b/makedumpfile-1.5.7/elf_info.c
index 5be1990..24936d4 100644
--- a/makedumpfile-1.5.7/elf_info.c
+++ b/makedumpfile-1.5.7/elf_info.c
@@ -95,42 +95,6 @@ static unsigned long size_xen_crash_info;
* Internal functions.
*/
static int
-get_elf64_phdr(int fd, char *filename, int index, Elf64_Phdr *phdr)
-{
- off_t offset;
-
- offset = sizeof(Elf64_Ehdr) + sizeof(Elf64_Phdr) * index;
-
- if (lseek(fd, offset, SEEK_SET) < 0) {
- ERRMSG("Can't seek %s. %s\n", filename, strerror(errno));
- return FALSE;
- }
- if (read(fd, phdr, sizeof(Elf64_Phdr)) != sizeof(Elf64_Phdr)) {
- ERRMSG("Can't read %s. %s\n", filename, strerror(errno));
- return FALSE;
- }
- return TRUE;
-}
-
-static int
-get_elf32_phdr(int fd, char *filename, int index, Elf32_Phdr *phdr)
-{
- off_t offset;
-
- offset = sizeof(Elf32_Ehdr) + sizeof(Elf32_Phdr) * index;
-
- if (lseek(fd, offset, SEEK_SET) < 0) {
- ERRMSG("Can't seek %s. %s\n", filename, strerror(errno));
- return FALSE;
- }
- if (read(fd, phdr, sizeof(Elf32_Phdr)) != sizeof(Elf32_Phdr)) {
- ERRMSG("Can't read %s. %s\n", filename, strerror(errno));
- return FALSE;
- }
- return TRUE;
-}
-
-static int
check_elf_format(int fd, char *filename, int *phnum, unsigned int *num_load)
{
int i;
@@ -446,6 +410,41 @@ int set_kcore_vmcoreinfo(uint64_t vmcoreinfo_addr, uint64_t vmcoreinfo_len)
/*
* External functions.
*/
+int
+get_elf64_phdr(int fd, char *filename, int index, Elf64_Phdr *phdr)
+{
+ off_t offset;
+
+ offset = sizeof(Elf64_Ehdr) + sizeof(Elf64_Phdr) * index;
+
+ if (lseek(fd, offset, SEEK_SET) < 0) {
+ ERRMSG("Can't seek %s. %s\n", filename, strerror(errno));
+ return FALSE;
+ }
+ if (read(fd, phdr, sizeof(Elf64_Phdr)) != sizeof(Elf64_Phdr)) {
+ ERRMSG("Can't read %s. %s\n", filename, strerror(errno));
+ return FALSE;
+ }
+ return TRUE;
+}
+
+int
+get_elf32_phdr(int fd, char *filename, int index, Elf32_Phdr *phdr)
+{
+ off_t offset;
+
+ offset = sizeof(Elf32_Ehdr) + sizeof(Elf32_Phdr) * index;
+
+ if (lseek(fd, offset, SEEK_SET) < 0) {
+ ERRMSG("Can't seek %s. %s\n", filename, strerror(errno));
+ return FALSE;
+ }
+ if (read(fd, phdr, sizeof(Elf32_Phdr)) != sizeof(Elf32_Phdr)) {
+ ERRMSG("Can't read %s. %s\n", filename, strerror(errno));
+ return FALSE;
+ }
+ return TRUE;
+}
/*
* Convert Physical Address to File Offset.
diff --git a/makedumpfile-1.5.7/elf_info.h b/makedumpfile-1.5.7/elf_info.h
index cbabf8a..e712253 100644
--- a/makedumpfile-1.5.7/elf_info.h
+++ b/makedumpfile-1.5.7/elf_info.h
@@ -27,6 +27,8 @@
#define MAX_SIZE_NHDR MAX(sizeof(Elf64_Nhdr), sizeof(Elf32_Nhdr))
+int get_elf64_phdr(int fd, char *filename, int index, Elf64_Phdr *phdr);
+int get_elf32_phdr(int fd, char *filename, int index, Elf32_Phdr *phdr);
off_t paddr_to_offset(unsigned long long paddr);
off_t paddr_to_offset2(unsigned long long paddr, off_t hint);
--
1.7.1