summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-size
Commit message (Collapse)AuthorAgeFilesLines
* [llvm-size] print a blank line between archieve members when using sysv formatTH3CHARLie2020-01-031-4/+2
| | | | | | | | | | | | | | Summary: This patch is related to https://bugs.llvm.org/show_bug.cgi?id=42967 and it fixes llvm-size's sysv format output by adding a blank line between archieve members Reviewers: jhenderson, Jim, MaskRay Reviewed By: jhenderson, Jim, MaskRay Subscribers: MaskRay, Jim, rupprecht, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D71957
* Reapply: [llvm-size] Tidy up error messages (PR42970)Jordan Rupprecht2019-10-141-22/+22
| | | | | | | | | | | | Clean up some formatting inconsistencies in the error messages and correctly exit with non-zero in all error cases. Originally submitted as r374771 and then reverted as r374780, this patch fixes the libObject test case in Object/macho-invalid.test. Patch by Alex Cameron Differential Revision: https://reviews.llvm.org/D68906 llvm-svn: 374793
* Revert r374771 "[llvm-size] Tidy up error messages (PR42970)"Nico Weber2019-10-141-22/+22
| | | | | | | | | This reverts commit 83e52f5e1150018329b8907bb014c77ac382d611. Makes Object/macho-invalid.test fail everywhere, e.g. here: http://lab.llvm.org:8011/builders/llvm-hexagon-elf/builds/23669/steps/test-llvm/logs/FAIL%3A%20LLVM%3A%3Amacho-invalid.test llvm-svn: 374780
* [llvm-size] Tidy up error messages (PR42970)Fangrui Song2019-10-141-22/+22
| | | | | | | | | Clean up some formatting inconsistencies in the error messages and correctly exit with non-zero in all error cases. Differential Revision: https://reviews.llvm.org/D68906 Patch by Alex Cameron llvm-svn: 374771
* [llvm-size] Fix spelling errors (Berkely -> Berkeley)James Henderson2019-09-131-3/+3
| | | | llvm-svn: 371845
* Recommit r368812 "[llvm/Object] - Convert SectionRef::getName() to return ↵George Rimar2019-08-141-19/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Expected<>" Changes: no changes. A fix for the clang code will be landed right on top. Original commit message: SectionRef::getName() returns std::error_code now. Returning Expected<> instead has multiple benefits. For example, it forces user to check the error returned. Also Expected<> may keep a valuable string error message, what is more useful than having a error code. (Object\invalid.test was updated to show the new messages printed.) This patch makes a change for all users to switch to Expected<> version. Note: in a few places the error returned was ignored before my changes. In such places I left them ignored. My intention was to convert the interface used, and not to improve and/or the existent users in this patch. (Though I think this is good idea for a follow-ups to revisit such places and either remove consumeError calls or comment each of them to clarify why it is OK to have them). Differential revision: https://reviews.llvm.org/D66089 llvm-svn: 368826
* Revert r368812 "[llvm/Object] - Convert SectionRef::getName() to return ↵George Rimar2019-08-141-13/+19
| | | | | | | | Expected<>" It broke clang BB: http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/16455 llvm-svn: 368813
* [llvm/Object] - Convert SectionRef::getName() to return Expected<>George Rimar2019-08-141-19/+13
| | | | | | | | | | | | | | | | | | | | | | | SectionRef::getName() returns std::error_code now. Returning Expected<> instead has multiple benefits. For example, it forces user to check the error returned. Also Expected<> may keep a valuable string error message, what is more useful than having a error code. (Object\invalid.test was updated to show the new messages printed.) This patch makes a change for all users to switch to Expected<> version. Note: in a few places the error returned was ignored before my changes. In such places I left them ignored. My intention was to convert the interface used, and not to improve and/or the existent users in this patch. (Though I think this is good idea for a follow-ups to revisit such places and either remove consumeError calls or comment each of them to clarify why it is OK to have them). Differential revision: https://reviews.llvm.org/D66089 llvm-svn: 368812
* [binutils] Add response file option to help and docsJames Henderson2019-06-211-0/+3
| | | | | | | | | | | | | | | | | | | | | Many LLVM-based tools already support response files (i.e. files containing a list of options, specified with '@'). This change simply updates the documentation and help text for some of these tools to include it. I haven't attempted to fix all tools, just a selection that I am interested in. I've taken the opportunity to add some tests for --help behaviour, where they were missing. We could expand these tests, but I don't think that's within scope of this patch. This fixes https://bugs.llvm.org/show_bug.cgi?id=42233 and https://bugs.llvm.org/show_bug.cgi?id=42236. Reviewed by: grimar, MaskRay, jkorous Differential Revision: https://reviews.llvm.org/D63597 llvm-svn: 364036
* Sanitize llvm-size helpSerge Guelton2019-06-051-26/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove irrelevant options from standard help output. New output: OVERVIEW: llvm object size dumper USAGE: llvm-size [options] <input files> OPTIONS: Generic Options: --help - Display available options (--help-hidden for more) --help-list - Display list of available options (--help-list-hidden for more) --version - Display the version of this program llvm-size Options: Specify output format -A - System V format -B - Berkeley format -m - Darwin -m format --arch=<string> - architecture(s) from a Mach-O file to dump --common - Print common symbols in the ELF file. When using Berkely format, this is added to bss. Print size in radix: -o - Print size in octal -d - Print size in decimal -x - Print size in hexadecimal --format=<value> - Specify output format =sysv - System V format =berkeley - Berkeley format =darwin - Darwin -m format -l - When format is darwin, use long format to include addresses and offsets. --radix=<value> - Print size in radix =8 - Print size in octal =10 - Print size in decimal =16 - Print size in hexadecimal --totals - Print totals of all objects - Berkeley format only Differential Revision: https://reviews.llvm.org/D62482 llvm-svn: 362593
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-192-8/+6
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* [binutils] NFC: fix clang-tidy warning: use empty() instead of size() == 0Jordan Rupprecht2018-12-201-1/+1
| | | | llvm-svn: 349710
* [llvm-size][libobject] Add explicit "inTextSegment" methods similar to ↵Jordan Rupprecht2018-12-131-2/+2
| | | | | | | | | | | | | | | | | | | | | "isText" section methods to calculate size correctly. Summary: llvm-size uses "isText()" etc. which seem to indicate whether the section contains code-like things, not whether or not it will actually go in the text segment when in a fully linked executable. The unit test added (elf-sizes.test) shows some types of sections that cause discrepencies versus the GNU size tool. llvm-size is not correctly reporting sizes of things mapping to text/data segments, at least for ELF files. This fixes pr38723. Reviewers: echristo, Bigcheese, MaskRay Reviewed By: MaskRay Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D54369 llvm-svn: 349074
* [llvm-size] Use empty() and range-based for loop. NFCFangrui Song2018-11-221-5/+5
| | | | llvm-svn: 347441
* [Support] Make error banner optional in logAllUnhandledErrorsJonas Devlieghere2018-11-111-2/+2
| | | | | | | | In a lot of places an empty string was passed as the ErrorBanner to logAllUnhandledErrors. This patch makes that argument optional to simplify the call sites. llvm-svn: 346604
* [llvm-size] Reject unknown radix valuesJames Henderson2018-10-301-4/+6
| | | | | | | | | | | | | | This addresses https://bugs.llvm.org/show_bug.cgi?id=39403 by making -radix an enumeration option with 8, 10, and 16 as the only accepted values. Reviewed by: jhenderson, MaskRay Differential Revision: https://reviews.llvm.org/D53799 Patch by Eugene Sharygin llvm-svn: 345588
* [llvm-size] Berkeley formatting: use tabs instead of spaces as field delimeters.Jordan Rupprecht2018-09-211-12/+18
| | | | | | This matches GNU behavior for size and allows use of cut to parse the output of llvm-size. llvm-svn: 342791
* [llvm-size] Make global variables staticFangrui Song2018-06-221-2/+2
| | | | llvm-svn: 335397
* Define InitLLVM to do common initialization all at once.Rui Ueyama2018-04-131-8/+2
| | | | | | | | | | | We have a few functions that virtually all command wants to run on process startup/shutdown. This patch adds InitLLVM class to do that all at once, so that we don't need to copy-n-paste boilerplate code to each llvm command's main() function. Differential Revision: https://reviews.llvm.org/D45602 llvm-svn: 330046
* Fix more inconsistent line endings. NFC.Dimitry Andric2017-12-181-7/+7
| | | | llvm-svn: 321016
* Add llvm::for_each as a range-based extensions to <algorithm> and make use ↵Aaron Ballman2017-11-031-8/+7
| | | | | | of it in some cases where it is a more clear alternative to std::for_each. llvm-svn: 317356
* [tools] Add option to install binutils symlinksShoaib Meenai2017-11-021-0/+4
| | | | | | | | | | | | The LLVM tools can be used as a replacement for binutils, in which case it's convenient to create symlinks with the binutils names. Add support for these symlinks in the build system. As with any other llvm tool symlinks, the user can limit the installed symlinks by only adding the desired ones to `LLVM_TOOLCHAIN_TOOLS`. Differential Revision: https://reviews.llvm.org/D39530 llvm-svn: 317272
* llvm-size: remove leading dash in '-radix' optionMehdi Amini2016-12-231-1/+1
| | | | | | cl::opt does not accept such option llvm-svn: 290466
* Fix a bugs with using some Mach-O command line flags like "-arch armv7m".Kevin Enderby2016-12-161-20/+20
| | | | | | | | | | | | | | | | | | 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
* Fix a bug with llvm-size and the -m option with multiple files not printing ↵Kevin Enderby2016-12-011-1/+3
| | | | | | the file names. llvm-svn: 288402
* Make the Error class constructor protectedMehdi Amini2016-11-111-4/+4
| | | | | | | | | 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
* Fix an unconditional break in checkMachOAndArchFlagsDavid Majnemer2016-10-311-26/+22
| | | | | | Found by PVS-Studio. llvm-svn: 285598
* Turn cl::values() (for enum) from a vararg function to using C++ variadic ↵Mehdi Amini2016-10-081-4/+3
| | | | | | | | | | | | | | | template The core of the change is supposed to be NFC, however it also fixes what I believe was an undefined behavior when calling: va_start(ValueArgs, Desc); with Desc being a StringRef. Differential Revision: https://reviews.llvm.org/D25342 llvm-svn: 283671
* llvm-size: Add --totals optionHemant Kulkarni2016-09-121-2/+39
| | | | | | Differential Revision: https://reviews.llvm.org/D24308 llvm-svn: 281233
* Add the first of what will be a long line of additional error checks for ↵Kevin Enderby2016-08-051-1/+1
| | | | | | | | | | | | | invalid Mach-O files. This is where an LC_SEGMENT load command has a fileoff field that extends past the end of the file. Also fix llvm-nm and llvm-size to remove the errorToErrorCode() call so error messages are printed. And needed to update a few test cases now that they do print the error messages just a bit differently. llvm-svn: 277845
* The next step along the way to getting good error messages for bad archives.Kevin Enderby2016-07-291-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | As mentioned in commit log for r276686 this next step is adding a new method in the ArchiveMemberHeader class to get the full name that does proper error checking, and can be use for error messages. To do this the name of ArchiveMemberHeader::getName() is changed to ArchiveMemberHeader::getRawName() to be consistent with Archive::Child::getRawName(). Then the “new” method is the addition of a new implementation of ArchiveMemberHeader::getName() which gets the full name and provides proper error checking. Which is mostly a rewrite of what was Archive::Child::getName() and cleaning up incorrect uses of llvm_unreachable() in the code which were actually just cases of errors in the input Archives. Then Archive::Child::getName() is changed to return Expected<> and use the new implementation of ArchiveMemberHeader::getName() . Also needed to change Archive::getMemoryBufferRef() with these changes to return Expected<> as well to propagate Errors up. As well as changing Archive::isThinMember() to return Expected<> . llvm-svn: 277177
* [Object] Re-apply r275316 now that I have the corresponding LLD patch ready.Lang Hames2016-07-141-30/+24
| | | | llvm-svn: 275361
* [Object] Revert r275316, Archive::child_iterator changes, while I update lld.Lang Hames2016-07-141-24/+30
| | | | | | Should fix the bots broken by r275316. llvm-svn: 275353
* [Object] Change Archive::child_iterator for better interop with Error/Expected.Lang Hames2016-07-131-30/+24
| | | | | | | | | | | | | | | | | | | | | | | 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). llvm-svn: 275316
* Finish cleaning up most of the error handling in libObject’s ↵Kevin Enderby2016-06-281-3/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. llvm-svn: 274079
* Search for llvm-symbolizer binary in the same directory as argv[0], beforeRichard Smith2016-06-091-1/+1
| | | | | | | looking for it along $PATH. This allows installs of LLVM tools outside of $PATH to find the symbolizer and produce pretty backtraces if they crash. llvm-svn: 272232
* Change llvm-objdump, llvm-nm and llvm-size when reporting an object file errorKevin Enderby2016-05-311-10/+50
| | | | | | | | | | | | | | | | | | | 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. llvm-svn: 271332
* Change llvm-objdump, llvm-nm and llvm-size when reporting an object file errorKevin Enderby2016-05-171-8/+45
| | | | | | | | | | | | | | | | | | | | | 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. llvm-svn: 269784
* Fix llvm-size to exit with non zero when it can’t open a file.Kevin Enderby2016-05-021-1/+5
| | | | | | rdar://26027819 llvm-svn: 268313
* MachO: remove weird ARM/Thumb interface from MachOObjectFileTim Northover2016-04-221-2/+2
| | | | | | | | | | | | | | | | Only one consumer (llvm-objdump) actually cared about the fact that there were two triples. Others were actively working around the fact that the Triple returned by getArch might have been invalid. As for llvm-objdump, it needs to be acutely aware of both Triples anyway, so being generic in the exposed API is no benefit. Also rename the version of getArch returning a Triple. Users were having to pass an unwanted nullptr to disambiguate the two, which was nasty. The only functional change here is that armv7m and armv7em object files no longer crash llvm-objdump. llvm-svn: 267249
* Thread Expected<...> up from createMachOObjectFile() to allow llvm-objdump ↵Kevin Enderby2016-04-061-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | to produce a real error message Produce the first specific error message for a malformed Mach-O file describing the problem instead of the generic message for object_error::parse_failed of "Invalid data was encountered while parsing the file”.  Many more good error messages will follow after this first one. This is built on Lang Hames’ great work of adding the ’Error' class for structured error handling and threading Error through MachOObjectFile construction. And making createMachOObjectFile return Expected<...> . So to to get the error to the llvm-obdump tool, I changed the stack of these methods to also return Expected<...> : object::ObjectFile::createObjectFile() object::SymbolicFile::createSymbolicFile() object::createBinary() Then finally in ParseInputMachO() in MachODump.cpp the error can be reported and the specific error message can be printed in llvm-objdump and can be seen in the existing test case for the existing malformed binary but with the updated error message. Converting these interfaces to Expected<> from ErrorOr<> does involve touching a number of places. To contain the changes for now use of errorToErrorCode() and errorOrToExpected() are used where the callers are yet to be converted. Also 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 comment: “// TODO: Actually report errors helpfully” and a call something like consumeError(ObjOrErr.takeError()) so the buggy code will not crash since needed to deal with the Error. Note there is one fix also needed to lld/COFF/InputFiles.cpp that goes along with this that I will commit right after this. So expect lld not to built after this commit and before the next one. llvm-svn: 265606
* [llvm-size] Implement --common optionHemant Kulkarni2016-03-281-0/+25
| | | | | | Differential Revision: http://reviews.llvm.org/D16820 llvm-svn: 264591
* [llvm-size] Remove variable used only once.Davide Italiano2016-02-131-8/+4
| | | | | | The use of auto and the name were very weird anyway. llvm-svn: 260789
* [llvm-size] Make error handling uniform.Davide Italiano2016-02-131-32/+9
| | | | llvm-svn: 260786
* This brings back commit r259578.Rafael Espindola2016-02-091-0/+20
| | | | | | | But now it follows the llvm style, uses an early return and doesn't include a file named 1.o. llvm-svn: 260293
* Fix name style.Rafael Espindola2016-02-091-30/+30
| | | | | | Functions start with a lower case, variables with an upper case. llvm-svn: 260287
* Update comment style.Rafael Espindola2016-02-091-14/+14
| | | | llvm-svn: 260286
* Revert "Correct size calculations for ELF files"Rafael Espindola2016-02-091-20/+0
| | | | | | | | | This reverts commit r259578. There are enough issues with this small patch that it is better to revert and then commit a fixed version (will be committed shortly). llvm-svn: 260285
* Fix a formatting problems with llvm-size and the -m option.Kevin Enderby2016-02-091-4/+6
| | | | | | | | | | It was using format() with a string for 64-bit types but was passed a 32-bit type in places when printing values for 32-bit Mach-O files. rdar://24542509 llvm-svn: 260243
* Correct size calculations for ELF filesHemant Kulkarni2016-02-021-0/+20
| | | | llvm-svn: 259578
OpenPOWER on IntegriCloud