From: "Wang, Xiao/Wang Xiao" <wangx.fnst@cn.fujitsu.com>
To: kexec@lists.infradead.org
Subject: [PATCH 1/3] makedumpfile: make get_elf64_phdr()/get_elf32_phdr() public
Date: Fri, 19 Sep 2014 17:22:04 +0800 [thread overview]
Message-ID: <541BF5BC.3020609@cn.fujitsu.com> (raw)
In-Reply-To: <541BF470.3050603@cn.fujitsu.com>
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>
---
elf_info.c | 71
+++++++++++++++++++++++++++++------------------------------
elf_info.h | 2 +
2 files changed, 37 insertions(+), 36 deletions(-)
diff --git a/elf_info.c b/elf_info.c
index b277f69..1499328 100644
--- a/elf_info.c
+++ b/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;
@@ -399,6 +363,41 @@ get_pt_note_info(void)
/*
* 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/elf_info.h b/elf_info.h
index 801faff..925c9f5 100644
--- a/elf_info.h
+++ b/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
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
prev parent reply other threads:[~2014-09-19 9:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-16 9:48 [PATCH 2/2] makedumpfile: make the incomplete vmcore generated by ENOSPC error analyzable Wang, Xiao/Wang Xiao
2014-09-17 6:47 ` Petr Tesarik
2014-09-18 7:26 ` Wang, Xiao/Wang Xiao
2014-09-18 11:18 ` HATAYAMA, Daisuke
2014-09-18 12:29 ` HATAYAMA, Daisuke
2014-09-19 9:16 ` Wang, Xiao/Wang Xiao
2014-09-19 9:22 ` Wang, Xiao/Wang Xiao [this message]
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=541BF5BC.3020609@cn.fujitsu.com \
--to=wangx.fnst@cn.fujitsu.com \
--cc=kexec@lists.infradead.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.