summaryrefslogtreecommitdiffstats
path: root/lib/libelf/_libelf.h
diff options
context:
space:
mode:
authorjkoshy <jkoshy@FreeBSD.org>2006-12-25 02:22:22 +0000
committerjkoshy <jkoshy@FreeBSD.org>2006-12-25 02:22:22 +0000
commit26d8253ac6532abcb8d1c8d57743998f5368173b (patch)
tree1f1c4db9c6b866adf56e5cc3eccd23baaa57af28 /lib/libelf/_libelf.h
parent44313eba34c379a180dc73dcd02ab9c415941db3 (diff)
downloadFreeBSD-src-26d8253ac6532abcb8d1c8d57743998f5368173b.zip
FreeBSD-src-26d8253ac6532abcb8d1c8d57743998f5368173b.tar.gz
Keep shadow copies of the `e_shnum', `e_phnum' and `e_shstrndx'
members of the ELF Executable Header inside the library-private `struct _Elf' descriptor and only update the underlying Elf{32,64}_Ehdr structure on an elf_update(3) call. These fields of the Ehdr structure are technically `out of bounds' for an application program per the ELF(3) API, but we've seen applications that initialize a new Ehdr structure using memcpy(), messing up the library's invariants. [1] Implement elf_getphnum() and handle ELF objects with more than 64K program header table entries. Reported by: jb [1]
Diffstat (limited to 'lib/libelf/_libelf.h')
-rw-r--r--lib/libelf/_libelf.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/libelf/_libelf.h b/lib/libelf/_libelf.h
index 02e7cf5..08185cc 100644
--- a/lib/libelf/_libelf.h
+++ b/lib/libelf/_libelf.h
@@ -71,6 +71,7 @@ extern struct _libelf_globals _libelf;
*/
#define LIBELF_F_MALLOCED 0x010000 /* whether data was malloc'ed */
#define LIBELF_F_MMAP 0x020000 /* whether e_rawfile was mmap'ed */
+#define LIBELF_F_SHDRS_LOADED 0x040000 /* whether all shdrs were read in */
struct _Elf {
int e_activations; /* activation count */
@@ -107,6 +108,9 @@ struct _Elf {
Elf64_Phdr *e_phdr64;
} e_phdr;
STAILQ_HEAD(, _Elf_Scn) e_scn; /* section list */
+ size_t e_nphdr; /* number of Phdr entries */
+ size_t e_nscn; /* number of sections */
+ size_t e_strndx; /* string table section index */
} e_elf;
} e_u;
};
@@ -171,9 +175,6 @@ void (*_libelf_get_translator(Elf_Type _t, int _direction, int _elfclass))
(char *_dst, char *_src, size_t _cnt, int _byteswap);
void *_libelf_getphdr(Elf *_e, int _elfclass);
void *_libelf_getshdr(Elf_Scn *_scn, int _elfclass);
-int _libelf_getshnum(Elf *_e, void *_eh, int _elfclass, size_t *_shnum);
-int _libelf_getshstrndx(Elf *_e, void *_eh, int _elfclass,
- size_t *_shstrndx);
void _libelf_init_elf(Elf *_e, Elf_Kind _kind);
int _libelf_malign(Elf_Type _t, int _elfclass);
size_t _libelf_msize(Elf_Type _t, int _elfclass, unsigned int _version);
@@ -181,6 +182,7 @@ void *_libelf_newphdr(Elf *_e, int _elfclass, size_t _count);
Elf_Data *_libelf_release_data(Elf_Data *_d);
Elf *_libelf_release_elf(Elf *_e);
Elf_Scn *_libelf_release_scn(Elf_Scn *_s);
+int _libelf_setphnum(Elf *_e, void *_eh, int _elfclass, size_t _phnum);
int _libelf_setshnum(Elf *_e, void *_eh, int _elfclass, size_t _shnum);
int _libelf_setshstrndx(Elf *_e, void *_eh, int _elfclass,
size_t _shstrndx);
OpenPOWER on IntegriCloud