diff options
| author | Roland McGrath <[email protected]> | 2008-09-30 06:35:35 +0000 |
|---|---|---|
| committer | Roland McGrath <[email protected]> | 2008-09-30 06:35:35 +0000 |
| commit | 9cf28e4f899f97ecdc983a0af8e2be62f3d69058 (patch) | |
| tree | df4ddf5910d2854a66e71081fd4753acb1ebd6d8 /libelf/elf_begin.c | |
| parent | bb48a2702b6db50614fbbf08b02a1c7d83e28ecf (diff) | |
libdwfl/
2008-09-29 Roland McGrath <[email protected]>
* segment.c (insert): Must realloc DWFL->lookup_module here too.
(dwfl_report_segment): Clear DWFL->lookup_module before insert calls.
Diffstat (limited to 'libelf/elf_begin.c')
| -rw-r--r-- | libelf/elf_begin.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/libelf/elf_begin.c b/libelf/elf_begin.c index b95b06bf..bd385306 100644 --- a/libelf/elf_begin.c +++ b/libelf/elf_begin.c @@ -111,7 +111,11 @@ get_shnum (void *map_address, unsigned char *e_ident, int fildes, off_t offset, bool is32 = e_ident[EI_CLASS] == ELFCLASS32; /* Make the ELF header available. */ - if (e_ident[EI_DATA] == MY_ELFDATA) + if (e_ident[EI_DATA] == MY_ELFDATA + && (ALLOW_UNALIGNED + || (((size_t) e_ident + & ((is32 ? __alignof__ (Elf32_Ehdr) : __alignof__ (Elf64_Ehdr)) + - 1)) == 0))) ehdr.p = e_ident; else { @@ -130,8 +134,11 @@ get_shnum (void *map_address, unsigned char *e_ident, int fildes, off_t offset, else memcpy (&ehdr_mem, e_ident, sizeof (Elf32_Ehdr)); - CONVERT (ehdr_mem.e32.e_shnum); - CONVERT (ehdr_mem.e32.e_shoff); + if (e_ident[EI_DATA] != MY_ELFDATA) + { + CONVERT (ehdr_mem.e32.e_shnum); + CONVERT (ehdr_mem.e32.e_shoff); + } } else { @@ -143,8 +150,11 @@ get_shnum (void *map_address, unsigned char *e_ident, int fildes, off_t offset, else memcpy (&ehdr_mem, e_ident, sizeof (Elf64_Ehdr)); - CONVERT (ehdr_mem.e64.e_shnum); - CONVERT (ehdr_mem.e64.e_shoff); + if (e_ident[EI_DATA] != MY_ELFDATA) + { + CONVERT (ehdr_mem.e64.e_shnum); + CONVERT (ehdr_mem.e64.e_shoff); + } } } |
