mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-10-02 21:17:17 +00:00
Detect invalid section indexes when we first read them.
We still detect the same errors, but now we do it earlier. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238024 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -537,6 +537,8 @@ std::error_code MachOObjectFile::getSymbolSection(DataRefImpl Symb,
|
|||||||
} else {
|
} else {
|
||||||
DataRefImpl DRI;
|
DataRefImpl DRI;
|
||||||
DRI.d.a = index - 1;
|
DRI.d.a = index - 1;
|
||||||
|
if (DRI.d.a >= Sections.size())
|
||||||
|
report_fatal_error("getSymbolSection: Invalid section index.");
|
||||||
Res = section_iterator(SectionRef(DRI, this));
|
Res = section_iterator(SectionRef(DRI, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2146,8 +2148,7 @@ MachOObjectFile::getSectionFinalSegmentName(DataRefImpl Sec) const {
|
|||||||
|
|
||||||
ArrayRef<char>
|
ArrayRef<char>
|
||||||
MachOObjectFile::getSectionRawName(DataRefImpl Sec) const {
|
MachOObjectFile::getSectionRawName(DataRefImpl Sec) const {
|
||||||
if (Sec.d.a >= Sections.size())
|
assert(Sec.d.a < Sections.size() && "Should have detected this earlier");
|
||||||
report_fatal_error("getSectionRawName: Invalid section index");
|
|
||||||
const section_base *Base =
|
const section_base *Base =
|
||||||
reinterpret_cast<const section_base *>(Sections[Sec.d.a]);
|
reinterpret_cast<const section_base *>(Sections[Sec.d.a]);
|
||||||
return makeArrayRef(Base->sectname);
|
return makeArrayRef(Base->sectname);
|
||||||
@@ -2155,8 +2156,7 @@ MachOObjectFile::getSectionRawName(DataRefImpl Sec) const {
|
|||||||
|
|
||||||
ArrayRef<char>
|
ArrayRef<char>
|
||||||
MachOObjectFile::getSectionRawFinalSegmentName(DataRefImpl Sec) const {
|
MachOObjectFile::getSectionRawFinalSegmentName(DataRefImpl Sec) const {
|
||||||
if (Sec.d.a >= Sections.size())
|
assert(Sec.d.a < Sections.size() && "Should have detected this earlier");
|
||||||
report_fatal_error("getSectionRawFinalSegmentName: Invalid section index");
|
|
||||||
const section_base *Base =
|
const section_base *Base =
|
||||||
reinterpret_cast<const section_base *>(Sections[Sec.d.a]);
|
reinterpret_cast<const section_base *>(Sections[Sec.d.a]);
|
||||||
return makeArrayRef(Base->segname);
|
return makeArrayRef(Base->segname);
|
||||||
|
Binary file not shown.
@@ -25,11 +25,8 @@ RUN: | FileCheck -check-prefix BAD-SYMBOL %s
|
|||||||
RUN: not llvm-objdump -t %p/Inputs/macho-invalid-symbol-name-past-eof 2>&1 \
|
RUN: not llvm-objdump -t %p/Inputs/macho-invalid-symbol-name-past-eof 2>&1 \
|
||||||
RUN: | FileCheck -check-prefix NAME-PAST-EOF %s
|
RUN: | FileCheck -check-prefix NAME-PAST-EOF %s
|
||||||
|
|
||||||
RUN: not llvm-objdump -t %p/Inputs/macho-invalid-section-index-getSectionRawFinalSegmentName 2>&1 \
|
|
||||||
RUN: | FileCheck -check-prefix INVALID-SECTION-IDX-SEG-NAME %s
|
|
||||||
|
|
||||||
RUN: not llvm-nm %p/Inputs/macho-invalid-section-index-getSectionRawName 2>&1 \
|
RUN: not llvm-nm %p/Inputs/macho-invalid-section-index-getSectionRawName 2>&1 \
|
||||||
RUN: | FileCheck -check-prefix INVALID-SECTION-IDX-SECT-NAME %s
|
RUN: | FileCheck -check-prefix INVALID-SECTION-IDX-SYMBOL-SEC %s
|
||||||
|
|
||||||
RUN: not llvm-objdump -t %p/Inputs/macho-invalid-getsection-index 2>&1 \
|
RUN: not llvm-objdump -t %p/Inputs/macho-invalid-getsection-index 2>&1 \
|
||||||
RUN: | FileCheck -check-prefix INVALID-SECTION-IDX-GETSECT %s
|
RUN: | FileCheck -check-prefix INVALID-SECTION-IDX-GETSECT %s
|
||||||
@@ -45,7 +42,6 @@ TOO-MANY-SECTS: Number of sections too large for size of load command
|
|||||||
BAD-SYMBOL: Requested symbol index is out of range
|
BAD-SYMBOL: Requested symbol index is out of range
|
||||||
NAME-PAST-EOF: Symbol name entry points before beginning or past end of file
|
NAME-PAST-EOF: Symbol name entry points before beginning or past end of file
|
||||||
|
|
||||||
INVALID-SECTION-IDX-SEG-NAME: getSectionRawFinalSegmentName: Invalid section index
|
INVALID-SECTION-IDX-SYMBOL-SEC: getSymbolSection: Invalid section index
|
||||||
INVALID-SECTION-IDX-SECT-NAME: getSectionRawName: Invalid section index
|
|
||||||
INVALID-SECTION-IDX-GETSECT: getSection: Invalid section index
|
INVALID-SECTION-IDX-GETSECT: getSection: Invalid section index
|
||||||
INVALID-SECTION-IDX-GETSECT64: getSection64: Invalid section index
|
INVALID-SECTION-IDX-GETSECT64: getSection64: Invalid section index
|
||||||
|
Reference in New Issue
Block a user