summaryrefslogtreecommitdiffstats
path: root/llvm/test/tools/llvm-nm
Commit message (Collapse)AuthorAgeFilesLines
...
* [WebAssembly] Add first claass symbol table to wasm objectsSam Clegg2018-02-233-107/+118
| | | | | | | | | | | | | | | | | | | | This is combination of two patches by Nicholas Wilson: 1. https://reviews.llvm.org/D41954 2. https://reviews.llvm.org/D42495 Along with a few local modifications: - One change I made was to add the UNDEFINED bit to the binary format to avoid the extra byte used when writing data symbols. Although this bit is redundant for other symbols types (i.e. undefined can be implied if a function or global is a wasm import) - I prefer to be explicit and consistent and not have derived flags. - Some field renaming. - Some reverting of unrelated minor changes. - No test output differences. Differential Revision: https://reviews.llvm.org/D43147 llvm-svn: 325860
* llvm-nm should show a symbol type of T for symbols in the ↵Kevin Enderby2018-01-313-0/+6
| | | | | | | | | | | | | | | (__TEXT_EXEC,__text) section. When a the Apple link editor builds a kext bundle file type and the value of the -miphoneos-version-min argument is significantly current (like 11.0) then the (__TEXT,__text) section is changed to the (__TEXT_EXEC,__text) section. So it would be nice for llvm-nm to show symbols in that section with a type of T instead of the generic type of S for some section other than text, data, etc. rdar://36262205 llvm-svn: 323836
* [WebAssembly] Remove debug names from symbol tableSam Clegg2018-01-172-0/+31
| | | | | | | | | | | | | | | | | | | | | | | | | Get rid of DEBUG_FUNCTION_NAME symbols. When we actually debug data, maybe we'll want somewhere to put it... but having a symbol that just stores the name of another symbol seems odd. It means you have multiple Symbols with the same name, one containing the actual function and another containing the name! Store the names in a vector on the WasmObjectFile when reading them in. Also stash them on the WasmFunctions themselves. The names are //not// "symbol names" or aliases or anything, they're just the name that a debugger should show against the function body itself. NB. The WasmObjectFile stores them so that they can be exported in the YAML losslessly, and hence the tests can be precise. Enforce that the CODE section has been read in before reading the "names" section. Requires minor adjustment to some tests. Patch by Nicholas Wilson! Differential Revision: https://reviews.llvm.org/D42075 llvm-svn: 322741
* [WebAssembly] Explicitly specify function/global index space in YAMLSam Clegg2018-01-093-22/+31
| | | | | | | | | | | These indexes are useful because they are not always zero based and functions and globals are referenced elsewhere by their index. This matches what we already do for the type index space. Differential Revision: https://reviews.llvm.org/D41877 llvm-svn: 322121
* Do not look up symbol names when n_strx == 0Michael Trent2018-01-032-0/+15
| | | | | | | | | | | | | | | | | | | | | | Summary: Historical tools for working with mach-o binaries verify the nlist field n_strx has a non-zero value before using that value to retrieve symbol names. Under some cirumstances, llvm-nm will attempt to display the symbol name at position 0, even though symbol names at that position are not well defined. This change addresses this problem by returning an empty string when n_strx is zero. rdar://problem/35750548 Reviewers: enderby, davide Reviewed By: enderby, davide Subscribers: davide, llvm-commits, JDevlieghere Differential Revision: https://reviews.llvm.org/D41657 llvm-svn: 321773
* [WebAssembly] Use bitfield types in wasm YAML representationSam Clegg2017-12-131-4/+4
| | | | | | Differential Revision: https://reviews.llvm.org/D41202 llvm-svn: 320642
* [llvm-nm] Don't error out on multiple occurrances of the -g/--external-only flagMartin Storsjo2017-11-031-0/+1
| | | | | | | | | | | GNU binutils nm doesn't error out on this, and some projects' build systems can end up doing that in some cases. Allowing that seems like a better target than trying to avoid user projects passing multiple -g parameters to $NM. Differential Revision: https://reviews.llvm.org/D39539 llvm-svn: 317301
* [llvm-nm] Print 'I' for import table data in COFFMartin Storsjo2017-11-031-0/+2
| | | | | | | | | | | | | | | | | | | | | | The character gets uppercased into 'I' when it's a global symbol. In GNU binutils, nm prints 'I' for symbols classified by bfd_is_ind_section - which probably isn't exactly/only import tables. When building for win32, (some incarnations of?) libtool has got rules that try to inspect linked libraries, and in order to be sure that it is linking to a DLL import library as opposed to a static library, it expects to find the string " I " in the output of $NM when run on such an import library. GNU binutils nm also flags all of the .idata$X chunks as 'i' (while this patch only makes it set on .idata$2 and .idata$6) and also flags __imp__function as 'I'. Differential Revision: https://reviews.llvm.org/D39540 llvm-svn: 317300
* [WebAssembly] Allow each data segment to specify its own alignmentSam Clegg2017-09-293-3/+0
| | | | | | | | | Also, add a flags field as we will almost certainly be needing that soon too. Differential Revision: https://reviews.llvm.org/D38296 llvm-svn: 314534
* [WebAssembly] Add support for local symbol bindingsSam Clegg2017-09-201-0/+8
| | | | | | Differential Revision: https://reviews.llvm.org/D38096 llvm-svn: 313817
* Fix a crash in llvm-nm for a bad Mach-O file that has an N_SECT type symbol ↵Kevin Enderby2017-09-132-0/+8
| | | | | | | | | | | | | | and a zero n_sect value. The code in llvm-nm for Mach-O files to determine the section type for an N_SECT type symbol it will call getSymbolSection() and check for the error, but in the case the n_sect value is zero it will return section_end() (aka nullptr). And the code was using that and crashing instead of just returning a ’s’ for a section or printing (?,?) as it would if getSymbolSection() returned an error. rdar://33136604 llvm-svn: 313193
* [WebAssembly] Only treat imports/exports as symbols when reading relocatable ↵Sam Clegg2017-09-063-4/+12
| | | | | | | | | | | | | | | | | | | object files This change only treats imported and exports functions and globals as symbol table entries the object has a "linking" section (i.e. it is relocatable object file). In this case all globals must be of type I32 and initialized with i32.const. This was previously being assumed but not checked for and was causing a failure on big endian machines due to using the wrong value of then union. See: https://bugs.llvm.org/show_bug.cgi?id=34487 Differential Revision: https://reviews.llvm.org/D37497 llvm-svn: 312674
* [WebAssembly] Fix getSymbolValue for exported globalsSam Clegg2017-09-013-7/+20
| | | | | | | | | | | | The code wasn't previously taking into account that the global index space is not same as the into in the Globals array since the latter does not include imported globals. This fixes the WebAssembly waterfall failures. Differential Revision: https://reviews.llvm.org/D37384 llvm-svn: 312340
* [WebAssembly] Fix getSymbolValue() for data symbolsSam Clegg2017-08-312-2/+2
| | | | | | | | | | This is mostly a fix for the output of `llvm-nm` See Bug 34392: https://bugs.llvm.org//show_bug.cgi?id=34392 Differential Revision: https://reviews.llvm.org/D37359 llvm-svn: 312294
* [WebAssembly] Validate exports when parsing object filesSam Clegg2017-08-312-0/+38
| | | | | | | | Subscribers: jfb, dschuff, jgravelle-google, aheejin Differential Revision: https://reviews.llvm.org/D37358 llvm-svn: 312286
* [llvm-nm] Fix output formatting of -f sysv for 64bit targetsSam Clegg2017-08-313-0/+19
| | | | | | Differential Revision: https://reviews.llvm.org/D37347 llvm-svn: 312284
* llvm-nm: Add support for symbol demangling (-C/--demangle)Sam Clegg2017-06-291-0/+37
| | | | | | Differential Revision: https://reviews.llvm.org/D34668 llvm-svn: 306718
* [WebAssembly] Add data size and alignement to linking sectionSam Clegg2017-06-271-0/+2
| | | | | | | | | The overal size of the data section (including BSS) is otherwise not included in the wasm binary. Differential Revision: https://reviews.llvm.org/D34657 llvm-svn: 306459
* [WebAssembly] Add support for weak symbols in the binary formatSam Clegg2017-06-202-4/+56
| | | | | | | | | | | This also introduces the updated format for the "linking" section which can represent extra symbol information. See: https://github.com/WebAssembly/tool-conventions/pull/10 Differential Revision: https://reviews.llvm.org/D34019 llvm-svn: 305769
* Change llvm-nm for Mach-O files to use dyld info in some cases when printing ↵Kevin Enderby2017-06-192-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | symbols. In order to reduce swift binary sizes, Apple is now stripping swift symbols from the nlist symbol table. llvm-nm currently only looks at the nlist symbol table and misses symbols that are present in dyld info. This makes it hard to know the set of symbols for a binary using just llvm-nm. Unless you know to run llvm-objdump -exports-trie that can output the exported symbols in the dyld info from the export trie, which does so but in a different format. Also moving forward the time may come a when a fully linked Mach-O file that uses dyld will no longer have an nlist symbol table to avoid duplicating the symbol information. This change adds three flags to llvm-nm, -add-dyldinfo, -no-dyldinfo, and -dyldinfo-only. The first, -add-dyldinfo, has the same effect as when the new bit in the Mach-O header, MH_NLIST_OUTOFSYNC_WITH_DYLDINFO, appears in a binary. In that it looks through the dyld info from the export trie and adds symbols to be printed that are not already in its internal SymbolList variable. The -no-dyldinfo option turns this behavior off. The -dyldinfo-only option only looks at the dyld information and recreates the symbol table from the dyld info from the export trie and binding information. As if it the Mach-O file had no nlist symbol table. Also fixed a few bugs with Mach-O N_INDR symbols not correctly printing the indirect name, or in the same format as the old nm-classic program. rdar://32021551 llvm-svn: 305733
* Print symbols from COFF import libraries.Rafael Espindola2017-05-242-0/+7
| | | | | | | | | This change allows llvm-nm to print symbols found in import libraries, in part by allowing COFFImportFiles to be casted to SymbolicFiles. Patch by Dave Lee! llvm-svn: 303821
* [WebAssembly] Improve readobj and nm support for wasmSam Clegg2017-04-143-0/+49
| | | | | | | | | Now that the libObect support for wasm is better we can have readobj and nm produce more useful output too. Differential Revision: https://reviews.llvm.org/D31514 llvm-svn: 300365
* Change the test added in r293099 so it does not have the string "llvm-nm" to fixKevin Enderby2017-01-251-1/+1
| | | | | | the clang-x86-windows-msvc2015 bot as the name is "llvm-nm.EXE" in that case. llvm-svn: 293114
* Add a warning when the llvm-nm -print-size flag is used on a Mach-O file asKevin Enderby2017-01-253-0/+5
| | | | | | | | | | | | Mach-O files don’t have size information about the symbols in the object file format unlike ELF. Also add the part of the fix to llvm-nm that was missed with r290001 so -arch armv7m works. rdar://25681018 llvm-svn: 293099
* llvm-nm: Print correct symbol types for init and fini sectionsMeador Inge2016-11-232-0/+8
| | | | | | | | | This patch fixes a small bug where symbols defined in the INIT and FINI sections were incorrectly getting a type of 'n'. Differential Revision: https://reviews.llvm.org/D26937 llvm-svn: 287803
* llvm-nm: Don't print value or size for undefined or weak symbolsMeador Inge2016-11-232-0/+6
| | | | | | | | | | | | | | | | | Undefined and weak symbols don't have a meaningful size or value. As such, nothing should be printed for those attributes (this is already done for the address with 'U') with the BSD format. This matches what GNU nm does. Note that for the POSIX.2 format [1] zero values are still printed for the size and value. This seems in spirit with the format strings in that specification, but is debatable. [1] http://pubs.opengroup.org/onlinepubs/9699919799/ Differential Revision: https://reviews.llvm.org/D26936 llvm-svn: 287802
* 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
* Fix some bugs in the posix output of llvm-nm. Which is documented onKevin Enderby2016-03-294-5/+10
| | | | | | | | | | | | | | http://pubs.opengroup.org/onlinepubs/9699919799/utilities/nm.html . 1) For Mach-O files the code was not printing the values in hex as is the default. 2) The values printed had leading zeros which they should not have. 3) The address for undefined symbols was printed as spaces instead of 0. 4) With the -A option with posix output for an archive did not use square brackets around the archive member name. rdar://25311883 and rdar://25299678 llvm-svn: 264778
* [llvm-nm] Correct -P ELF outputJames Molloy2016-03-242-0/+4
| | | | | | Correctly add a space between the address and size when outputting in posix mode (-P). llvm-svn: 264247
* Make llvm-nm test consistent with other testsHemant Kulkarni2016-02-103-85/+84
| | | | llvm-svn: 260464
* [llvm-nm] Add -radix optionHemant Kulkarni2016-02-103-0/+267
| | | | | | Differential Revision: http://reviews.llvm.org/D16822 llvm-svn: 260392
* [llvm-nm] Remove redundant check for file validity.Davide Italiano2016-01-271-0/+2
| | | | | | | | 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
* Fix llvm-nm(1) printing of llvm-bitcode files for -format darwin to match ↵Kevin Enderby2015-11-103-0/+18
| | | | | | | | darwin’s nm(1). Also a small fix to match printing of Mach-O objects with -format posix. llvm-svn: 252567
* Allow llvm-nm’s single letter command line flags to be grouped.Kevin Enderby2015-11-021-0/+5
| | | | | | | | | | 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-303-0/+6
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
OpenPOWER on IntegriCloud