Simplify ELF parser code.

The layout of Elf32_Nhdr and Elf64_Nhdr is the same, so remove
templating and code that extracts the elfclass from the ELF file.

Testing: "make check" and breakpad_unittests when patched into
chromium.

Bug: chromium:716484
Change-Id: I41442cfff48afc6ae1a5b604d22b67550a910376
Reviewed-on: https://chromium-review.googlesource.com/514450
Reviewed-by: Mike Frysinger <vapier@chromium.org>
This commit is contained in:
Peter Collingbourne 2017-05-24 16:25:09 -07:00 committed by Mike Frysinger
parent 77305c3ae6
commit fbfd41af5f
4 changed files with 17 additions and 40 deletions

View file

@ -122,8 +122,7 @@ bool FindElfSection(const void *elf_mapped_base,
const char *section_name,
uint32_t section_type,
const void **section_start,
size_t *section_size,
int *elfclass) {
size_t *section_size) {
assert(elf_mapped_base);
assert(section_start);
assert(section_size);
@ -135,10 +134,6 @@ bool FindElfSection(const void *elf_mapped_base,
return false;
int cls = ElfClass(elf_mapped_base);
if (elfclass) {
*elfclass = cls;
}
const char* elf_base =
static_cast<const char*>(elf_mapped_base);
@ -158,8 +153,7 @@ bool FindElfSection(const void *elf_mapped_base,
bool FindElfSegment(const void *elf_mapped_base,
uint32_t segment_type,
const void **segment_start,
size_t *segment_size,
int *elfclass) {
size_t *segment_size) {
assert(elf_mapped_base);
assert(segment_start);
assert(segment_size);
@ -171,10 +165,6 @@ bool FindElfSegment(const void *elf_mapped_base,
return false;
int cls = ElfClass(elf_mapped_base);
if (elfclass) {
*elfclass = cls;
}
const char* elf_base =
static_cast<const char*>(elf_mapped_base);