summaryrefslogtreecommitdiffstats
path: root/llvm/test/tools/llvm-objdump
Commit message (Collapse)AuthorAgeFilesLines
...
* [WebAssembly] Add wasm symbol table support to llvm-objdumpSam Clegg2017-05-041-0/+8
| | | | | | Differential Revision: https://reviews.llvm.org/D32760 llvm-svn: 302185
* [llvm-objdump] Don't attempt to print lines beyond the end of filePetr Hosek2017-04-252-0/+27
| | | | | | | | | | | | | This may trigger a segfault in llvm-objdump when the line number stored in debug infromation points beyond the end of file; lines in LineBuffer are stored in std::vector which is allocated in chunks, so even if the debug info points beyond the end of the file, this doesn't necessarily trigger the segfault unless the line number points beyond the allocated space. Differential Revision: https://reviews.llvm.org/D32466 llvm-svn: 301347
* [Object] Remove check for BIND_OPCODE_DONE/REBASE_OPCODE_DONE.Juergen Ributzka2017-03-303-6/+0
| | | | | | | | | | BIND_OPCODE_DONE/REBASE_OPCODE_DONE may appear at the end of the opcode array, but they are not required to. The linker only adds them as padding to align the opcodes to pointer size. This fixes rdar://problem/31285560. llvm-svn: 299104
* [WebAssembly] Improve support for WebAssembly binary formatDerek Schuff2017-03-302-1/+1
| | | | | | | | | | | | | | | | | | | Mostly this change adds support converting to and from YAML which will allow us to write more test cases for the WebAssembly MC and lld ports. Better support for objdump, readelf, and nm will be in followup CLs. I had to update the two wasm test binaries because they used the old style 'name' section which is no longer supported. Differential Revision: https://reviews.llvm.org/D31099 Patch by Sam Clegg llvm-svn: 299101
* Add the error handling for Mach-O dyld compact lazy bind, weak bind andKevin Enderby2017-03-2720-1/+58
| | | | | | | | | | | | | | | | | | | | | 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
* Add the rest of the error checking for Mach-O dyld compact bind entry errorsKevin Enderby2017-03-2019-2/+52
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix source-lines test on Windows.Zachary Turner2017-03-071-7/+7
| | | | llvm-svn: 297233
* llvm-objdump: handle line numbers and source options for amdgpu objectsKonstantin Zhuravlyov2017-03-073-0/+117
| | | | | | Differential Revision: https://reviews.llvm.org/D30679 llvm-svn: 297193
* [mips] Drop unneeded REQUIRES line in test. NFCISimon Dardis2017-03-011-1/+0
| | | | | | rL296111 provides the proper fix. llvm-svn: 296622
* Actually add error handling to unpacking the dyld compact bind andKevin Enderby2017-02-281-5/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [mips][mc] Fix a crash when disassembling odd sized sectionsSimon Dardis2017-02-241-0/+1
| | | | | | Attempt to fix failing test. llvm-svn: 296112
* Fixup r296105 - only run tests on MipsDiana Picus2017-02-241-0/+3
| | | | llvm-svn: 296111
* [mips][mc] Fix a crash when disassembling odd sized sectionsSimon Dardis2017-02-241-0/+16
| | | | | | Corresponding test. llvm-svn: 296106
* [WebAssembly] Update llvm-objdump tests for the new wasm version number.Dan Gohman2017-02-222-1/+1
| | | | llvm-svn: 295869
* Yet another fix llvm-objdump so it picks a good CPU based for Mach-O files,Kevin Enderby2017-02-103-1/+4
| | | | | | | | | | | 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
* Tweak the implementation of llvm-objdump’s -objc-meta-data option soKevin Enderby2017-02-092-0/+62
| | | | | | | | | that it works when the ObjC metadata sections end up in the __DATA_CONST or __DATA_DIRTY segments. rdar://26315238 llvm-svn: 294599
* Move test from r294430 to target-specific directoryDiana Picus2017-02-082-0/+0
| | | | | | | The test is X86-specific, and it broke on the ARM bots because they don't build the X86 target. llvm-svn: 294446
* Use dynamic symbols for ELF disassemblySam Parker2017-02-082-0/+10
| | | | | | | | | | | Disassembly currently begins from addresses obtained from the objects symbol table. For ELF, add the dynamic symbols to the list if no static symbols are available so that we can more successfully disassemble stripped binaries. Differential Revision: https://reviews.llvm.org/D29632 llvm-svn: 294430
* Fix a bug in llvm-obdump(1) with the -macho and -info-plist optionsKevin Enderby2017-02-061-0/+10
| | | | | | | | | which caused it to print more than the (__TEXT,__info_plist) if that section did not end with a null. rdar://27378808 llvm-svn: 294236
* Fix a bug in llvm-obdump(1) with the -macho and -disassemble optionsKevin Enderby2017-02-062-0/+8
| | | | | | | | | | which caused it to not disassemble the bytes a the start of the section if the section had symbols and the first symbol was not at the start of the section. rdar://30143243 llvm-svn: 294212
* Fix a bug in llvm-obdump(1) with the -objc-meta-data flag with -machoKevin Enderby2017-02-032-0/+3
| | | | | | | | which caused a hang on a malformed binary with bad bind info. rdar://29672108 llvm-svn: 294021
* Fix a bug in llvm-obdump(1) with the -macho flag disassembling an objectKevin Enderby2017-01-312-0/+3
| | | | | | | | | | | | | without symbols that makes calls through a symbol stub which were not correctly being annotated with “## symbol stub for: _foo”. Just adds the same parameters for getting the annotations from DisAsm->getInstruction() and passing them to IP->printInst() from the code above when boolean variable symbolTableWorked was true. rdar://29791952 llvm-svn: 293662
* Change the llvm-obdump(1) behavior with the -macho flag and inappropriate ↵Kevin Enderby2017-01-301-2/+3
| | | | | | | | | | | | | | | | | | file types. To better match the old darwin otool(1) behavior, when llvm-obdump(1) is used with the -macho option and the input file is not an object file simply print the file name and this message: foo: is not an object file and continue on to process other input files. Also in this case don’t exit non-zero. This should help in some OSS projects' with autoconf scripts that are expecting the old darwin otool(1) behavior. rdar://26828015 llvm-svn: 293547
* Fix llvm-objdump so it picks a good CPU based for Mach-O filesKevin Enderby2017-01-242-0/+3
| | | | | | | | | | | 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
* Add support for the x86_thread_state32_t andKevin Enderby2017-01-232-0/+11
| | | | | | | | | | | | | 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
* Add LC_BUILD_VERSION load commandSteven Wu2017-01-232-0/+101
| | | | | | | | | | | | | | | | | | | 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
* Add support for the new LC_NOTE load command.Kevin Enderby2017-01-192-0/+8
| | | | | | | | | | 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
* [ARM] Create SubtargetFeatures from build attrsSam Parker2017-01-187-0/+163
| | | | | | | | | | | An ELFObjectFile can now create SubtargetFeatures from the available ARM build attributes, in a similar manner to MIPS. I've moved the MIPS code into its own function and the ARM handler also has a separate function. Differential Revision: https://reviews.llvm.org/D28291 llvm-svn: 292403
* [ARM] Create objdump subtarget from build attrsSam Parker2017-01-188-0/+74
| | | | | | | | | | | Enable an ELFObjectFile to read the its arm build attributes to produce a target triple with a specific ARM architecture. llvm-objdump now uses this functionality to automatically produce a more accurate target. Differential Revision: https://reviews.llvm.org/D28769 llvm-svn: 292366
* [llvm-objdump tests] Copy the inputs of tests closer to tests.Krasimir Georgiev2017-01-175-3/+3
| | | | | | | | | | | | | | | | | Summary: Tests under tools/llvm-objdump should not use inputs from Object. Copied the required inputs and aligned the new tests to be more consistent with the existing tests in this respect. Reviewers: ioeric Reviewed By: ioeric Subscribers: davide, djasper, cfe-commits Differential Revision: https://reviews.llvm.org/D28799 llvm-svn: 292222
* [llvm-objdump] Dump PT_NOTE as part of -p.Davide Italiano2017-01-161-0/+14
| | | | | PR: 31641 llvm-svn: 292170
* [llvm-objdump] Dump PT_GNU_RELRO as part of -p.Davide Italiano2017-01-161-0/+18
| | | | | PR: 31641 llvm-svn: 292169
* [llvm-objdump] Dump PT_OPENBSD_{BOOTDATA,RANDOMIZE,WXNEEDED}.Davide Italiano2017-01-161-0/+20
| | | | | PR: 31641 llvm-svn: 292167
* Revert r291903 and r291898. Reason: they break check-lld on the bots.Ivan Krasin2017-01-138-74/+0
| | | | | | | | | | | | | | | | | | | | | | | | Summary: Revert [ARM] Fix ubig32_t read in ARMAttributeParser Now using support functions to read data instead of trying to perform casts. =========================================================== Revert [ARM] Enable objdump to construct triple for ARM Now that The ARMAttributeParser has been moved into the library, it has been modified so that it can parse the attributes without printing them and stores them in a map. ELFObjectFile now queries the attributes to fill out the architecture details of a provided triple for 'arm' and 'thumb' targets. llvm-objdump uses this new functionality. Subscribers: llvm-commits, samparker, aemerson, mgorny Differential Revision: https://reviews.llvm.org/D28683 llvm-svn: 291911
* [ARM] Enable objdump to construct triple for ARMSam Parker2017-01-138-0/+74
| | | | | | | | | | | | | Now that The ARMAttributeParser has been moved into the library, it has been modified so that it can parse the attributes without printing them and stores them in a map. ELFObjectFile now queries the attributes to fill out the architecture details of a provided triple for 'arm' and 'thumb' targets. llvm-objdump uses this new functionality. Differential Revision: https://reviews.llvm.org/D28281 llvm-svn: 291898
* [IR] Remove the DIExpression field from DIGlobalVariable.Adrian Prantl2016-12-202-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch implements PR31013 by introducing a DIGlobalVariableExpression that holds a pair of DIGlobalVariable and DIExpression. Currently, DIGlobalVariables holds a DIExpression. This is not the best way to model this: (1) The DIGlobalVariable should describe the source level variable, not how to get to its location. (2) It makes it unsafe/hard to update the expressions when we call replaceExpression on the DIGLobalVariable. (3) It makes it impossible to represent a global variable that is in more than one location (e.g., a variable with multiple DW_OP_LLVM_fragment-s). We also moved away from attaching the DIExpression to DILocalVariable for the same reasons. This reapplies r289902 with additional testcase upgrades and a change to the Bitcode record for DIGlobalVariable, that makes upgrading the old format unambiguous also for variables without DIExpressions. <rdar://problem/29250149> https://llvm.org/bugs/show_bug.cgi?id=31013 Differential Revision: https://reviews.llvm.org/D26769 llvm-svn: 290153
* Fix a bugs with using some Mach-O command line flags like "-arch armv7m".Kevin Enderby2016-12-162-0/+5
| | | | | | | | | | | | | | | | | | 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
* Revert "[IR] Remove the DIExpression field from DIGlobalVariable."Adrian Prantl2016-12-162-2/+2
| | | | | | | | | | | | | | | | | This reverts commit 289920 (again). I forgot to implement a Bitcode upgrade for the case where a DIGlobalVariable has not DIExpression. Unfortunately it is not possible to safely upgrade these variables without adding a flag to the bitcode record indicating which version they are. My plan of record is to roll the planned follow-up patch that adds a unit: field to DIGlobalVariable into this patch before recomitting. This way we only need one Bitcode upgrade for both changes (with a version flag in the bitcode record to safely distinguish the record formats). Sorry for the churn! llvm-svn: 289982
* [IR] Remove the DIExpression field from DIGlobalVariable.Adrian Prantl2016-12-162-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch implements PR31013 by introducing a DIGlobalVariableExpression that holds a pair of DIGlobalVariable and DIExpression. Currently, DIGlobalVariables holds a DIExpression. This is not the best way to model this: (1) The DIGlobalVariable should describe the source level variable, not how to get to its location. (2) It makes it unsafe/hard to update the expressions when we call replaceExpression on the DIGLobalVariable. (3) It makes it impossible to represent a global variable that is in more than one location (e.g., a variable with multiple DW_OP_LLVM_fragment-s). We also moved away from attaching the DIExpression to DILocalVariable for the same reasons. This reapplies r289902 with additional testcase upgrades. <rdar://problem/29250149> https://llvm.org/bugs/show_bug.cgi?id=31013 Differential Revision: https://reviews.llvm.org/D26769 llvm-svn: 289920
* [WebAssembly] Add llvm-objdump support for wasm file formatDerek Schuff2016-11-302-0/+24
| | | | | | | | | | | This is the first part of an effort to add wasm binary support across all llvm tools. Patch by Sam Clegg Differential Revision: https://reviews.llvm.org/D26172 llvm-svn: 288251
* Add to llvm-objdump the -no-leading-headers option with the use of the ↵Kevin Enderby2016-11-291-0/+4
| | | | | | | | | | | | | -macho option. In some cases the leading headers of the file name, archive member and architecture slice name in the output of lvm-objdump is not wanted so the tool’s output can be directly used by scripts. This matches the -X option of the Apple otool(1) program. rdar://28491674 llvm-svn: 288199
* General clean up of error handling in llvm-objdump to remove its use of ↵Kevin Enderby2016-11-161-0/+3
| | | | | | | | | | | | | | | | | | report_fatal_error(). No real functional change with this commit. The problem with report_fatal_error() is it does not include the tool name and the file name the for which the error message was generated. Uses of report_fatal_error() were change to report_error() or error() to get a better error and to make the code smaller and cleaner. Also changed things like error(errorToErrorCode(SOrErr.takeError())) to use report_error() with a file name and the llvm::Error (as well as the ArchitectureName if available) so the error message is printed. llvm-svn: 287163
* General clean up of Mach-O error handling in llvm-objdump.Kevin Enderby2016-11-154-0/+9
| | | | | | | | | | | | | | | | | | | | | To get a good error message for all files that could contain Mach-O files the code in llvm-objdump needs to use the archive member name and name of the architecture of a slice of a universal file in those cases where the error come from a Mach-O file in an archive or a universal file. Most of this is fixed by moving the call to checkSymbolTable() into ProcessMachO() and calling it when the operation needs the symbol table. And then calling the form of report_error() that has the ArchiveName and ArchitectureName arguments. One other place needed to call this form of report_error() also with these arguments. Also changed the code in MachODump.cpp to not use report_fatal_error() and use report_error() instead to make the code smaller and cleaner. All cases of this are for errors with the symbol table which should now never be tripped since checkSymbolTable() should be called first to get a good error message in these cases. llvm-svn: 287050
* llvm-objdump: deal with unexpected object files more gracefully.Tim Northover2016-11-152-0/+5
| | | | | | | Specifically, we don't want to segfault on release builds, so print the problem instead. llvm-svn: 287022
* Add a checkSymbolTable() method to the MachOObjectFile class.Kevin Enderby2016-11-145-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add support for the ARM_THREAD_STATE64 andKevin Enderby2016-11-032-0/+19
| | | | | | | | | | | | | 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
* Add the rest of the additional error checks for invalid Mach-O files whenKevin Enderby2016-11-021-9/+9
| | | | | | | | | | 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
* llvm-objdump: Make some error messages more consistentJustin Bogner2016-10-261-6/+6
| | | | | | | | | Most of the version of report_error were quoting the filename and printing a colon between the file name and the error message, but this one wasn't doing either of those. Fix the output to be more consistent. llvm-svn: 285252
* For llvm-objdump for Mach-O files add printing ofKevin Enderby2016-10-212-0/+13
| | | | | | | | | | | | the ARM_THREAD_STATE in the same format as otool-classic(1) on darwin. Also remove an extra space in printing the initprot to make the output match otool-classic(1) on darwin. rdar://28851457 llvm-svn: 284852
* DebugInfo: New metadata representation for global variables.Peter Collingbourne2016-09-132-4/+4
| | | | | | | | | | | | | This patch reverses the edge from DIGlobalVariable to GlobalVariable. This will allow us to more easily preserve debug info metadata when manipulating global variables. Fixes PR30362. A program for upgrading test cases is attached to that bug. Differential Revision: http://reviews.llvm.org/D20147 llvm-svn: 281284
OpenPOWER on IntegriCloud