diff options
author | Kevin Enderby <enderby@apple.com> | 2016-07-25 20:36:36 +0000 |
---|---|---|
committer | Kevin Enderby <enderby@apple.com> | 2016-07-25 20:36:36 +0000 |
commit | 95b0842e64ffe02f09c8f54d39d4eb1b8dd0ebe0 (patch) | |
tree | 64032acf6f4259ad4bbcd4fe34243b680f0f1a89 /llvm/test | |
parent | 10697a7c34e27a82efdffb3b29254ffc9309704f (diff) | |
download | bcm5719-llvm-95b0842e64ffe02f09c8f54d39d4eb1b8dd0ebe0.tar.gz bcm5719-llvm-95b0842e64ffe02f09c8f54d39d4eb1b8dd0ebe0.zip |
Next step along the way to getting good error messages for bad archives.
I consulted with Lang Hames on this work, and the goal was to add a bit
of "where" in the archive the error occurred along with what the error was.
So this step changes ArchiveMemberHeader into a class with a pointer
to the archive header and the parent archive. Which allows the methods
in the ArchiveMemberHeader to determine which member the header is
for to include that information in the error message.
For this first step the "where" is just the offset to the member in the
archive. The next step will be a new method on ArchiveMemberHeader
to get the full name, if possible, to be use in the error message. Which
will now be possible as ArchiveMemberHeader contains a pointer to
the Archive with its string table and its size, etc. so the full name can
be determined from the header if it is valid.
Also this change adds the missing checks the archive header is actually
contained in the buffer and is not truncated, as well as if the terminating
characters are correct in the header.
And changes one error message in Archive::Child::getNext() where the
name or offset to member is now added.
llvm-svn: 276686
Diffstat (limited to 'llvm/test')
-rw-r--r-- | llvm/test/tools/llvm-objdump/Inputs/libbogus4.a | 11 | ||||
-rw-r--r-- | llvm/test/tools/llvm-objdump/Inputs/libbogus5.a | 10 | ||||
-rw-r--r-- | llvm/test/tools/llvm-objdump/malformed-archives.test | 18 |
3 files changed, 36 insertions, 3 deletions
diff --git a/llvm/test/tools/llvm-objdump/Inputs/libbogus4.a b/llvm/test/tools/llvm-objdump/Inputs/libbogus4.a new file mode 100644 index 00000000000..44f01e323c6 --- /dev/null +++ b/llvm/test/tools/llvm-objdump/Inputs/libbogus4.a @@ -0,0 +1,11 @@ +!<arch> +hello.c 1444941273 124 0 100644 102 ` +#include <stdio.h> +#include <stdlib.h> +int +main() +{ + printf("Hello World\n"); + return EXIT_SUCCESS; +} +foo.c 1444941645 124 0 100644 diff --git a/llvm/test/tools/llvm-objdump/Inputs/libbogus5.a b/llvm/test/tools/llvm-objdump/Inputs/libbogus5.a new file mode 100644 index 00000000000..d832991f73f --- /dev/null +++ b/llvm/test/tools/llvm-objdump/Inputs/libbogus5.a @@ -0,0 +1,10 @@ +!<arch> +hello.c 1444941273 124 0 100644 102 @ +#include <stdio.h> +#include <stdlib.h> +int +main() +{ + printf("Hello World\n"); + return EXIT_SUCCESS; +} diff --git a/llvm/test/tools/llvm-objdump/malformed-archives.test b/llvm/test/tools/llvm-objdump/malformed-archives.test index b44b1609d60..c52bc8003f8 100644 --- a/llvm/test/tools/llvm-objdump/malformed-archives.test +++ b/llvm/test/tools/llvm-objdump/malformed-archives.test @@ -5,16 +5,28 @@ # RUN: %p/Inputs/libbogus1.a \ # RUN: 2>&1 | FileCheck -check-prefix=bogus1 %s -# bogus1: libbogus1.a': truncated or malformed archive (characters in size field in archive header are not all decimal numbers: '10%') +# bogus1: libbogus1.a': truncated or malformed archive (characters in size field in archive header are not all decimal numbers: '10%' for archive member header at offset 8) # RUN: not llvm-objdump -macho -archive-headers \ # RUN: %p/Inputs/libbogus2.a \ # RUN: 2>&1 | FileCheck -check-prefix=bogus2 %s -# bogus2: libbogus2.a': truncated or malformed archive (characters in size field in archive header are not all decimal numbers: '1%') +# bogus2: libbogus2.a': truncated or malformed archive (characters in size field in archive header are not all decimal numbers: '1%' for archive member header at offset 170) # RUN: not llvm-objdump -macho -archive-headers \ # RUN: %p/Inputs/libbogus3.a \ # RUN: 2>&1 | FileCheck -check-prefix=bogus3 %s -# bogus3: libbogus3.a': truncated or malformed archive (offset to next archive member past the end of the archive) +# bogus3: libbogus3.a': truncated or malformed archive (offset to next archive member past the end of the archive after member foo.c) + +# RUN: not llvm-objdump -macho -archive-headers \ +# RUN: %p/Inputs/libbogus4.a \ +# RUN: 2>&1 | FileCheck -check-prefix=bogus4 %s + +# bogus4: libbogus4.a': truncated or malformed archive (remaining size of archive too small for next archive member header at offset 170) + +# RUN: not llvm-objdump -macho -archive-headers \ +# RUN: %p/Inputs/libbogus5.a \ +# RUN: 2>&1 | FileCheck -check-prefix=bogus5 %s + +# bogus5: libbogus5.a': truncated or malformed archive (terminator characters in archive member "@\n" not the correct "`\n" values for the archive member header at offset 8) |