summaryrefslogtreecommitdiffstats
path: root/llvm/test/Object
diff options
context:
space:
mode:
authorKevin Enderby <enderby@apple.com>2016-04-13 21:17:58 +0000
committerKevin Enderby <enderby@apple.com>2016-04-13 21:17:58 +0000
commit870257455762cc35b609e6050abebd905d73dccc (patch)
tree68eb93752d00a63fae343c66483378fbca007e54 /llvm/test/Object
parent8331458deb1706c00ca98815a6edb42ba526ad36 (diff)
downloadbcm5719-llvm-870257455762cc35b609e6050abebd905d73dccc.tar.gz
bcm5719-llvm-870257455762cc35b609e6050abebd905d73dccc.zip
Start to add real error messages for malformed Mach-O files.
And update the existing test cases in test/Object/macho-invalid.test to use llvm-objdump with the -macho option to produce these error messages and stop producing the generic "Invalid data was encountered while parsing the file" message. Working from the beginning of the file, if the mach header is too large for the size of the file and then if the load commands that follow extend past the end of the file these two errors now generate correct error messages. Both of these have existing test cases in test/Object/macho-invalid.test . But the first with macho-invalid-header it will never trigger the error message "mach header extends past the end of the file" using any of the llvm tools as they all use identify_magic() which rejects files with the correct magic number that are too small in size. So I tested this by hacking that code and seeing the error message down in parseHeader() really does happen. So in case there is ever code in llvm that directly calls createMachOObjectFile() this error message will be correctly produced. The second error message of "load commands extends past the end of the file" is triggered by a number of existing tests cases in test/Object/macho-invalid.test . Also other tests trigger different error messages now like "ilocalsym plus nlocalsym in LC_DYSYMTAB load command extends past the end of the symbol table". There are two existing test cases that still get the "Invalid data was encountered ..." error messages that I will tackle next. But they will involve a bit of pluming an Expect<...> up through the call stack and I want to do those as separate changes. FYI, for those test cases that were trying to test specific errors that now get different errors I’ll fix those in follow on changes and create new test cases for those so they test the error they were meant to test. llvm-svn: 266248
Diffstat (limited to 'llvm/test/Object')
-rw-r--r--llvm/test/Object/macho-invalid.test22
1 files changed, 10 insertions, 12 deletions
diff --git a/llvm/test/Object/macho-invalid.test b/llvm/test/Object/macho-invalid.test
index be75ba9077d..f3e8ac4d73a 100644
--- a/llvm/test/Object/macho-invalid.test
+++ b/llvm/test/Object/macho-invalid.test
@@ -9,11 +9,11 @@ RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho64-invalid-incomple
RUN: | FileCheck -check-prefix INCOMPLETE-LOADC %s
INCOMPLETE-LOADC: truncated or malformed object (load command 0 extends past the end all load commands in the file)
-RUN: not llvm-objdump -private-headers %p/Inputs/macho-invalid-too-small-load-command 2>&1 \
+RUN: not llvm-objdump -macho -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: not llvm-objdump -macho -private-headers %p/Inputs/macho64-invalid-too-small-load-command 2>&1 \
RUN: | FileCheck -check-prefix SMALL-LOADC-SIZE %s
-SMALL-LOADC-SIZE: Mach-O load command with size < 8 bytes
+SMALL-LOADC-SIZE: truncated or malformed object (load commands extends past the end of the file)
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
@@ -27,13 +27,12 @@ RUN: not llvm-objdump -private-headers %p/Inputs/macho64-invalid-no-size-for-sec
RUN: | FileCheck -check-prefix TOO-MANY-SECTS %s
TOO-MANY-SECTS: Mach-O segment load command contains too many sections
-RUN: not llvm-objdump -t %p/Inputs/macho-invalid-bad-symbol-index 2>&1 \
+RUN: not llvm-objdump -macho -t %p/Inputs/macho-invalid-bad-symbol-index 2>&1 \
RUN: | FileCheck -check-prefix BAD-SYMBOL %s
-BAD-SYMBOL: Invalid data was encountered while parsing the file.
-RUN: llvm-objdump -t %p/Inputs/macho-valid-0-nsyms 2>&1 \
+BAD-SYMBOL: truncated or malformed object (ilocalsym plus nlocalsym in LC_DYSYMTAB load command extends past the end of the symbol table)
+RUN: llvm-objdump -macho -t %p/Inputs/macho-valid-0-nsyms 2>&1 \
RUN: | FileCheck -check-prefix ZERO-NSYMS %s
ZERO-NSYMS: SYMBOL TABLE
-ZERO-NSYMS-NOT: Requested symbol index is out of range
RUN: not llvm-objdump -t %p/Inputs/macho-invalid-symbol-name-past-eof 2>&1 \
RUN: | FileCheck -check-prefix NAME-PAST-EOF %s
@@ -58,9 +57,8 @@ RUN: not llvm-objdump -t %p/Inputs/macho-invalid-section-index-getSectionRawName
RUN: | FileCheck -check-prefix INVALID-SECTION-IDX-SYMBOL-SEC-objdump %s
INVALID-SECTION-IDX-SYMBOL-SEC-objdump: Invalid data was encountered while parsing the file.
-RUN: not llvm-objdump -private-headers %p/Inputs/macho-invalid-header 2>&1 | FileCheck -check-prefix INVALID-HEADER %s
-INVALID-HEADER: The file was not recognized as a valid object file.
-NOT-INVALID-HEADER: Invalid data was encountered while parsing the file.
+RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho-invalid-header 2>&1 | FileCheck -check-prefix INVALID-HEADER %s
+INVALID-HEADER: The file was not recognized as a valid object file
-RUN: not llvm-objdump -private-headers %p/Inputs/macho64-invalid-incomplete-segment-load-command 2>&1 | FileCheck -check-prefix INCOMPLETE-SEGMENT-LOADC %s
-INCOMPLETE-SEGMENT-LOADC: Invalid data was encountered while parsing the file
+RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho64-invalid-incomplete-segment-load-command 2>&1 | FileCheck -check-prefix INCOMPLETE-SEGMENT-LOADC %s
+INCOMPLETE-SEGMENT-LOADC: truncated or malformed object (load commands extends past the end of the file)
OpenPOWER on IntegriCloud