+/* 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 <string.h>
&lowestOffs, &highestOffsEnd);
if (phdr_maxsz < (me->ehdr.e_phnum + 1) * me->ehdr.e_phentsize
&& phdrmp == lowestAddr
- && phdrmp == lowestOffs) {
+ && phdrmp == lowestOffs
+ && (lowestAddr->phdr.p_vaddr >= 2 * lowestAddr->phdr.p_align)) {
ElfuPhdr *mp;
ElfuScn *ms;
GElf_Word size = ROUNDUP(me->ehdr.e_phentsize, phdrmp->phdr.p_align);
ElfuPhdr *highestOffsEnd;
ElfuPhdr *mp;
ElfuScn *ms;
- ElfuPhdr **phdrArr;
GElf_Off lastend = 0;
assert(me);
elfu_mPhdrLoadLowestHighest(me, &lowestAddr, &highestAddr,
&lowestOffs, &highestOffsEnd);
- phdrArr = malloc(elfu_mPhdrCount(me) * sizeof(*phdrArr));
- if (!phdrArr) {
- ELFU_WARN("elfu_mLayoutAuto: malloc failed for phdrArr.\n");
- return 1;
- }
-
lastend = OFFS_END(highestOffsEnd->phdr.p_offset, highestOffsEnd->phdr.p_filesz);