mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-11 07:03:09 -04:00
elf: Add elf headers helpers support
ELF header format is been used in multiple places, add helper functions to get section, program headers, and string table section details of the elf header. Change-Id: Ib67b6f25a3a9c32305710eae4ad66bea511d6799 Signed-off-by: Lingutla Chandrasekhar <clingutla@codeaurora.org> Signed-off-by: Rishabh Bhatnagar <rishabhb@codeaurora.org> Signed-off-by: Raghavendra Rao Ananta <rananta@codeaurora.org>
This commit is contained in:
parent
2a6ff2fd81
commit
5dd4bc7f96
1 changed files with 33 additions and 0 deletions
|
|
@ -45,6 +45,39 @@ extern Elf64_Dyn _DYNAMIC [];
|
|||
|
||||
#endif
|
||||
|
||||
/* Generic helpers for ELF use */
|
||||
/* Return first section header */
|
||||
static inline struct elf_shdr *elf_sheader(struct elfhdr *hdr)
|
||||
{
|
||||
return (struct elf_shdr *)((size_t)hdr + (size_t)hdr->e_shoff);
|
||||
}
|
||||
|
||||
/* Return idx section header */
|
||||
static inline struct elf_shdr *elf_section(struct elfhdr *hdr, int idx)
|
||||
{
|
||||
return &elf_sheader(hdr)[idx];
|
||||
}
|
||||
|
||||
/* Return first program header */
|
||||
static inline struct elf_phdr *elf_pheader(struct elfhdr *hdr)
|
||||
{
|
||||
return (struct elf_phdr *)((size_t)hdr + (size_t)hdr->e_phoff);
|
||||
}
|
||||
|
||||
/* Return idx program header */
|
||||
static inline struct elf_phdr *elf_program(struct elfhdr *hdr, int idx)
|
||||
{
|
||||
return &elf_pheader(hdr)[idx];
|
||||
}
|
||||
|
||||
/* Retunr section's string table header */
|
||||
static inline char *elf_str_table(struct elfhdr *hdr)
|
||||
{
|
||||
if (hdr->e_shstrndx == SHN_UNDEF)
|
||||
return NULL;
|
||||
return (char *)hdr + elf_section(hdr, hdr->e_shstrndx)->sh_offset;
|
||||
}
|
||||
|
||||
/* Optional callbacks to write extra ELF notes. */
|
||||
struct file;
|
||||
struct coredump_params;
|
||||
|
|
|
|||
Loading…
Reference in a new issue