Improve error message for files with no sections

Bug: http://b/25801618
Change-Id: I4f4f368e727ff48c84781279e3d17d4ac2d1b6b0
This commit is contained in:
Dmitriy Ivanov 2015-11-20 10:42:02 -08:00
parent 43c9045017
commit b76123fed8

View file

@ -268,6 +268,11 @@ bool ElfReader::ReadProgramHeaders() {
bool ElfReader::ReadSectionHeaders() {
shdr_num_ = header_.e_shnum;
if (shdr_num_ == 0) {
DL_ERR("\"%s\" there are no section headers in this file", name_.c_str());
return false;
}
if (!shdr_fragment_.Map(fd_, file_offset_, header_.e_shoff, shdr_num_ * sizeof(ElfW(Shdr)))) {
DL_ERR("\"%s\" shdr mmap failed: %s", name_.c_str(), strerror(errno));
return false;
@ -288,7 +293,7 @@ bool ElfReader::ReadDynamicSection() {
}
if (dynamic_shdr == nullptr) {
DL_ERR("\"%s\" .dynamic section was not found", name_.c_str());
DL_ERR("\"%s\" .dynamic section header was not found", name_.c_str());
return false;
}