summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-nm/llvm-nm.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [llvm-nm] Transform a switch() statement in a pair of if(s).Davide Italiano2016-02-051-7/+2
| | | | | | | This is more uniform wrt what other tools do and makes the code a little bit more readable. llvm-svn: 259937
* [llvm-nm] Simplify code logic. NFCI.Davide Italiano2016-02-051-7/+3
| | | | llvm-svn: 259917
* [llvm-nm] Simplify the code a bit. NFCI.Davide Italiano2016-02-011-6/+2
| | | | | | Fix a style violation while I'm here. llvm-svn: 259391
* [llvm-nm] Add a comment to explain why we initialize MC.Davide Italiano2016-01-291-0/+1
| | | | llvm-svn: 259266
* [llvm-nm] Remove redundant check for file validity.Davide Italiano2016-01-271-2/+0
| | | | | | | | We already perform it at the beginning of the function so we can't arrive here with an invalid object. Also, add a test so that bugs won't sneak in the future. llvm-svn: 258982
* [llvm-nm] Roll several conditions into a single if. NFCI.Davide Italiano2016-01-261-7/+2
| | | | llvm-svn: 258846
* [llvm-nm] Simplify. No functional changes intended.Davide Italiano2016-01-261-4/+3
| | | | llvm-svn: 258837
* Fix MachOObjectFile::getSymbolName() to not call report_fatal_error()Kevin Enderby2016-01-221-2/+5
| | | | | | | | | | | but to return object_error::parse_failed.  Then made the code in llvm-nm do for Mach-O files what is done in the darwin native tools which is to print "bad string index" for bad string indexes. Updated the error message in the llvm-objdump test, and added tests to show llvm-nm prints "bad string index" and a test to print the actual bad string index value which in this case is 0xfe000002 when printing the fields as raw hex. llvm-svn: 258520
* Fix MachOObjectFile::getSymbolSection() to not call report_fatal_error()Kevin Enderby2016-01-211-2/+11
| | | | | | | | | but to return object_error::parse_failed.  Then made the code in llvm-nm do for Mach-O files what is done in the darwin native tools which is to print "(?,?)" or just "s" for bad section indexes. Also added a test to show it prints the bad section index of "42" when printing the fields as raw hex. llvm-svn: 258434
* GlobalValue: use getValueType() instead of getType()->getPointerElementType().Manuel Jacob2016-01-161-1/+1
| | | | | | | | | | | | Reviewers: mjacob Subscribers: jholewinski, arsenm, dsanders, dblaikie Patch by Eduard Burtescu. Differential Revision: http://reviews.llvm.org/D16260 llvm-svn: 257999
* Fix UMR in llvm-nm on IR object files in printDarwinSymbolReid Kleckner2015-11-191-5/+4
| | | | llvm-svn: 253529
* Fix llvm-nm(1) printing of llvm-bitcode files for -format darwin to match ↵Kevin Enderby2015-11-101-45/+113
| | | | | | | | darwin’s nm(1). Also a small fix to match printing of Mach-O objects with -format posix. llvm-svn: 252567
* Reapply r250906 with many suggested updates from Rafael Espindola.Kevin Enderby2015-11-051-5/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The needed lld matching changes to be submitted immediately next, but this revision will cause lld failures with this alone which is expected. This removes the eating of the error in Archive::Child::getSize() when the characters in the size field in the archive header for the member is not a number. To do this we have all of the needed methods return ErrorOr to push them up until we get out of lib. Then the tools and can handle the error in whatever way is appropriate for that tool. So the solution is to plumb all the ErrorOr stuff through everything that touches archives. This include its iterators as one can create an Archive object but the first or any other Child object may fail to be created due to a bad size field in its header. Thanks to Lang Hames on the changes making child_iterator contain an ErrorOr<Child> instead of a Child and the needed changes to ErrorOr.h to add operator overloading for * and -> . We don’t want to use llvm_unreachable() as it calls abort() and is produces a “crash” and using report_fatal_error() to move the error checking will cause the program to stop, neither of which are really correct in library code. There are still some uses of these that should be cleaned up in this library code for other than the size field. The test cases use archives with text files so one can see the non-digit character, in this case a ‘%’, in the size field. These changes will require corresponding changes to the lld project. That will be committed immediately after this change. But this revision will cause lld failures with this alone which is expected. llvm-svn: 252192
* Don't implicitly construct a Archive::child_iterator.Rafael Espindola2015-11-031-2/+2
| | | | llvm-svn: 251878
* Allow llvm-nm’s single letter command line flags to be grouped.Kevin Enderby2015-11-021-18/+22
| | | | | | | | | | Which is needed if we want to replace darwin’s nm(1) with llvm-nm as there are many uses of grouped flags. The added test case is one specific case that is in real use. rdar://23337419 llvm-svn: 251864
* Implemented the code to make llvm-nm’s -g option work.Kevin Enderby2015-10-301-0/+3
| | | | | | | | | | | | | While llvm-nm parses the -g option and has help that describes it as: -extern-only - Show only external symbols There is no code in the program to use the boolean valve it sets from the command line. rdar://23261095 llvm-svn: 251718
* Backing out commit r250906 as it broke lld.Kevin Enderby2015-10-211-20/+7
| | | | llvm-svn: 250908
* This removes the eating of the error in Archive::Child::getSize() when the ↵Kevin Enderby2015-10-211-7/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | characters in the size field in the archive header for the member is not a number. To do this we have all of the needed methods return ErrorOr to push them up until we get out of lib. Then the tools and can handle the error in whatever way is appropriate for that tool. So the solution is to plumb all the ErrorOr stuff through everything that touches archives. This include its iterators as one can create an Archive object but the first or any other Child object may fail to be created due to a bad size field in its header. Thanks to Lang Hames on the changes making child_iterator contain an ErrorOr<Child> instead of a Child and the needed changes to ErrorOr.h to add operator overloading for * and -> . We don’t want to use llvm_unreachable() as it calls abort() and is produces a “crash” and using report_fatal_error() to move the error checking will cause the program to stop, neither of which are really correct in library code. There are still some uses of these that should be cleaned up in this library code for other than the size field. Also corrected the code where the size gets us to the “at the end of the archive” which is OK but past the end of the archive will return object_error::parse_failed now. The test cases use archives with text files so one can see the non-digit character, in this case a ‘%’, in the size field. llvm-svn: 250906
* Fix Clang-tidy modernize-use-nullptr warnings in source directories and ↵Hans Wennborg2015-10-061-5/+6
| | | | | | | | | | generated files; other minor cleanups. Patch by Eugene Zelenko! Differential Revision: http://reviews.llvm.org/D13321 llvm-svn: 249482
* Convert getSymbolSection to return an ErrorOr.Rafael Espindola2015-08-071-8/+8
| | | | | | | This function can actually fail since the symbol contains an index to the section and that can be invalid. llvm-svn: 244375
* Use std::make_tuple to reduce code duplication.Rafael Espindola2015-07-131-27/+8
| | | | | | Thanks to David Blaikie for the suggestion. llvm-svn: 242074
* Delete UnknownAddress. It is a perfectly valid symbol value.Rafael Espindola2015-07-071-11/+7
| | | | | | | | | | | getSymbolValue now returns a value that in convenient for most callers: * 0 for undefined * symbol size for common symbols * offset/address for symbols the rest Code that needs something more specific can check getSymbolFlags. llvm-svn: 241605
* llvm-nm: treat weak undefined as undefined.Rafael Espindola2015-07-061-12/+18
| | | | | | This matches the behavior of gnu ld. llvm-svn: 241512
* Swap operands instead of using !.Rafael Espindola2015-07-061-1/+1
| | | | | | | | This avoids returning true for A == B. Thanks to Benjamin Kramer for noticing it. llvm-svn: 241490
* When sorting by address, undefined symbols go first.Rafael Espindola2015-07-061-0/+4
| | | | | | This matches gnu nm. llvm-svn: 241488
* Reduce code duplication. NFC.Rafael Espindola2015-07-061-41/+17
| | | | llvm-svn: 241484
* Fix printing of common symbols.Rafael Espindola2015-07-061-4/+9
| | | | | | Printing the symbol size matches the behavior or both gnu nm and freebsd nm. llvm-svn: 241480
* Return ErrorOr from getSymbolAddress.Rafael Espindola2015-07-031-1/+3
| | | | | | | It can fail trying to get the section on ELF and COFF. This makes sure the error is handled. llvm-svn: 241366
* Return ErrorOr from SymbolRef::getName.Rafael Espindola2015-07-021-6/+6
| | | | | | | | | | | | This function can really fail since the string table offset can be out of bounds. Using ErrorOr makes sure the error is checked. Hopefully a lot of the boilerplate code in tools/* can go away once we have a diagnostic manager in Object. llvm-svn: 241297
* Simplify isSymbolList64Bit. NFC.Rafael Espindola2015-06-261-9/+1
| | | | llvm-svn: 240784
* Simplify isObject. NFC.Rafael Espindola2015-06-261-19/+5
| | | | llvm-svn: 240783
* Implement elf_section_iterator and getELFType().Rafael Espindola2015-06-261-21/+10
| | | | | | And with those, simplify getSymbolNMTypeChar. llvm-svn: 240780
* Add an ELFSymbolRef type.Rafael Espindola2015-06-251-2/+2
| | | | | | | This allows user code to say Sym.getSize() instead of having to manually fetch the object. llvm-svn: 240708
* llvm-nm: print 'n' instead of '?'Rafael Espindola2015-06-251-1/+1
| | | | | | This matches gnu nm and has the advantage that there is a upper case N. llvm-svn: 240655
* Use range loop. NFC.Rafael Espindola2015-06-251-20/+18
| | | | llvm-svn: 240645
* Modernize getELFDynamicSymbolIterators.Rafael Espindola2015-06-251-5/+5
| | | | | | | | * Have it return a iterator_range. * Remove the global function. * Rename to getDynamicSymbolIterators. llvm-svn: 240644
* Change how symbol sizes are handled in lib/Object.Rafael Espindola2015-06-241-12/+12
| | | | | | | | | | | | | | COFF and MachO only define symbol sizes for common symbols. Reflect that in the class hierarchy by having a method for common symbols only in the base and a general one in ELF. This avoids the need of using a magic value for the size, which had a few problems * Most callers didn't check for it. * The ones that did could not tell the magic value from a file actually having that value. llvm-svn: 240529
* Simplify another function that doesn't fail.Rafael Espindola2015-06-011-2/+1
| | | | llvm-svn: 238703
* Fix llvm-nm -S option.Rafael Espindola2015-05-221-1/+1
| | | | | | | It is explicitly documented to have no effect on object formats where symbols don't have sizes. llvm-svn: 238019
* Cleanup else-after-return and add an early-return to llvm-nmDavid Blaikie2015-03-231-71/+59
| | | | | | | | | | | | The loop and error handling in checkMachOAndArchFlags didn't make sense to me (a loop that only ever executes once? An error path that uses the element the loop stopped at (which must always be a buffer overrun if I'm reading that right?)... I'm confused) but I've made a guess at what was intended. Based on a patch by Richard Thomson to simplify boolean expressions. llvm-svn: 233025
* [cleanup] Re-sort all the #include lines in LLVM usingChandler Carruth2015-01-141-1/+1
| | | | | | | | | | | utils/sort_includes.py. I clearly haven't done this in a while, so more changed than usual. This even uncovered a missing include from the InstrProf library that I've added. No functionality changed here, just mechanical cleanup of the include order. llvm-svn: 225974
* Return ErrorOr<std::unique_ptr<Archive>> form getAsArchive.Rafael Espindola2014-12-091-6/+8
| | | | | | This is the same return type of Archive::create. llvm-svn: 223827
* Object, COFF: Cleanup symbol type code, improve binutils compatibilityDavid Majnemer2014-10-311-9/+5
| | | | | | | Do a better job classifying symbols. This increases the consistency between the COFF handling code and the ELF side of things. llvm-svn: 220952
* LTO: introduce object file-based on-disk module format.Peter Collingbourne2014-09-181-2/+5
| | | | | | | | | | | | | | | | | | This format is simply a regular object file with the bitcode stored in a section named ".llvmbc", plus any number of other (non-allocated) sections. One immediate use case for this is to accommodate compilation processes which expect the object file to contain metadata in non-allocated sections, such as the ".go_export" section used by some Go compilers [1], although I imagine that in the future we could consider compiling parts of the module (such as large non-inlinable functions) directly into the object file to improve LTO efficiency. [1] http://golang.org/doc/install/gccgo#Imports Differential Revision: http://reviews.llvm.org/D4371 llvm-svn: 218078
* Object: Add support for bigobjDavid Majnemer2014-09-101-4/+4
| | | | | | | | | | | | | | | | | | | | | | This adds support for reading the "bigobj" variant of COFF produced by cl's /bigobj and mingw's -mbig-obj. The most significant difference that bigobj brings is more than 2**16 sections to COFF. bigobj brings a few interesting differences with it: - It doesn't have a Characteristics field in the file header. - It doesn't have a SizeOfOptionalHeader field in the file header (it's only used in executable files). - Auxiliary symbol records have the same width as a symbol table entry. Since symbol table entries are bigger, so are auxiliary symbol records. Write support will come soon. Differential Revision: http://reviews.llvm.org/D5259 llvm-svn: 217496
* Don't own the buffer in object::Binary.Rafael Espindola2014-08-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Owning the buffer is somewhat inflexible. Some Binaries have sub Binaries (like Archive) and we had to create dummy buffers just to handle that. It is also a bad fit for IRObjectFile where the Module wants to own the buffer too. Keeping this ownership would make supporting IR inside native objects particularly painful. This patch focuses in lib/Object. If something elsewhere used to own an Binary, now it also owns a MemoryBuffer. This patch introduces a few new types. * MemoryBufferRef. This is just a pair of StringRefs for the data and name. This is to MemoryBuffer as StringRef is to std::string. * OwningBinary. A combination of Binary and a MemoryBuffer. This is needed for convenience functions that take a filename and return both the buffer and the Binary using that buffer. The C api now uses OwningBinary to avoid any change in semantics. I will start a new thread to see if we want to change it and how. llvm-svn: 216002
* Use a simpler predicate. NFC.Rafael Espindola2014-08-081-2/+1
| | | | llvm-svn: 215218
* Remove some calls to std::move.Rafael Espindola2014-08-011-14/+14
| | | | | | | | | Instead of moving out the data in a ErrorOr<std::unique_ptr<Foo>>, get a reference to it. Thanks to David Blaikie for the suggestion. llvm-svn: 214516
* Replaces a few pointers with references in llvm-nm.cpp.Rafael Espindola2014-07-311-40/+39
| | | | | | This opens the way for a few std::uinque_ptr cleanups. llvm-svn: 214439
* Use std::unique_ptr to make the ownership explicit.Rafael Espindola2014-07-311-2/+2
| | | | llvm-svn: 214377
OpenPOWER on IntegriCloud