summaryrefslogtreecommitdiff
path: root/elf_info.c
diff options
context:
space:
mode:
authorWang Xiao <wangx.fnst@cn.fujitsu.com>2014-10-20 13:38:45 +0900
committerAtsushi Kumagai <kumagai-atsushi@mxc.nes.nec.co.jp>2014-10-20 13:38:45 +0900
commit3182be907d27584cd04dfb03d0ec5bf7134da87f (patch)
tree9a060cace2a5cd527b19b38310e08607a1a8054b /elf_info.c
parent56649f7b6bfe7b5060ea0332982a7344ab4e1324 (diff)
[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>
Diffstat (limited to 'elf_info.c')
-rw-r--r--elf_info.c71
1 files changed, 35 insertions, 36 deletions
diff --git a/elf_info.c b/elf_info.c
index 5be1990..24936d4 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;
@@ -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.