#
6c1d2b4c |
| 27-Mar-2017 |
Kevin Enderby <enderby@apple.com> |
Add the error handling for Mach-O dyld compact lazy bind, weak bind and rebase entry errors and test cases for each of the error checks.
Also verified with Nick Kledzik that a BIND_OPCODE_SET_ADDEND
Add the error handling for Mach-O dyld compact lazy bind, weak bind and rebase entry errors and test cases for each of the error checks.
Also verified with Nick Kledzik that a BIND_OPCODE_SET_ADDEND_SLEB opcode is legal in a lazy bind table, so code that had that as an error check was removed.
With MachORebaseEntry and MachOBindEntry classes now returning an llvm::Error in all cases for malformed input the variables Malformed and logic to set use them is no longer needed and has been removed from those classes.
Also in a few places, removed the redundant Done assignment to true when also calling moveToEnd() as it does that assignment.
This only leaves the dyld compact export entries left to have error handling yet to be added for the dyld compact info.
llvm-svn: 298883
show more ...
|
#
a8d256cb |
| 20-Mar-2017 |
Kevin Enderby <enderby@apple.com> |
Add the rest of the error checking for Mach-O dyld compact bind entry errors and test cases for each of the error checks.
To do this more plumbing was needed so that the segment indexes and segment
Add the rest of the error checking for Mach-O dyld compact bind entry errors and test cases for each of the error checks.
To do this more plumbing was needed so that the segment indexes and segment offsets can be checked. Basically what was done was the SegInfo from llvm-objdump’s MachODump.cpp was moved into libObject for Mach-O objects as BindRebaseSegInfo and it is only created when an iterator for bind or rebase entries are created.
This commit really only adds the error checking and test cases for the bind table entires and the checking for the lazy bind and weak bind entries are still to be fully done as well as the rebase entires. Though some of the plumbing for those are added with this commit. Those other error checks and test cases will be added in follow on commits.
Note, the two llvm_unreachable() calls should now actually be unreachable with the error checks in place and would take a logic bug in the error checking code to be reached if the segment indexes and segment offsets are used from a checked bind entry. Comments have been added to the methods that require the arguments to have been checked prior to calling.
llvm-svn: 298292
show more ...
|
Revision tags: llvmorg-4.0.0, llvmorg-4.0.0-rc4, llvmorg-4.0.0-rc3 |
|
#
feb63b93 |
| 28-Feb-2017 |
Kevin Enderby <enderby@apple.com> |
Actually add error handling to unpacking the dyld compact bind and other tables. Providing a helpful error message to what the error is and where the error occurred based on which opcode it was asso
Actually add error handling to unpacking the dyld compact bind and other tables. Providing a helpful error message to what the error is and where the error occurred based on which opcode it was associated with.
There have been handful of bug fixes dealing with bad bind info in object files, r294021 and r249845, which only put a band aid on the problem after a bad bind table was created after unpacking from its compact info. In these cases a bind table should have never been created and an error should have simply been generated.
This change puts in place the plumbing to allow checking and returning of an error when the compact info is unpacked. This follows the model of iterators that can fail that Lang Hanes designed when fixing the problem for bad archives r275316 (or r275361).
This change uses one of the existing test cases that now causes an error instead of printing <<bad library ordinal>> after a bad bind table is created. The error uses the offset into the opcode table as shown with the macOS dyldinfo(1) tool to indicate where the error is and which opcode and which parameter is in error.
For example the exiting test case has this lazy binding opcode table:
% dyldinfo -opcodes test/tools/llvm-objdump/Inputs/bad-ordinal.macho-x86_64 … lazy binding opcodes: 0x0000 BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB(0x02, 0x00000010) 0x0002 BIND_OPCODE_SET_DYLIB_ORDINAL_IMM(2)
In the test case the binary only has one library so setting the library ordinal to the value of 2 in the BIND_OPCODE_SET_DYLIB_ORDINAL_IMM opcode at 0x0002 above is an error. This now produces this error message:
% llvm-objdump -lazy-bind bad-ordinal.macho-x86_64 … llvm-objdump: 'bad-ordinal.macho-x86_64': truncated or malformed object (for BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB bad library ordinal: 2 (max 1) for opcode at: 0x2)
This change provides the plumbing for the error handling and one example of an error message. Other error checks and test cases will be added in follow on commits.
llvm-svn: 296527
show more ...
|
#
dc412ccc |
| 10-Feb-2017 |
Kevin Enderby <enderby@apple.com> |
Yet another fix llvm-objdump so it picks a good CPU based for Mach-O files, in this case for CPU_SUBTYPE_ARM64_ALL.
For this cpusubtype it should default to a cyclone CPU to give proper disassembly
Yet another fix llvm-objdump so it picks a good CPU based for Mach-O files, in this case for CPU_SUBTYPE_ARM64_ALL.
For this cpusubtype it should default to a cyclone CPU to give proper disassembly without a -mcpu= flag.
rdar://27767188
llvm-svn: 294771
show more ...
|
Revision tags: llvmorg-4.0.0-rc2 |
|
#
86d8bd1d |
| 07-Feb-2017 |
Kevin Enderby <enderby@apple.com> |
Fix a typo in an error message for a check of invalid Mach-O files where it was printing the field name fileoff instead of filesize. The original check was added in r278557.
This was found in track
Fix a typo in an error message for a check of invalid Mach-O files where it was printing the field name fileoff instead of filesize. The original check was added in r278557.
This was found in tracking down the problem that lead to the fix in r293842 - [dsymutil] Fix __LINKEDIT vmsize in dsymutil upgrade path
rdar://30386075
llvm-svn: 294354
show more ...
|
#
7a165755 |
| 24-Jan-2017 |
Kevin Enderby <enderby@apple.com> |
Fix llvm-objdump so it picks a good CPU based for Mach-O files for CPU_SUBTYPE_ARM_V7S and CPU_SUBTYPE_ARM_V7K.
For these two cpusubtypes they should default to a cortex-a7 CPU to give proper disass
Fix llvm-objdump so it picks a good CPU based for Mach-O files for CPU_SUBTYPE_ARM_V7S and CPU_SUBTYPE_ARM_V7K.
For these two cpusubtypes they should default to a cortex-a7 CPU to give proper disassembly without a -mcpu= flag.
rdar://27431703
llvm-svn: 292993
show more ...
|
#
c3a035d8 |
| 23-Jan-2017 |
Kevin Enderby <enderby@apple.com> |
Add support for the x86_thread_state32_t and in llvm-objdump for Mach-O files add the printing of the x86_thread_state32_t in the same format as otool-classic(1) on darwin.
To do this the 32-bit x86
Add support for the x86_thread_state32_t and in llvm-objdump for Mach-O files add the printing of the x86_thread_state32_t in the same format as otool-classic(1) on darwin.
To do this the 32-bit x86 general tread state needed to be defined in include/llvm/Support/MachO.h .
rdar://30110111
llvm-svn: 292829
show more ...
|
#
5b54a42c |
| 23-Jan-2017 |
Steven Wu <stevenwu@apple.com> |
Add LC_BUILD_VERSION load command
Summary: Add a new load command LC_BUILD_VERSION. It is a generic version of LC_*_VERSION_MIN load_command used on Apple platforms. Instead of having a seperate loa
Add LC_BUILD_VERSION load command
Summary: Add a new load command LC_BUILD_VERSION. It is a generic version of LC_*_VERSION_MIN load_command used on Apple platforms. Instead of having a seperate load command for each platform, LC_BUILD_VERSION is recording platform info as an enum. It also records SDK version, min_os, and tools that used to build the binary.
rdar://problem/29781291
Reviewers: enderby
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D29044
llvm-svn: 292824
show more ...
|
#
a4579c41 |
| 19-Jan-2017 |
Kevin Enderby <enderby@apple.com> |
Add support for the new LC_NOTE load command.
It describes a region of arbitrary data included in a Mach-O file. Its initial use is to record extra data in MH_CORE files.
rdar://30001545 rdar://300
Add support for the new LC_NOTE load command.
It describes a region of arbitrary data included in a Mach-O file. Its initial use is to record extra data in MH_CORE files.
rdar://30001545 rdar://30001731
llvm-svn: 292500
show more ...
|
Revision tags: llvmorg-4.0.0-rc1 |
|
#
1d84d9ac |
| 08-Jan-2017 |
Saleem Abdulrasool <compnerd@compnerd.org> |
llvm-objdump: speed up -objc-meta-data
Running a Debug build of objdump -objc-meta-data with a large Mach-O file is currently unnecessarily slow.
With some local test input, this change reduces the
llvm-objdump: speed up -objc-meta-data
Running a Debug build of objdump -objc-meta-data with a large Mach-O file is currently unnecessarily slow.
With some local test input, this change reduces the run time from 75-85s down to 15-20s.
The two changes are: Assert on pointer equality not array equality Replace vector<pair<address, symbol>> with DenseMap<address, symbol>
Additionally, use a std::unique_ptr rather than handling the memory manually.
Patch by Dave Lee!
llvm-svn: 291398
show more ...
|
#
59343a94 |
| 16-Dec-2016 |
Kevin Enderby <enderby@apple.com> |
Fix a bugs with using some Mach-O command line flags like "-arch armv7m".
The Mach-O command line flag like "-arch armv7m" does not match the arch name part of its llvm Triple which is "thumbv7m-app
Fix a bugs with using some Mach-O command line flags like "-arch armv7m".
The Mach-O command line flag like "-arch armv7m" does not match the arch name part of its llvm Triple which is "thumbv7m-apple-darwin”.
I think the best way to fix this is to have llvm::object::MachOObjectFile::getArchTriple() optionally return the name of the Mach-O arch flag that would be used with -arch that matches the CPUType and CPUSubType. Then change llvm::object::MachOUniversalBinary::ObjectForArch::getArchTypeName() to use that and change it to getArchFlagName() as the type name is really part of the Triple and the -arch flag name is a Mach-O thing for a specific Triple with a specific Mcpu value.
rdar://29663637
llvm-svn: 290001
show more ...
|
Revision tags: llvmorg-3.9.1, llvmorg-3.9.1-rc3 |
|
#
697e7cd7 |
| 04-Dec-2016 |
Lang Hames <lhames@gmail.com> |
[Object][MachO] Reference-ify some helper function arguments. NFC.
Changes all static helper functions in MachOObjectFile.cpp that expect a non-null MachOObjectFile pointer to take a reference inste
[Object][MachO] Reference-ify some helper function arguments. NFC.
Changes all static helper functions in MachOObjectFile.cpp that expect a non-null MachOObjectFile pointer to take a reference instead.
llvm-svn: 288608
show more ...
|
Revision tags: llvmorg-3.9.1-rc2, llvmorg-3.9.1-rc1 |
|
#
435890a4 |
| 22-Nov-2016 |
Peter Collingbourne <peter@pcc.me.uk> |
Object: Make SymbolicFile::symbol_{begin,end}() virtual and remove unnecessary wrappers.
llvm-svn: 287611
|
#
22fc0078 |
| 14-Nov-2016 |
Kevin Enderby <enderby@apple.com> |
Add a checkSymbolTable() method to the MachOObjectFile class.
The philosophy of the error checking in libObject for Mach-O files is that the constructor will check the load commands so for their tab
Add a checkSymbolTable() method to the MachOObjectFile class.
The philosophy of the error checking in libObject for Mach-O files is that the constructor will check the load commands so for their tables the offsets and sizes are properly contained in the file. But there is no checking of the entries of any of the tables.
For the contents of the tables themselves the methods accessing the contents of the entries return errors as needed. In some cases this however makes it difficult or cumbersome to produce a good error message which would include the tool name, file name, archive member, and name of the architecture of a slice of a universal file the error occurred in.
So idea is that there will be a method to check a table which can be called up front before using it allowing a good error message to be produced before a table is used. And if only verification of the Mach-O file and its tables are wanted a new possible method checkAllTables() could be added to call all of the methods to check all the tables at some time when such methods exist.
The checkSymbolTable() is the first of such methods to check one of the Mach-O file tables. This method initially will used in llvm-objdump’s DisassembleMachO() routine before it gets the section and symbol information. As if there are problems with the symbol table currently the error is first encountered by the bool operator() in the SymbolSorter() struct which passed to std::sort(). In this case there is no context as to the file name the symbol which results a poor error message:
LLVM ERROR: truncated or malformed object (bad string index: 22 for symbol at index 1)
with the added call to the checkSymbolTable() method the error message includes the tool name and file name:
llvm-objdump: 'macho-invalid-symbol-strx': truncated or malformed object (bad string table index: 22 past the end of string table, for symbol at index 1) llvm-svn: 286887
show more ...
|
#
41af4309 |
| 11-Nov-2016 |
Mehdi Amini <mehdi.amini@apple.com> |
Make the Error class constructor protected
This is forcing to use Error::success(), which is in a wide majority of cases a lot more readable.
Differential Revision: https://reviews.llvm.org/D26481
Make the Error class constructor protected
This is forcing to use Error::success(), which is in a wide majority of cases a lot more readable.
Differential Revision: https://reviews.llvm.org/D26481
llvm-svn: 286561
show more ...
|
#
7747cb55 |
| 03-Nov-2016 |
Kevin Enderby <enderby@apple.com> |
Add support for the ARM_THREAD_STATE64 and in llvm-objdump for Mach-O files add the printing of the ARM_THREAD_STATE64 in the same format as otool-classic(1) on darwin.
To do this the 64-bit ARM gen
Add support for the ARM_THREAD_STATE64 and in llvm-objdump for Mach-O files add the printing of the ARM_THREAD_STATE64 in the same format as otool-classic(1) on darwin.
To do this the 64-bit ARM general tread state needed to be defined in include/llvm/Support/MachO.h .
rdar://28985800
llvm-svn: 285967
show more ...
|
#
fbebe163 |
| 02-Nov-2016 |
Kevin Enderby <enderby@apple.com> |
Add the rest of the additional error checks for invalid Mach-O files when the offsets and sizes of an element of the Mach-O file overlaps with another element in the Mach-O file.
Some other tests fo
Add the rest of the additional error checks for invalid Mach-O files when the offsets and sizes of an element of the Mach-O file overlaps with another element in the Mach-O file.
Some other tests for malformed Mach-O files now run into these checks so their tests were also adjusted.
llvm-svn: 285860
show more ...
|
#
d503940e |
| 31-Oct-2016 |
Kevin Enderby <enderby@apple.com> |
More additional error checks for invalid Mach-O files when the offsets and sizes of an element of the file overlaps with another element in the Mach-O file.
This shows the approach to this testing f
More additional error checks for invalid Mach-O files when the offsets and sizes of an element of the file overlaps with another element in the Mach-O file.
This shows the approach to this testing for three elements and contains for tests for their overlap. Checking for all the remain elements will be added next.
llvm-svn: 285632
show more ...
|
#
bc5c29a6 |
| 27-Oct-2016 |
Kevin Enderby <enderby@apple.com> |
Another additional error check for invalid Mach-O files for the obsolete load commands.
Again the philosophy of the error checking in libObject for Mach-O files, the idea behind the checking is that
Another additional error check for invalid Mach-O files for the obsolete load commands.
Again the philosophy of the error checking in libObject for Mach-O files, the idea behind the checking is that we never will return a Mach-O file out of libObject that contains unknown things the library code can’t operate on. So known obsolete load commands will cause a hard error.
Also to make things clear I have added comments to the values and structures in Support/Mach-O.h and Support/MachO.def as to what is obsolete.
As noted in a TODO in the code, there may need to be a non-default mode to allow some unknown values for well structured Mach-O files with things like unknown load load commands. So things like using an old lldb on a newer Mach-O file could still provide some limited functionality.
llvm-svn: 285342
show more ...
|
#
79d6c63f |
| 24-Oct-2016 |
Kevin Enderby <enderby@apple.com> |
nother additional error check for an invalid Mach-O file when contained in a Mach-O universal file and the cputypes in both headers don’t match.
llvm-svn: 285026
|
#
c8bb4228 |
| 20-Oct-2016 |
Kevin Enderby <enderby@apple.com> |
Another additional error check for invalid Mach-O files for the load commands that use the MachO::twolevel_hints_command type which includes only the LC_TWOLEVEL_HINTS load command.
This is not used
Another additional error check for invalid Mach-O files for the load commands that use the MachO::twolevel_hints_command type which includes only the LC_TWOLEVEL_HINTS load command.
This is not used in llvm libObject code or in llvm tool code. But does appear in one of the binary test files. While this load command is obsolete it is easier to add code for it in libObject than edit or change the binary test case.
llvm-svn: 284769
show more ...
|
#
210030ba |
| 19-Oct-2016 |
Kevin Enderby <enderby@apple.com> |
Next set of additional error checks for invalid Mach-O files for the load commands that use the MachO::thread_command type but are not used in llvm libObject code but used in llvm tool code.
This in
Next set of additional error checks for invalid Mach-O files for the load commands that use the MachO::thread_command type but are not used in llvm libObject code but used in llvm tool code.
This includes the LC_UNIXTHREAD and LC_THREAD load commands.
A quick note about the philosophy of the error checking in libObject for Mach-O files, the idea behind the checking is that we never will return a Mach-O file out of libObject that contains unknown things in the load commands.
To do this the 32-bit ARM and PPC general tread states needed to be defined as two test case binaries contained them. If other thread states for other CPUs need to be added we will do that as needed.
Going forward the LC_MAIN load command is used to set the entry point in Mach-O executables these days instead of an LC_UNIXTHREAD as was done in the past. So today only in core files are LC_THREAD load commands and thread states usually found.
Other thread states have not yet been defined in include/Support/MachO.h at this time. But that can be added as needed with their corresponding checking also added.
llvm-svn: 284668
show more ...
|
#
89baf99c |
| 18-Oct-2016 |
Kevin Enderby <enderby@apple.com> |
One more additional error check for invalid Mach-O files for a load command that use the MachO:: linkedit_data_command type but is not used in llvm libObject code but used in llvm tool code.
This is
One more additional error check for invalid Mach-O files for a load command that use the MachO:: linkedit_data_command type but is not used in llvm libObject code but used in llvm tool code.
This is for the LC_CODE_SIGNATURE load command.
llvm-svn: 284529
show more ...
|
#
6f69582e |
| 18-Oct-2016 |
Kevin Enderby <enderby@apple.com> |
Next set of additional error checks for invalid Mach-O files for the load commands that use the MachO::routines_command and and MachO::routines_command_64 types but are not used in llvm libObject cod
Next set of additional error checks for invalid Mach-O files for the load commands that use the MachO::routines_command and and MachO::routines_command_64 types but are not used in llvm libObject code but used in llvm tool code.
This includes the LC_ROUTINES and LC_ROUTINES_64 load commands.
llvm-svn: 284504
show more ...
|
#
2490de06 |
| 17-Oct-2016 |
Kevin Enderby <enderby@apple.com> |
Next set of additional error checks for invalid Mach-O files for the load commands that use the MachO::sub_framework_command, MachO::sub_umbrella_command, MachO::sub_library_command and MachO::sub_cl
Next set of additional error checks for invalid Mach-O files for the load commands that use the MachO::sub_framework_command, MachO::sub_umbrella_command, MachO::sub_library_command and MachO::sub_client_command types but are not used in llvm libObject code but used in llvm tool code.
This includes the LC_SUB_FRAMEWORK, LC_SUB_UMBRELLA, LC_SUB_LIBRARY and LC_SUB_CLIENT load commands.
llvm-svn: 284431
show more ...
|