Commit Graph

876 Commits

Author SHA1 Message Date
Lang Hames
36105c0dde [Object] Change Archive::findSym to return an Expected<Optional<Child>>.
As suggested by Rafael in review of D22079 - this was accidentally left out of
the final commit (r275316).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275469 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-14 20:44:27 +00:00
Lang Hames
aacf2fbfe4 [Object] Re-apply r275316 now that I have the corresponding LLD patch ready.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275361 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-14 02:24:01 +00:00
Lang Hames
5daf897d80 [Object] Revert r275316, Archive::child_iterator changes, while I update lld.
Should fix the bots broken by r275316.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275353 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-14 00:37:04 +00:00
Lang Hames
9b42acafff [Object] Change Archive::child_iterator for better interop with Error/Expected.
See http://reviews.llvm.org/D22079

Changes the Archive::child_begin and Archive::children to require a reference
to an Error. If iterator increment fails (because the archive header is
damaged) the iterator will be set to 'end()', and the error stored in the
given Error&. The Error value should be checked by the user immediately after
the loop. E.g.:

Error Err;
for (auto &C : A->children(Err)) {
  // Do something with archive child C.
}
// Check the error immediately after the loop.
if (Err)
  return Err;

Failure to check the Error will result in an abort() when the Error goes out of
scope (as guaranteed by the Error class).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275316 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-13 21:13:05 +00:00
Kevin Enderby
ac3d934510 Add checks to the MachOObjectFile() constructor to make sure load commands sizes
are the correct multiple.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274798 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-07 22:11:42 +00:00
Saleem Abdulrasool
e88f1b3430 Object: support empty UID/GID fields
Normal archives do not have empty UID/GID fields.  However, the Microsoft
Import library format is a customized archive (it just uses an alternate symbol
index format).  When the import library is constructed by lib.exe, the UID and
GID fields are left empty.  Do not abort on such an input.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274528 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-05 00:23:05 +00:00
Benjamin Kramer
fc44a8b1e4 function_refify. NFC.
While there use emplace_back to create an expensive pair.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274344 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-01 11:05:15 +00:00
Peter Collingbourne
d9613da65c Object: Replace NewArchiveIterator with a simpler NewArchiveMember class. NFCI.
The NewArchiveIterator class has a problem: it requires too much context. Any
memory buffers added to the archive must be stored within an Archive::Member,
which must have an associated Archive. This makes it harder than necessary
to create new archive members (or new archives entirely) from scratch using
memory buffers.

This patch replaces NewArchiveIterator with a NewArchiveMember class that
stores just the memory buffer and the information that goes into the archive
member header.

Differential Revision: http://reviews.llvm.org/D21721

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274183 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-29 22:27:42 +00:00
Kevin Enderby
0b21d88fd3 Change Archive::create() from ErrorOr<...> to Expected<...> and update
its clients.

This commit will break the next lld builds.  I’ll be committing the matching
change for lld next.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274160 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-29 20:35:44 +00:00
Vedant Kumar
3cb7bf5952 [Object] Fix a -Wpessimizing-move error; clang-format; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274085 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-29 00:37:13 +00:00
Kevin Enderby
c827f2cd76 Finish cleaning up most of the error handling in libObject’s MachOUniversalBinary
and its clients to use the new llvm::Error model for error handling.

Changed getAsArchive() from ErrorOr<...> to Expected<...> so now all
interfaces there use the new llvm::Error model for return values.

In the two places it had if (!Parent) this is actually a program error so changed
from returning errorCodeToError(object_error::parse_failed) to calling
report_fatal_error() with a message.

In getObjectForArch() added error messages to its two llvm::Error return values
instead of returning errorCodeToError(object_error::arch_not_found) with no
error message.

For the llvm-obdump, llvm-nm and llvm-size clients since the only binary files in
Mach-O Universal Binaries that are supported are Mach-O files or archives with
Mach-O objects, updated their logic to generate an error when a slice contains
something like an ELF binary instead of ignoring it. And added a test case for
that.

The last error stuff to be cleaned up for libObject’s MachOUniversalBinary is
the use of errorOrToExpected(Archive::create(ObjBuffer)) which needs
Archive::create() to be changed from ErrorOr<...> to Expected<...> first,
which I’ll work on next. 


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274079 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-28 23:16:13 +00:00
Kevin Enderby
054620884a Change all but the last ErrorOr<...> use for MachOUniversalBinary to Expected<...> to
allow a good error message to be produced.

I added the one test case that the object file tools could produce an error
message.  The other two errors can’t be triggered if the input file is passed
through sys::fs::identify_magic().  But the malformedError("bad magic number")
does get triggered by the logic in llvm-dsymutil when dealing with a normal
Mach-O file.  The other "File too small ..." error would take a logic error
currently to produce and is not tested for.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273946 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-27 21:39:39 +00:00
David Majnemer
6ea11a40aa [Object, COFF] An import data directory might not consist soley of imports
The last import is the penultimate entry, the last entry is nulled out.
Data beyond the null entry should not be considered to hold import
entries.

This fixes PR28302.

N.B.  I am working on a reduced testcase, the one in PR28302 is too
large.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273790 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-26 04:36:32 +00:00
Kevin Enderby
317de7ce5b Thread Expected<...> up from libObject’s getSymbolAddress() for symbols to allow
a good error message to be produced.

This is nearly the last libObject interface that used ErrorOr and the last one
that appears in llvm/include/llvm/Object/MachO.h .  For Mach-O objects this is
just a clean up because it’s version of getSymbolAddress() can’t return an
error.

I will leave it to the experts on COFF and ELF to actually add meaning full
error messages in their tests if they wish.  And also leave it to these experts
to change the last two ErrorOr interfaces in llvm/include/llvm/Object/ObjectFile.h
for createCOFFObjectFile() and createELFObjectFile() if they wish.

Since there are no test cases for COFF and ELF error cases with respect to
getSymbolAddress() in the test suite this is no functional change (NFC).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273701 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-24 18:24:42 +00:00
Rafael Espindola
c0b76e3114 Make sure Format is always initialized.
Should fix the msan bots.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273679 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-24 13:47:29 +00:00
Davide Italiano
788062df94 [IRObjectFile] Try to be defensive, add a break.
Suggested by Sean Silva.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273519 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-23 00:07:31 +00:00
Chris Bieneman
1a713c6e05 [MachO] Finish moving fat header swap functions to MachO.h
This is a follow-up to r273479. At the time I wrote r273479 I didn't connect the dots that the functions I was adding had to exist somewhere. Turns out, they do. This finishes moving the functions to MachO.h.

Existing MachO fat header tests like test/tools/llvm-readobj/Inputs/macho-universal-archive.x86_64.i386 execute this code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273502 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-22 22:19:08 +00:00
Davide Italiano
90107652c0 [IRObjectFile] Propagate .weak attribute correctly for ASM symbols.
PR: 28256
Differential Revision:  http://reviews.llvm.org/D21616


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273474 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-22 20:48:15 +00:00
Kevin Enderby
f5d5db71df Add support for Darwin’s 64-bit universal files with 64-bit offsets and sizes for the objects.
Darwin added support in its Xcode 8.0 tools (released in the beta) for universal
files where offsets and sizes for the objects are 64-bits to allow support for
objects contained in universal files to be larger then 4gb.  The change is very
straight forward.  There is a new magic number that differs by one bit, much
like the 64-bit Mach-O files.  Then there is a new structure that follow the
fat_header that has the same layout but with the offset and size fields using
64-bit values instead of 32-bit values.

rdar://26899493


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273207 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-20 22:16:18 +00:00
Tom Stellard
7dc79e5898 Support/ELF: Add AMDGPU relocation definitions to match documentation
Reviewers: arsenm, kzhuravl, rafael

Subscribers: llvm-commits, kzhuravl

Differential Revision: http://reviews.llvm.org/D21443

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273066 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-17 22:38:08 +00:00
Kevin Enderby
68806ff6b6 Add support for Darwin’s static library table of contents with 64-bit offsets to the archive members.
Darwin added support in its Xcode 8.0 tools (released in the beta) for static
library table of contents with 64-bit offsets to the archive members.  The
change is very straight forward.  The table of contents member is named
___.SYMDEF_64 or "___.SYMDEF_64 SORTED" and same layout is used but with
fields using 64 bit values instead of 32 bit values.

rdar://26869808


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273058 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-17 22:16:06 +00:00
Benjamin Kramer
e5eb673413 Apply another batch of fixes from clang-tidy's performance-unnecessary-value-param.
Contains some manual fixes. No functionality change intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273047 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-17 20:41:14 +00:00
Davide Italiano
f57147f09b [IRObjectFile] Handle .weak in RecordStreamer.
Differential Revision:  http://reviews.llvm.org/D21476

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273027 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-17 18:20:14 +00:00
Daniel Sanders
0b8fc77698 [llvm-objdump] Support detection of feature bits from the object and implement this for Mips.
Summary:
The Mips implementation only covers the feature bits described by the ELF
e_flags so far. Mips stores additional feature bits such as MSA in the
.MIPS.abiflags section.

Also fixed a small bug this revealed where microMIPS wouldn't add the
EF_MIPS_MICROMIPS flag when using -filetype=obj.

Reviewers: echristo, rafael

Subscribers: rafael, mehdi_amini, dsanders, sdardis, llvm-commits

Differential Revision: http://reviews.llvm.org/D21125

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272880 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-16 09:17:03 +00:00
Reid Kleckner
1ac3f3eb9d [Symbolize] Check if the PE file has a PDB and emit an error if we can't load it
Summary:
Previously we would try to load PDBs for every PE executable we tried to
symbolize. If that failed, we would fall back to DWARF. If there wasn't
any DWARF, we'd print mostly useless symbol information using the export
table.

With this change, we only try to load PDBs for executables that claim to
have them. If that fails, we can now print an error rather than falling
back silently. This should make it a lot easier to diagnose and fix
common symbolization issues, such as not having DIA or not having a PDB.

Reviewers: zturner, eugenis

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D20982

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271725 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-03 20:25:09 +00:00
Reid Kleckner
fb1a91169a [COFF] Expose the PE debug data directory and dump it
This directory is used to find if there is a PDB associated with an
executable. I plan to use this functionality to teach llvm-symbolizer
whether it should use DIA or DWARF to symbolize a given DLL.

Reviewers: majnemer

Differential Revision: http://reviews.llvm.org/D20885

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271539 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-02 17:10:43 +00:00
Kevin Enderby
e9ddf3a4a7 Change llvm-objdump, llvm-nm and llvm-size when reporting an object file error
when the object is from a slice of a Mach-O Universal Binary use something like
"foo.o (for architecture i386)" as part of the error message when expected.

Also fixed places in these tools that were ignoring object file errors from
MachOUniversalBinary::getAsObjectFile() when the code moved on to see if
the slice was an archive.

To do this MachOUniversalBinary::getAsObjectFile() and
MachOUniversalBinary::getObjectForArch() were changed from returning
ErrorOr<...> to Expected<...> then that was threaded up to its users.

Converting these interfaces to Expected<> from ErrorOr<> does involve
touching a number of places. To contain the changes for now the use of
errorToErrorCode() is still used in two places yet to be fully converted.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271332 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-31 20:35:34 +00:00
David Majnemer
ddd4585661 [Object] Return an error code instead of asserting
This makes it easier to report errors up the stack.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271140 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-28 19:45:51 +00:00
Chris Bieneman
26cbd17577 [CMake] Restrict libxar linkage to just llvm-objdump
At some point we're going to need libObject to have this dependency, but as it is now this is causing too many headaches. This commit will reduce the linkage to just llvm-objdump where it is strictly needed, and we'll cross the libObject bridge later when we need it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270866 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-26 16:32:40 +00:00
Peter Collingbourne
84e27c2068 Add FIXMEs to all derived classes of std::error_category.
This helps make clear that we're moving away from std::error_code.

Differential Revision: http://reviews.llvm.org/D20592

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270604 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-24 20:13:46 +00:00
George Rimar
5ad80b222a Recommit r270547 ([llvm-dwarfdump] - Teach dwarfdump to decompress debug sections in zlib style.)
Fix was:
1) Had to regenerate dwarfdump-test-zlib.elf-x86-64, dwarfdump-test-zlib-gnu.elf-x86-64
(because llvm-symbolizer-zlib.test uses that inputs for its purposes and failed).
2) Updated llvm-symbolizer-zlib.test (updated used call function address to match new files + 
added one more check for newly created dwarfdump-test-zlib-gnu.elf-x86-64 binary input).
3) Updated comment in dwarfdump-test-zlib.cc.

Original commit message:
[llvm-dwarfdump] - Teach dwarfdump to decompress debug sections in zlib style.

Before this llvm-dwarfdump only recognized zlib-gnu compression style of headers,
this patch adds support for zlib style. 
It looks reasonable to support both styles for dumping,
even if we are not going to suport generating of deprecated gnu one.

Differential revision: http://reviews.llvm.org/D20470

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270557 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-24 12:48:46 +00:00
George Rimar
fd3faf4011 Revert r270543 ("Recommit r270540")
Failed build bot in another test.
I am sorry for noise.
http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_check/23679/testReport/junit/LLVM/DebugInfo/llvm_symbolizer_zlib_test/

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270547 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-24 11:03:10 +00:00
George Rimar
6795981199 Recommit r270540
fix: forgot to commit the updated dwarfdump-test-zlib.elf-x86-64

Original commit message:
[llvm-dwarfdump] - Teach dwarfdump to decompress debug sections in zlib style.

Before this llvm-dwarfdump only recognized zlib-gnu compression style of headers,
this patch adds support for zlib style. 
It looks reasonable to support both styles for dumping,
even if we are not going to suport generating of deprecated gnu one.

Differential revision: http://reviews.llvm.org/D20470

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270543 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-24 10:46:43 +00:00
George Rimar
c19728fa10 Revert r270540 "[llvm-dwarfdump] - Teach dwarfdump to decompress debug sections in zlib style."
it broked bot:
http://lab.llvm.org:8011/builders/clang-s390x-linux/builds/5036


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270541 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-24 09:44:44 +00:00
George Rimar
dba28a8d42 [llvm-dwarfdump] - Teach dwarfdump to decompress debug sections in zlib style.
Before this llvm-dwarfdump only recognized zlib-gnu compression style of headers,
this patch adds support for zlib style. 
It looks reasonable to support both styles for dumping,
even if we are not going to suport generating of deprecated gnu one.

Differential revision: http://reviews.llvm.org/D20470

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270540 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-24 09:28:36 +00:00
Kevin Enderby
866cdd590d Add the printing the Mach-O (__LLVM,__bundle) xar archive file section "verbosely"
to llvm-objdump. This section is created with -fembed-bitcode option.

This requires the use of libxar and the Cmake and lit support were crafted by
Chris Bieneman!

rdar://26202242


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270491 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-23 21:34:12 +00:00
Rafael Espindola
2dc637165b Don't pass a Reloc::Model to MC.
MC only needs to know if the output is PIC or not. It never has to
decide about creating GOTs and PLTs for example. The only thing that
MC itself uses this information for is expanding "macros" in sparc and
mips. The rest I am pretty sure could be moved to CodeGen.

This is a cleanup and isolates the code from future changes to
Reloc::Model.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269909 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-18 11:58:50 +00:00
Lang Hames
47ad42e0ee [Object] Move isNotObjectErrorInvalidFileType out of header.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269848 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-17 21:38:53 +00:00
Kevin Enderby
77be094e2f Change llvm-objdump, llvm-nm and llvm-size when reporting an object file error
when the object is in an archive to use something like libx.a(foo.o) as part of
the error message.

Also changed llvm-objdump and llvm-size to be like llvm-nm and ignore non-object
files in archives and not produce any error message.

To do this Archive::Child::getAsBinary() was changed from ErrorOr<...> to
Expected<...> then that was threaded up to its users.

Converting this interface to Expected<> from ErrorOr<> does involve
touching a number of places. To contain the changes for now the use of
errorToErrorCode() is still used in one place yet to be fully converted.

Again there some were bugs in the existing code that did not deal with the
old ErrorOr<> return values.  So now with Expected<> since they must be
checked and the error handled, I added a TODO and a comments for those.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269784 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-17 17:10:12 +00:00
Rafael Espindola
e973d3f2ce Return a StringRef from getSection.
This is similar to how getName is handled.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269218 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-11 18:21:59 +00:00
Rafael Espindola
0c06716f89 Fix bug where temporary file would be left behind every time an archive was updated.
When updating an existing archive, llvm-ar opens the old archive into a
`MemoryBuffer`, does its thing, and writes the results to a temporary
file. That file is then renamed to the original archive filename, thus
replacing it with the updated contents. However, on Windows at least,
what would happen is that the `MemoryBuffer` for the old archive would
actually be an mmap'ed view of the file, so when it came time to do the
rename via Win32's `ReplaceFile`, it would succeed but would be unable
to fully replace the file since there would still be a handle open on
it; instead, the old version got renamed to a random temporary name and
left behind.

Patch by Cameron!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268916 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-09 13:31:11 +00:00
Kevin Enderby
eaa1f084ce Change GenericBinaryError to no longer include a FileName, which is then not
part of the error message.

As the caller is the one that needs to add the name of where the "object file"
comes from to the error message as the object file could be in an archive, or
coming from a slice of a Mach-O universal file or a buffer created by a JIT.

In the cases of a Mach-O universal file the architecture name may or may not
also need to be printed which is up to the tool code.  For example if the tool
code is only selecting the host architecture slice then that architecture name
is never printed.

This patch is the change to the libObject code and there will be follow on
commits for changes to the code for each tool.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268789 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-06 20:16:28 +00:00
Justin Bogner
2dd0b894b1 Object: Fix two -Wpessimizing-move warnings after r268694
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268697 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-05 23:59:57 +00:00
Kevin Enderby
2512bda3fc Fix window bots failures due to r268694 - Cleanup and refactor of malformedError() in lib/Object/MachOObjectFile.cpp .
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268696 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-05 23:55:27 +00:00
Kevin Enderby
ba3a53c045 Cleanup and refactor of malformedError() in lib/Object/MachOObjectFile.cpp .
No functional change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268694 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-05 23:41:05 +00:00
Kevin Enderby
00e8fc511c Clean up the specific error message for a malformed Mach-O files with bad segment
load commands.

The existing test case in test/Object/macho-invalid.test for
macho-invalid-too-small-segment-load-command has a cmdsize of 55, while
being too small also it is not a multiple of 4.  So when that check is added
this test case will produce a different error. So I constructed a new test case
that will trigger the intended error.

I also changed the error message to be consistent with the other malformed Mach-O
file error messages which prints the load command index.  I also removed both
object_error::macho_load_segment_too_small and
object_error::macho_load_segment_too_many_sections from Object/Error.h
as they are not needed and can just use object_error::parse_failed and let the
error message string distinguish the specific error.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268652 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-05 17:43:35 +00:00
Kevin Enderby
1820caaf98 Produce another specific error message for a malformed Mach-O file when a load
command has a size less than 8 bytes.

I think the existing test case in test/Object/macho-invalid.test for
macho64-invalid-too-small-load-command was trying to test for this but that
test case triggered a different error given how it was constructed.  So I
constructed a new test case that would trigger this specific error.

I also changed the error message to be consistent with the other malformed Mach-O
file error messages.  I also removed object_error::macho_small_load_command from
Object/Error.h as it is not needed and can just use object_error::parse_failed
and let the error message string distinguish the error.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268463 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-03 23:13:50 +00:00
Kevin Enderby
57dae44420 Produce another specific error message for a malformed Mach-O file when a load
command other than the first one is past the end of the load commands.

This is like the test case in test/Object/macho-invalid.test for
macho64-invalid-incomplete-load-command but it is the second load command
that is past the end of all the load commands instead of the first.

The code in the constructor for MachOObjectFile that loops over the load
commands used getNextLoadCommandInfo() which was not producing
a good error message.  So that was fixed and a test case was added.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268403 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-03 17:16:08 +00:00
Davide Italiano
9de339f6ec [lib/Object] Make this assertion more useful.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268367 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-03 07:30:56 +00:00
Rafael Espindola
78deea801b Don't try to create thin bsd archives.
Not such variant has been specified yet.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268305 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-02 21:06:57 +00:00