From f8083bfc5080fea1a66eedfefc53b31526f4cd34 Mon Sep 17 00:00:00 2001 From: Filipe Cabecinhas Date: Thu, 15 Jan 2015 22:52:38 +0000 Subject: [PATCH] Report fatal errors instead of segfaulting/asserting on a few invalid accesses while reading MachO files. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Shift an older “invalid file” test to get a consistent naming for these tests. Bugs found by afl-fuzz Reviewers: rafael Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D6945 llvm-svn: 226219 --- lib/Object/MachOObjectFile.cpp | 54 +++++++++++++++--- .../Inputs/macho-invalid-bad-symbol-index | Bin 0 -> 4536 bytes .../Inputs/macho-invalid-getsection-index | Bin 0 -> 316 bytes .../Inputs/macho-invalid-no-size-for-sections | Bin 0 -> 104 bytes ...ection-index-getSectionRawFinalSegmentName | Bin 0 -> 4536 bytes ...ho-invalid-section-index-getSectionRawName | Bin 0 -> 4536 bytes .../Inputs/macho-invalid-symbol-name-past-eof | Bin 0 -> 4536 bytes .../macho-invalid-too-small-load-command | Bin 0 -> 36 bytes ...cho-invalid-too-small-segment-load-command | Bin 0 -> 104 bytes ...ho-zero-ncmds => macho-invalid-zero-ncmds} | Bin .../Inputs/macho64-invalid-getsection-index | Bin 0 -> 4536 bytes .../macho64-invalid-incomplete-load-command | Bin 0 -> 36 bytes .../macho64-invalid-no-size-for-sections | Bin 0 -> 104 bytes .../macho64-invalid-too-small-load-command | Bin 0 -> 40 bytes ...o64-invalid-too-small-segment-load-command | Bin 0 -> 104 bytes test/Object/macho-invalid.test | 51 +++++++++++++++++ test/Object/objdump-macho-quirks.test | 9 --- 17 files changed, 97 insertions(+), 17 deletions(-) create mode 100644 test/Object/Inputs/macho-invalid-bad-symbol-index create mode 100644 test/Object/Inputs/macho-invalid-getsection-index create mode 100644 test/Object/Inputs/macho-invalid-no-size-for-sections create mode 100644 test/Object/Inputs/macho-invalid-section-index-getSectionRawFinalSegmentName create mode 100644 test/Object/Inputs/macho-invalid-section-index-getSectionRawName create mode 100644 test/Object/Inputs/macho-invalid-symbol-name-past-eof create mode 100644 test/Object/Inputs/macho-invalid-too-small-load-command create mode 100644 test/Object/Inputs/macho-invalid-too-small-segment-load-command rename test/Object/Inputs/{macho-zero-ncmds => macho-invalid-zero-ncmds} (100%) create mode 100644 test/Object/Inputs/macho64-invalid-getsection-index create mode 100644 test/Object/Inputs/macho64-invalid-incomplete-load-command create mode 100644 test/Object/Inputs/macho64-invalid-no-size-for-sections create mode 100644 test/Object/Inputs/macho64-invalid-too-small-load-command create mode 100644 test/Object/Inputs/macho64-invalid-too-small-segment-load-command create mode 100644 test/Object/macho-invalid.test delete mode 100644 test/Object/objdump-macho-quirks.test diff --git a/lib/Object/MachOObjectFile.cpp b/lib/Object/MachOObjectFile.cpp index 978988c2569..a367a49f6bc 100644 --- a/lib/Object/MachOObjectFile.cpp +++ b/lib/Object/MachOObjectFile.cpp @@ -38,8 +38,12 @@ namespace { }; } -template +template static T getStruct(const MachOObjectFile *O, const char *P) { + // Don't read before the beginning or past the end of the file + if (P < O->getData().begin() || P + sizeof(T) > O->getData().end()) + report_fatal_error("Malformed MachO file."); + T Cmd; memcpy(&Cmd, P, sizeof(T)); if (O->isLittleEndian() != sys::IsLittleEndianHost) @@ -47,15 +51,26 @@ static T getStruct(const MachOObjectFile *O, const char *P) { return Cmd; } +template +static uint32_t getSegmentLoadCommandNumSections(const SegmentCmd &S, + uint32_t Cmdsize) { + const unsigned SectionSize = sizeof(SegmentCmd); + if (S.nsects > std::numeric_limits::max() / SectionSize || + S.nsects * SectionSize > Cmdsize - sizeof(S)) + report_fatal_error( + "Number of sections too large for size of load command."); + return S.nsects; +} + static uint32_t getSegmentLoadCommandNumSections(const MachOObjectFile *O, const MachOObjectFile::LoadCommandInfo &L) { - if (O->is64Bit()) { - MachO::segment_command_64 S = O->getSegment64LoadCommand(L); - return S.nsects; - } - MachO::segment_command S = O->getSegmentLoadCommand(L); - return S.nsects; + if (O->is64Bit()) + return getSegmentLoadCommandNumSections(O->getSegment64LoadCommand(L), + L.C.cmdsize); + + return getSegmentLoadCommandNumSections(O->getSegmentLoadCommand(L), + L.C.cmdsize); } static bool isPageZeroSegment(const MachOObjectFile *O, @@ -281,6 +296,12 @@ MachOObjectFile::MachOObjectFile(MemoryBufferRef Object, bool IsLittleEndian, } UuidLoadCmd = Load.Ptr; } else if (Load.C.cmd == SegmentLoadType) { + const unsigned SegmentLoadSize = this->is64Bit() + ? sizeof(MachO::segment_command_64) + : sizeof(MachO::segment_command); + if (Load.C.cmdsize < SegmentLoadSize) + report_fatal_error("Segment load command size is too small."); + uint32_t NumSections = getSegmentLoadCommandNumSections(this, Load); for (unsigned J = 0; J < NumSections; ++J) { const char *Sec = getSectionPtr(this, Load, J); @@ -315,6 +336,8 @@ std::error_code MachOObjectFile::getSymbolName(DataRefImpl Symb, StringRef StringTable = getStringTableData(); MachO::nlist_base Entry = getSymbolTableEntryBase(this, Symb); const char *Start = &StringTable.data()[Entry.n_strx]; + if (Start >= getData().end()) + report_fatal_error("Symbol name entry points past end of file."); Res = StringRef(Start); return object_error::success; } @@ -1204,7 +1227,8 @@ basic_symbol_iterator MachOObjectFile::getSymbolByIndex(unsigned Index) const { return basic_symbol_iterator(SymbolRef(DRI, this)); MachO::symtab_command Symtab = getSymtabLoadCommand(); - assert(Index < Symtab.nsyms && "Requested symbol index is out of range."); + if (Index >= Symtab.nsyms) + report_fatal_error("Requested symbol index is out of range."); unsigned SymbolTableEntrySize = is64Bit() ? sizeof(MachO::nlist_64) : sizeof(MachO::nlist); DRI.p = reinterpret_cast(getPtr(this, Symtab.symoff)); @@ -2108,6 +2132,8 @@ MachOObjectFile::getSectionFinalSegmentName(DataRefImpl Sec) const { ArrayRef MachOObjectFile::getSectionRawName(DataRefImpl Sec) const { + if (Sec.d.a >= Sections.size()) + report_fatal_error("getSectionRawName: Invalid section index"); const section_base *Base = reinterpret_cast(Sections[Sec.d.a]); return makeArrayRef(Base->sectname); @@ -2115,6 +2141,8 @@ MachOObjectFile::getSectionRawName(DataRefImpl Sec) const { ArrayRef MachOObjectFile::getSectionRawFinalSegmentName(DataRefImpl Sec) const { + if (Sec.d.a >= Sections.size()) + report_fatal_error("getSectionRawFinalSegmentName: Invalid section index"); const section_base *Base = reinterpret_cast(Sections[Sec.d.a]); return makeArrayRef(Base->segname); @@ -2205,6 +2233,8 @@ MachOObjectFile::getFirstLoadCommandInfo() const { sizeof(MachO::mach_header); Load.Ptr = getPtr(this, HeaderSize); Load.C = getStruct(this, Load.Ptr); + if (Load.C.cmdsize < 8) + report_fatal_error("Load command with size < 8 bytes."); return Load; } @@ -2213,14 +2243,22 @@ MachOObjectFile::getNextLoadCommandInfo(const LoadCommandInfo &L) const { MachOObjectFile::LoadCommandInfo Next; Next.Ptr = L.Ptr + L.C.cmdsize; Next.C = getStruct(this, Next.Ptr); + if (Next.C.cmdsize < 8) + report_fatal_error("Load command with size < 8 bytes."); return Next; } MachO::section MachOObjectFile::getSection(DataRefImpl DRI) const { + // TODO: What if Sections.size() == 0? + if (DRI.d.a >= Sections.size()) + report_fatal_error("getSection: Invalid section index."); return getStruct(this, Sections[DRI.d.a]); } MachO::section_64 MachOObjectFile::getSection64(DataRefImpl DRI) const { + // TODO: What if Sections.size() == 0? + if (DRI.d.a >= Sections.size()) + report_fatal_error("getSection64: Invalid section index."); return getStruct(this, Sections[DRI.d.a]); } diff --git a/test/Object/Inputs/macho-invalid-bad-symbol-index b/test/Object/Inputs/macho-invalid-bad-symbol-index new file mode 100644 index 0000000000000000000000000000000000000000..294bbde3ddfffbf5102115ae5428cb1b81936d23 GIT binary patch literal 4536 zcmeHLK~EDw6rKeI0*zF|K_iK%Xi!53wQ5N`sId{EL4=YR6P@g`Q&`g$>~5j;puKqT zhS4iO!8;e@!GlNt0rBF|KR}G}`?j-o+tkD#urGN#^SycV-pn_>eEoLt^Y@?-R=*I< zJ|V;?JO}VbOkgI&3HTgbsm0s(@=x+h4;k$=s}uG_tdm2cQic5ELT5_2KiwG<2IFkv zFdRn;O{qZF0|PL0*K6Vetar?$5Fcu%6Ex#csaj>*tGLRm6gRNYUGIabM-FJjP{UMVh4Bxz6hrc8E5V=Jl+rRzw8LICg3T!toc=0@*L?lN-i+% zB%J41n{9aegI7O)9DnwzH1J4IA{HKP7@gr4BaD$Yh5K?J-#>2blY?`u^^TwL^RU{z z(SNz&2fCcOlfgMWr?vY$2KJl5hxfi37Uqd13?vLB3?vLB3?vLB3?vLB z3?vLB40JQFGWYh!9)n-=zc@Vova>@SHBJDFkJKyFGg*xE_eR@rP7RrYj!CywSSZKF z5T{u$mxNVMTj|u`P}raq#)5*r?o;J;rR#dN7HGAuZC6*t>9Xxr#5p$Y7tK>9Kbjou zrzp#B!Xw!?h8VLTy~5Z4M(!SoNh-jW+~q=~@fc+NI6ezp?6<`3?z;ll*(8Gx@6Wk{ zPsT7~)P#}lCtkoOj$Hpw;%8@IYn!ql?djY# e$Gv_fvmsPSw(9W=traR_&zvOy literal 0 HcmV?d00001 diff --git a/test/Object/Inputs/macho-invalid-getsection-index b/test/Object/Inputs/macho-invalid-getsection-index new file mode 100644 index 0000000000000000000000000000000000000000..b7e4b95bc9b186c2c3b9f5f98badf4e65d90771a GIT binary patch literal 316 zcmX^2>+L^w1_lOZAZ7$&79jot#0&}$ehr9?1&9L01b`YqG)O-PgY<(ye0)i2MG1rr z;fJ_Jgdq4J7EC|LJ~&`uXn?U*fD8c;hl>j=!~`TIfLH@)3CJE3Ai)8oxq&zUh>-zE q9)!sOp`A|yc7QY+L@VC}0HAAnbv}w*a!^s literal 0 HcmV?d00001 diff --git a/test/Object/Inputs/macho-invalid-section-index-getSectionRawFinalSegmentName b/test/Object/Inputs/macho-invalid-section-index-getSectionRawFinalSegmentName new file mode 100644 index 0000000000000000000000000000000000000000..e3f658659226f8bee05714558525aa63377013bd GIT binary patch literal 4536 zcmeHL!DsM*D7DrUM9{}fXVQ)&Y0XU9#D!+# z!d*qT{RH>jhzl1k{e$Ahr9V(aJZCavCLw|!Fc5fT=aW**! z$B_cl+IJd$2r%^4YvBT{cQi~PKF~=gXvLw{_3D;ewY6I_=&koXtamIdKpfqzU(F8x_vaVx74FPO+<~7i-a@{1gP;g`3#UQZ(|F&R zehqqKsKY$ok!NfGk6@fSBC?H<^F=sqICSP7g2(#-{+As_)&x8aS9PzZ%C4pCX4wX& zoq+QktFujaFLmYf$MI*c%0myGNyKn8G)8Cmg$OeSo5Fp$kMAEh_Q}J!)_%uN_<0ze z-su0R>G@72dpnDBxK?}jISlMKgAeb0KE(Op5F!_2_$KCwB@84CBn%`BBn%`BBn%`B zBn%`BBni;vVR)H6AZ^!K5*;hY*W4IPu|sIWke zjUi4mUM`8z$QYS)YB*@n4r4(>Uk~WYnsyq_O5Jz#nq%5dO-@xzw<>4ZbWmC+!~AHn zzn7*gzX6YA-xy-dg7gYvLm0VxBqpf<+j5r+k;Y??_2c*qaB0wxot<|@uCqxNAKssH z4WEo*#;6G+-A}xLPaN9}hDLclYP7{0!_5G9>c0jyT7T~*6QY(qr{<}WTXr`bWjmY7 zES0By$MZcUW_Cr?rdd;^^)krwRAWW?dNWtqs(F{1tFt*jfBl7JJ@=|!ZU(lxp^D0! g&R@0cYnQX@q64yZpJ!;VP!Vg-uUp!}pA~qWKkmAmumAu6 literal 0 HcmV?d00001 diff --git a/test/Object/Inputs/macho-invalid-section-index-getSectionRawName b/test/Object/Inputs/macho-invalid-section-index-getSectionRawName new file mode 100644 index 0000000000000000000000000000000000000000..9cd3e1cace8cb8fb0409eb0a5c494a88c0e44b7a GIT binary patch literal 4536 zcmeHL!A=uV6ukoqL>j4vg+>xl(V&Jt)T$+Mp~Oar1`$ePO!Q@jnZlU1U}p-g3+={* zJB)7m1ov!=3l}c^1LDS|KR}G}oav06HZ}1B<|cREJNMmp?|bKUbNcPz=kGxgqhF-i zCn6*89KahH$4ulTd=9Sl;+=c>C;6p^jCPvQ340>e$stkeLjG}~GbPxc?u zUJbfqsKY$ok!P#}4`ZA>CbEN(^F=sqD0Jo?fyes+{+As^);K%`S2eGyO0K2sM#%=I zor3cmYcmaZfAHGpk7LhXl?EO;6NuqxXpGMAOA%%aHi`RkAKyQ2?306Yt@Vzd@bfU* zz0rTU;rUKEGn>IVT&uPF0tWV*#)tR57~))T2$9P%d>iw`5(W|m5(W|m5(W|m5(W|m z5(W|m5(c^%SebkKV~@eF`ClBKe%aZfjv6C?#YgHD>X|G?`ukAZa83=Gf{sbIRahX$ zMiHkOFPFrqr;T)Ka42Zd3S&V-U-#+qx_0W$YRz}_x?|c-RnC-6w<71+v|pO1!~AG+ zu%DtVzXgwE-zZ|tg7gYv0~on`I3}q8TXL5Rk;Y??_2c*)aIxQz-Q9NuuCqx7AKssH z4WEc%#;6G+-A}xLPaN9}hDLclGTRbw3^#}|iR!-wHkyC$CgY-3Jg4fZqFZt|9c4RP z$}EzmWj*&QUUnL`wy6rr hoXTCd>>F1z8=?cUb&qFgtxyqb&#zh9!k-m*oj)E#obdnv literal 0 HcmV?d00001 diff --git a/test/Object/Inputs/macho-invalid-symbol-name-past-eof b/test/Object/Inputs/macho-invalid-symbol-name-past-eof new file mode 100644 index 0000000000000000000000000000000000000000..874788407879c348fce8012f2fa303a57132621a GIT binary patch literal 4536 zcmeHLO;1xn6rBeOL>j4vg+>xl(V&J7YSogsP-7!Rg9s%tCOUbKH-%^Vfqk!~b)nt3 zaEH+?Kfyg4lyx+&gooo73<6zYd0lFb0Ka z4+tT~;5mS|ViGeUPQvHmN-f>FpMRQPe#B_E8QriiVx1fkl`7<)6uMLV{ps$Q2r+XKRH|Otaw@iRD#a=mdh2}*>yZN*F?srz zDWx}5v1XQakkMQ3M_BJfSb#XXTfdqe{vR$ZKFHr&h`0kkUA%>S?fO9>$Xht|%bvyi z&h~528$%uD@s2!W6L=Kk^f4i}F><~Hr;UWp+#~RKKfwR8qsW?sr{J>g)?~@Cq}?jn zz_e3vo@0Hkj-&f!?W?h6>$Zx$ck`(lW5{vm|89K*LUPb^^|VIW~3VIW~3VIW~3 zVIW~3VIX0kmx0y!cRzO-{FeXC;n~;iZR)5A0$6;cUZI}JVx)fvwGHRgkSXYxbVr5x za%>!Nn(=B`7|pbiP7ROv4T3Nh6!i6gDsL#=)N6H5s|{`1x+cz)O{XHxv+1B{pAPe* z$^Kr7viuf2l6~WdF$>bmj}2ku?$MZ}0u1CX77ikf#~|y+@j2k)pdog4-WRyeCK-Hq zf6f(rDux-OCX94H@ghEPY%>@d<@uNqh&P5?KJL_i1C03J9g{+?y1M4dqEm7xEl!v$L@EO<9oU hOzyg6-?*Bo3gwfn`aDChLPe}xuWl&|e^%gi{s7z0oh|?X literal 0 HcmV?d00001 diff --git a/test/Object/Inputs/macho-invalid-too-small-load-command b/test/Object/Inputs/macho-invalid-too-small-load-command new file mode 100644 index 0000000000000000000000000000000000000000..36021692ee5543fc1155eee07d496515d11b9fa7 GIT binary patch literal 36 XcmX^2>+L@VC}0HAAnbv}X9uzYgi-_s literal 0 HcmV?d00001 diff --git a/test/Object/Inputs/macho-invalid-too-small-segment-load-command b/test/Object/Inputs/macho-invalid-too-small-segment-load-command new file mode 100644 index 0000000000000000000000000000000000000000..8cbfbf965785c358a42a70dfd74763a566560cdc GIT binary patch literal 104 ncmX^2>+L@VC}0HAAnbv}HwUug8{ literal 0 HcmV?d00001 diff --git a/test/Object/Inputs/macho-zero-ncmds b/test/Object/Inputs/macho-invalid-zero-ncmds similarity index 100% rename from test/Object/Inputs/macho-zero-ncmds rename to test/Object/Inputs/macho-invalid-zero-ncmds diff --git a/test/Object/Inputs/macho64-invalid-getsection-index b/test/Object/Inputs/macho64-invalid-getsection-index new file mode 100644 index 0000000000000000000000000000000000000000..a2a7bc10c4fe8a44820ff155aadb75cff4b1a3b3 GIT binary patch literal 4536 zcmeHLJ#Q015Zy~4iHJoEN&zAg0Rjr3cnuhEBnm)SBm#wyI1)mF)m?7w9I~C@J0~^; zxS^m6f`%eLfj$kQprGU*L^PEAfe0bqyAOP}jKmMPk>+;a?Ci|$TQ|?&_J95!7Qz@5 zqCFsl7=z~lUW-Z0gg6eLgDbUo>u%w3Vd(**-DY&dzUTv@c_b=TEIcZ9r}+ER-7yhj zoJ|~r<4C?K<>{su0t~(N+PDDg9Su{64|LKA+Ht5saWm_dcvg4rs*W z>0hRlUQ?yIS=B*CZ@uqfy<=ek;^=PuYIgX)KfiFVaA!W^4*YcS7V@?02ZbPS;nXjC z8t!Or>dq?6KC0UP_$2m z`O##5FGX2?10Kn~am1Jf>E*|UFmm^3Oi}>`a+eE{#$%B6bGpLhYEIJOxKjq-fV2*ex1EgyI4zXC@5?~X|!S6p3pWyz^H8(P|W zQ<|m9jHg}CmBP%d3b|?4Wof+v@?6-+&p!JM!F literal 0 HcmV?d00001 diff --git a/test/Object/Inputs/macho64-invalid-incomplete-load-command b/test/Object/Inputs/macho64-invalid-incomplete-load-command new file mode 100644 index 0000000000000000000000000000000000000000..a569c9e14b3ac429870992a1d63e00f71a17de6c GIT binary patch literal 36 VcmX^A>+L@VC}0HAFbop|(Exwq1GoSH literal 0 HcmV?d00001 diff --git a/test/Object/Inputs/macho64-invalid-no-size-for-sections b/test/Object/Inputs/macho64-invalid-no-size-for-sections new file mode 100644 index 0000000000000000000000000000000000000000..5aae5ffed3aecb116bea13bb249f1ab3179553e7 GIT binary patch literal 104 tcmX^A>+L@VC}0HAAnXAX0Me3Betf)>qf5MBu&Z-OFp@MuCdfPx004(p2o(ST literal 0 HcmV?d00001 diff --git a/test/Object/Inputs/macho64-invalid-too-small-load-command b/test/Object/Inputs/macho64-invalid-too-small-load-command new file mode 100644 index 0000000000000000000000000000000000000000..0028451d1905a8893aaeda5e5662455ac180dced GIT binary patch literal 40 bcmX^A>+L@VC}0HAAnXAX0Me2`%nrl=l`;e$ literal 0 HcmV?d00001 diff --git a/test/Object/Inputs/macho64-invalid-too-small-segment-load-command b/test/Object/Inputs/macho64-invalid-too-small-segment-load-command new file mode 100644 index 0000000000000000000000000000000000000000..ce6a20134a99c27934e832962d4a6a3001dad34d GIT binary patch literal 104 rcmX^A>+L@VC}0HAAnXAX0Me2`><+~7@lK8|@jm{JF2PYq(nK=>hDHbw literal 0 HcmV?d00001 diff --git a/test/Object/macho-invalid.test b/test/Object/macho-invalid.test new file mode 100644 index 00000000000..138d8eb1f3d --- /dev/null +++ b/test/Object/macho-invalid.test @@ -0,0 +1,51 @@ +// No crash, might not be totally invalid +RUN: llvm-objdump -private-headers %p/Inputs/macho-invalid-zero-ncmds + +RUN: not llvm-objdump -private-headers %p/Inputs/macho64-invalid-incomplete-load-command 2>&1 \ +RUN: | FileCheck -check-prefix INCOMPLETE-LOADC %s + +RUN: not llvm-objdump -private-headers %p/Inputs/macho-invalid-too-small-load-command 2>&1 \ +RUN: | FileCheck -check-prefix SMALL-LOADC-SIZE %s +RUN: not llvm-objdump -private-headers %p/Inputs/macho64-invalid-too-small-load-command 2>&1 \ +RUN: | FileCheck -check-prefix SMALL-LOADC-SIZE %s + +RUN: not llvm-objdump -private-headers %p/Inputs/macho-invalid-too-small-segment-load-command 2>&1 \ +RUN: | FileCheck -check-prefix SMALL-SEGLOADC-SIZE %s +RUN: not llvm-objdump -private-headers %p/Inputs/macho64-invalid-too-small-segment-load-command 2>&1 \ +RUN: | FileCheck -check-prefix SMALL-SEGLOADC-SIZE %s + +RUN: not llvm-objdump -private-headers %p/Inputs/macho-invalid-no-size-for-sections 2>&1 \ +RUN: | FileCheck -check-prefix TOO-MANY-SECTS %s +RUN: not llvm-objdump -private-headers %p/Inputs/macho64-invalid-no-size-for-sections 2>&1 \ +RUN: | FileCheck -check-prefix TOO-MANY-SECTS %s + +RUN: not llvm-objdump -t %p/Inputs/macho-invalid-bad-symbol-index 2>&1 \ +RUN: | FileCheck -check-prefix BAD-SYMBOL %s + +RUN: not llvm-objdump -t %p/Inputs/macho-invalid-symbol-name-past-eof 2>&1 \ +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: | FileCheck -check-prefix INVALID-SECTION-IDX-SECT-NAME %s + +RUN: not llvm-objdump -t %p/Inputs/macho-invalid-getsection-index 2>&1 \ +RUN: | FileCheck -check-prefix INVALID-SECTION-IDX-GETSECT %s + +RUN: not llvm-objdump -t %p/Inputs/macho64-invalid-getsection-index 2>&1 \ +RUN: | FileCheck -check-prefix INVALID-SECTION-IDX-GETSECT64 %s + + +SMALL-LOADC-SIZE: Load command with size < 8 bytes +SMALL-SEGLOADC-SIZE: Segment load command size is too small +INCOMPLETE-LOADC: Malformed MachO file +TOO-MANY-SECTS: Number of sections too large for size of load command +BAD-SYMBOL: Requested symbol index is out of range +NAME-PAST-EOF: Symbol name entry points past end of file + +INVALID-SECTION-IDX-SEG-NAME: getSectionRawFinalSegmentName: Invalid section index +INVALID-SECTION-IDX-SECT-NAME: getSectionRawName: Invalid section index +INVALID-SECTION-IDX-GETSECT: getSection: Invalid section index +INVALID-SECTION-IDX-GETSECT64: getSection64: Invalid section index diff --git a/test/Object/objdump-macho-quirks.test b/test/Object/objdump-macho-quirks.test deleted file mode 100644 index eeee1537def..00000000000 --- a/test/Object/objdump-macho-quirks.test +++ /dev/null @@ -1,9 +0,0 @@ -RUN: llvm-objdump -private-headers %p/Inputs/macho-zero-ncmds \ -RUN: | FileCheck %s -check-prefix A - -// Check that we don't get an infinite loop if ncmds = 0 -A: file format Mach-O 64-bit unknown -A: Mach header -A: magic cputype cpusubtype caps filetype ncmds sizeofcmds flags -A: MH_MAGIC_64 0x00 OBJECT 0 0 0x00000000 -