[PATCH 05/19] Export the reusable ELF core generation routines

From: Janani Venkataraman
Date: Fri Oct 04 2013 - 06:31:36 EST


From:Suzuki K. Poulose <suzuki@xxxxxxxxxx>

Export the ELF class specific core generation helper functions via
elfcore-internal.h

Signed-off-by: Suzuki K. Poulose <suzuki@xxxxxxxxxx>
---
fs/binfmt_elf.c | 10 +++++-----
include/linux/elfcore-internal.h | 28 +++++++++++++++++++++++++++-
2 files changed, 32 insertions(+), 6 deletions(-)

diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 4eee017..3f13203 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1137,7 +1137,7 @@ static int writenote(struct memelfnote *men, struct file *file,
}
#undef DUMP_WRITE

-static void fill_elf_header(struct elfhdr *elf, int segs,
+void fill_elf_header(struct elfhdr *elf, int segs,
u16 machine, u32 flags)
{
memset(elf, 0, sizeof(*elf));
@@ -1177,7 +1177,7 @@ static void fill_elf_note_phdr(struct elf_phdr *phdr, int sz, loff_t offset)
* fill up all the fields in prstatus from the given task struct, except
* registers which need to be filled up separately.
*/
-static void fill_prstatus(struct elf_prstatus *prstatus,
+void fill_prstatus(struct elf_prstatus *prstatus,
struct task_struct *p, long signr)
{
prstatus->pr_info.si_signo = prstatus->pr_cursig = signr;
@@ -1210,7 +1210,7 @@ static void fill_prstatus(struct elf_prstatus *prstatus,
cputime_to_timeval(p->signal->cstime, &prstatus->pr_cstime);
}

-static int fill_psinfo(struct elf_prpsinfo *psinfo, struct task_struct *p,
+int fill_psinfo(struct elf_prpsinfo *psinfo, struct task_struct *p,
struct mm_struct *mm)
{
const struct cred *cred;
@@ -1265,7 +1265,7 @@ static int fill_psinfo(struct elf_prpsinfo *psinfo, struct task_struct *p,
return 0;
}

-static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
+void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
{
elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
int i = 0;
@@ -1858,7 +1858,7 @@ static void free_note_info(struct elf_note_info *info)

#endif

-static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
+void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
elf_addr_t e_shoff, int segs)
{
elf->e_shoff = e_shoff;
diff --git a/include/linux/elfcore-internal.h b/include/linux/elfcore-internal.h
index 9e9cd93..8c5323a 100644
--- a/include/linux/elfcore-internal.h
+++ b/include/linux/elfcore-internal.h
@@ -14,7 +14,7 @@
#define __ELF_CORE_INTERNAL_H

#ifdef __KERNEL__
-
+#include <linux/elfcore.h>
/* An ELF note in memory */
struct memelfnote
{
@@ -42,5 +42,31 @@ extern unsigned long vma_dump_size(struct task_struct *task,
struct vm_area_struct *vma,
unsigned long mm_flags);

+/* Core dump generation routines for native ELF class */
+extern void fill_elf_header(struct elfhdr *elf, int segs,
+ u16 machine, u32 flags);
+extern void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr,
+ elf_addr_t e_shoff, int segs);
+extern void fill_prstatus(struct elf_prstatus *prstatus,
+ struct task_struct *p, long signr);
+extern int fill_psinfo(struct elf_prpsinfo *psinfo, struct task_struct *p,
+ struct mm_struct *mm);
+extern void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm);
+
+/* compat ELF class variant of the above helpers*/
+#ifdef CONFIG_COMPAT_BINFMT_ELF
+#include <linux/elfcore-compat.h>
+
+extern void compat_fill_extnum_info(struct elf32_hdr *elf, struct elf32_shdr *shdr,
+ Elf32_Addr e_shoff, int segs);
+extern void compat_fill_prstatus(struct compat_elf_prstatus *prstatus,
+ struct task_struct *p, long signr);
+extern int compat_fill_psinfo(struct compat_elf_prpsinfo *psinfo, struct task_struct *p,
+ struct mm_struct *mm);
+extern void compat_fill_auxv_note(struct memelfnote *note, struct mm_struct *mm);
+extern void compat_fill_elf_header(struct elf32_hdr *elf, int segs,
+ u16 machine, u32 flags);
+#endif /* CONFIG_COMPAT_BINFMT_ELF */
+
#endif
#endif

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/