Ghidra is a software reverse engineering (SRE) framework
Merge branch 'GP-1936_ghidra1_Elf_PN_XNUM'
ghidra1d7f9cdfe5cfa
diff --cc Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/elf/ElfHeader.javaindex 15b11988db,2fb44a8af3..3506725254--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/elf/ElfHeader.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/elf/ElfHeader.java@@@ -161,9 -162,9 +162,9 @@@ public class ElfHeader implements Struce_version = reader.readNextInt();if (is32Bit()) {- e_entry = reader.readNextInt() & 0xffffffffL;- e_phoff = reader.readNextInt() & 0xffffffffL;- e_shoff = reader.readNextInt() & 0xffffffffL;- e_entry = Integer.toUnsignedLong(reader.readNextInt());- e_phoff = Integer.toUnsignedLong(reader.readNextInt());- e_shoff = Integer.toUnsignedLong(reader.readNextInt());++ e_entry = reader.readNextUnsignedInt();++ e_phoff = reader.readNextUnsignedInt();++ e_shoff = reader.readNextUnsignedInt();}else if (is64Bit()) {e_entry = reader.readNextLong();@@@ -195,6 -201,48 +201,48 @@@}}+ private ElfSectionHeader getSection0() throws IOException {+ if (section0 == null && e_shnum != 0) {+ long index = e_shoff;+ if (!providerContainsRegion(index, e_shentsize)) {+ return null;+ }+ reader.setPointerIndex(index);+ section0 = new ElfSectionHeader(reader, this);+ }+ return section0;+ }++ /**+ * Read extended program header count stored in first section header (ST_NULL) sh_info field value.- * Returned value is constrained to the range 0..0x7fffffff.++ * Returned value is restricted to the range 0..0x7fffffff.+ * @return extended program header count or 0 if not found or out of range+ * @throws IOException if file IO error occurs+ */+ private int readExtendedProgramHeaderCount() throws IOException {+ ElfSectionHeader s = getSection0();+ if (s != null && s.getType() == ElfSectionHeaderConstants.SHT_NULL) {+ long val = s.getInfo();+ return (val < 0 || val > Integer.MAX_VALUE) ? 0 : (int) val;+ }+ return 0;+ }++ /**+ * Read extended section header count stored in first section header (ST_NULL) sh_size field value.- * Returned value is constrained to the range 0..0x7fffffff.++ * Returned value is restricted to the range 0..0x7fffffff.+ * @return extended section header count or 0 if not found or out of range+ * @throws IOException if file IO error occurs+ */+ private int readExtendedSectionHeaderCount() throws IOException {+ ElfSectionHeader s = getSection0();+ if (s != null && s.getType() == ElfSectionHeaderConstants.SHT_NULL) {+ long val = s.getSize();+ return (val < 0 || val > Integer.MAX_VALUE) ? 0 : (int) val;+ }+ return 0;+ }+private void initElfLoadAdapter() {programHeaderTypeMap = new HashMap<>();