+/* This file is part of centaur.
+ *
+ * centaur is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License 2 as
+ * published by the Free Software Foundation.
+
+ * centaur is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with centaur. If not, see <http://www.gnu.org/licenses/>.
+ */
+
#include <assert.h>
#include <stdlib.h>
#include <libelfu/libelfu.h>
ELFU_WARN("elfu_eCheck: Sections %d and %d overlap in file.\n", i, j);
goto ERROR;
}
+
+ /* We may not have more than one symbol table */
+ if (shdrs[i].sh_type == SHT_SYMTAB && shdrs[j].sh_type == SHT_SYMTAB) {
+ ELFU_WARN("elfu_eCheck: Found more than one SYMTAB section.\n");
+ goto ERROR;
+ }
+
+ /* We may not have more than one dynamic symbol table */
+ if (shdrs[i].sh_type == SHT_DYNSYM && shdrs[j].sh_type == SHT_DYNSYM) {
+ ELFU_WARN("elfu_eCheck: Found more than one DYNSYM section.\n");
+ goto ERROR;
+ }
}
/* Section addr/offset should match parent PHDR.
if (PHDR_CONTAINS_SCN_IN_MEMORY(&phdrs[j], &shdrs[i])) {
GElf_Off shoff = phdrs[j].p_offset + (shdrs[i].sh_addr - phdrs[j].p_vaddr);
- if (shdrs[i].sh_offset != shoff
+ if ((shdrs[i].sh_offset != shoff && shdrs[i].sh_type != SHT_NOBITS)
|| !PHDR_CONTAINS_SCN_IN_FILE(&phdrs[j], &shdrs[i])) {
- ELFU_WARN("elfu_eCheck: Memory/file offsets/sizes are not congruent for SHDR %d, PHDR %d.\n", i, j);
+ ELFU_WARN("elfu_eCheck: SHDR %d and PHDR %d report conflicting file/memory regions.\n", i, j);
goto ERROR;
}
}