[PATCH] D69856: [Object][MachO] Rewrite macho-invalid-fat-arch-size into YAML
Steven Wu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 6 11:32:37 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6da58e7e0fac: [Object][MachO] Rewrite macho-invalid-fat-arch-size into YAML (authored by steven_wu).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D69856/new/
https://reviews.llvm.org/D69856
Files:
llvm/lib/ObjectYAML/MachOEmitter.cpp
llvm/test/Object/Inputs/macho-invalid-fat-arch-size
llvm/test/Object/Inputs/macho-invalid-fat-arch-size.yaml
llvm/test/Object/macho-invalid.test
Index: llvm/test/Object/macho-invalid.test
===================================================================
--- llvm/test/Object/macho-invalid.test
+++ llvm/test/Object/macho-invalid.test
@@ -491,8 +491,8 @@
RUN: not llvm-objdump --macho --universal-headers %p/Inputs/macho-invalid-fat-header 2>&1 | FileCheck -check-prefix INVALID-FAT-HEADER %s
INVALID-FAT-HEADER: macho-invalid-fat-header': truncated or malformed fat file (contains zero architecture types)
-RUN: not llvm-objdump --macho --universal-headers %p/Inputs/macho-invalid-fat-arch-size 2>&1 | FileCheck -check-prefix INVALID-FAT-ARCH-SIZE %s
-INVALID-FAT-ARCH-SIZE: macho-invalid-fat-arch-size': truncated or malformed fat file (offset plus size of cputype (7) cpusubtype (3) extends past the end of the file)
+RUN: yaml2obj %p/Inputs/macho-invalid-fat-arch-size.yaml -o - | not llvm-objdump --macho --universal-headers - 2>&1 | FileCheck -check-prefix INVALID-FAT-ARCH-SIZE %s
+INVALID-FAT-ARCH-SIZE: '-': truncated or malformed fat file (offset plus size of cputype (7) cpusubtype (3) extends past the end of the file)
RUN: not llvm-objdump --macho --universal-headers %p/Inputs/macho-invalid-fat-arch-bigalign 2>&1 | FileCheck -check-prefix INVALID-FAT-ARCH-BIGALIGN %s
INVALID-FAT-ARCH-BIGALIGN: macho-invalid-fat-arch-bigalign': truncated or malformed fat file (align (2^212) too large for cputype (7) cpusubtype (3) (maximum 2^15))
Index: llvm/test/Object/Inputs/macho-invalid-fat-arch-size.yaml
===================================================================
--- /dev/null
+++ llvm/test/Object/Inputs/macho-invalid-fat-arch-size.yaml
@@ -0,0 +1,12 @@
+--- !fat-mach-o
+FatHeader:
+ magic: 0xCAFEBABE
+ nfat_arch: 1
+FatArchs:
+ - cputype: 0x00000007
+ cpusubtype: 0x00000003
+ offset: 0x000000000000020
+ size: 32
+ align: 2
+Slices:
+...
Index: llvm/lib/ObjectYAML/MachOEmitter.cpp
===================================================================
--- llvm/lib/ObjectYAML/MachOEmitter.cpp
+++ llvm/lib/ObjectYAML/MachOEmitter.cpp
@@ -494,7 +494,8 @@
writeFatArchs(OS);
auto &FatFile = *ObjectFile.FatMachO;
- assert(FatFile.FatArchs.size() == FatFile.Slices.size());
+ assert(FatFile.FatArchs.size() > FatFile.Slices.size() &&
+ "Cannot write Slices if not decribed in FatArches");
for (size_t i = 0; i < FatFile.Slices.size(); i++) {
ZeroToOffset(OS, FatFile.FatArchs[i].offset);
MachOWriter Writer(FatFile.Slices[i]);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69856.228110.patch
Type: text/x-patch
Size: 2528 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191106/4b5e0f99/attachment.bin>
More information about the llvm-commits
mailing list