Add warning for ignored loadable ELF segments.

base/loader/elf_object.cc:
    Print warning if there are more than two loadable segments.
    We currently assume there are at most two (text & data), and that's
    held so far, but it would be nice not to silently ignore others.

--HG--
extra : convert_revision : 1b3e693e95ba1210b09528b97819a7fa86426edc
This commit is contained in:
Steve Reinhardt 2006-03-16 10:31:00 -05:00
parent 7359e2df01
commit 31a20c88c5

View file

@ -75,8 +75,7 @@ ElfObject::tryFile(const string &fname, int fd, size_t len, uint8_t *data)
DPRINTFR(Loader, "Not ELF\n"); DPRINTFR(Loader, "Not ELF\n");
elf_end(elf); elf_end(elf);
return NULL; return NULL;
} } else {
else {
//Detect the architecture //Detect the architecture
//Versioning issues in libelf need to be resolved to get the correct //Versioning issues in libelf need to be resolved to get the correct
//SPARC constants. //SPARC constants.
@ -213,8 +212,7 @@ ElfObject::ElfObject(const string &_filename, int _fd,
bss.size = phdr.p_memsz - phdr.p_filesz; bss.size = phdr.p_memsz - phdr.p_filesz;
bss.baseAddr = phdr.p_vaddr + phdr.p_filesz; bss.baseAddr = phdr.p_vaddr + phdr.p_filesz;
bss.fileImage = NULL; bss.fileImage = NULL;
} } else if (data.size == 0) { // have text, this must be data
else if (data.size == 0) { // have text, this must be data
data.baseAddr = phdr.p_vaddr; data.baseAddr = phdr.p_vaddr;
data.size = phdr.p_filesz; data.size = phdr.p_filesz;
data.fileImage = fileData + phdr.p_offset; data.fileImage = fileData + phdr.p_offset;
@ -227,6 +225,10 @@ ElfObject::ElfObject(const string &_filename, int _fd,
bss.size = phdr.p_memsz - phdr.p_filesz; bss.size = phdr.p_memsz - phdr.p_filesz;
bss.baseAddr = phdr.p_vaddr + phdr.p_filesz; bss.baseAddr = phdr.p_vaddr + phdr.p_filesz;
bss.fileImage = NULL; bss.fileImage = NULL;
} else {
warn("More than two loadable segments in ELF object.");
warn("Ignoring segment @ 0x%x length 0x%x.",
phdr.p_vaddr, phdr.p_filesz);
} }
} }