mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Merge pull request #83582 from augusto2112/fix-elf-shnum
[RemoteInspection] Handle special case of large amount of ELF sections.
This commit is contained in:
@@ -565,6 +565,26 @@ public:
|
||||
|
||||
if (sizeof(typename T::Section) > SectionEntrySize)
|
||||
return {};
|
||||
|
||||
// Special handling for large amount of sections.
|
||||
// From the elf man page, describing e_shnum:
|
||||
//
|
||||
// If the number of entries in the section header table is
|
||||
// larger than or equal to SHN_LORESERVE (0xff00), e_shnum
|
||||
// holds the value zero and the real number of entries in the
|
||||
// section header table is held in the sh_size member of the
|
||||
// initial entry in section header table. Otherwise, the
|
||||
// sh_size member of the initial entry in the section header
|
||||
// table holds the value zero.
|
||||
if (SectionHdrNumEntries == 0 && SectionEntrySize > 0) {
|
||||
auto SecBuf = readData(SectionHdrAddress, sizeof(typename T::Section));
|
||||
if (!SecBuf)
|
||||
return {};
|
||||
const typename T::Section *FirstSectHdr =
|
||||
reinterpret_cast<const typename T::Section *>(SecBuf);
|
||||
SectionHdrNumEntries = FirstSectHdr->sh_size;
|
||||
}
|
||||
|
||||
if (SectionHdrNumEntries == 0)
|
||||
return {};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user