summaryrefslogtreecommitdiffstats
path: root/llvm/test/tools/llvm-readobj
Commit message (Collapse)AuthorAgeFilesLines
* [ELF][PowerPC] Support R_PPC_COPY and R_PPC64_COPYFangrui Song2020-01-241-0/+3
| | | | | | | | Reviewed By: Bdragon28, jhenderson, grimar, sfertile Differential Revision: https://reviews.llvm.org/D73255 (cherry picked from commit f1dab29908d25a4044abff6ffc120c48b20f034d)
* [llvm-readobj][llvm-readelf][test] - Add a few more dynamic section tests.Georgii Rymar2020-01-141-135/+428
| | | | | | | | | | | | This adds a few more tests for dynamic section. We only had tests for simple unknown values for 64-bits target, in this patch I've added OS specific and processor specific tags. Also it tests both 32 and 64-bits targets now. It will help to fix the formatting issues we have and diagnose a possible new ones. Differential revision: https://reviews.llvm.org/D71896
* [llvm-readobj][test] - Fix grammar in comments.Georgii Rymar2020-01-142-2/+2
| | | | This addresses post commit review comments for D71766.
* [llvm-readelf] Print EI_ABIVERSION as decimal instead of hexadecimalFangrui Song2020-01-062-6/+6
| | | | | | | | This matches GNU readelf and llvm-readobj. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D72234
* [llvm-readobj][llvm-objdump][test] - Improve dynamic section testing.Georgii Rymar2019-12-272-230/+234
| | | | | | | This adds --strict-whitespace --match-full-lines flags to improve the testing and reveal formatting issues we have. Differential revision: https://reviews.llvm.org/D71895
* [llvm-readobj] - Merge `gnu-symbols.test` to `symbols.test` and cleanup.Georgii Rymar2019-12-254-91/+109
| | | | | | | | | | | | | | | | This cleans up and merges `gnu-symbols.test` to `symbols.test`. Initially `gnu-symbols.test` tested the following things: 1) How symbols are printed in GNU style. It does not make sense to have a separate file for such tests. 2) It tried to test proc-specific symbol indexes. The test was incomplete and also we already have `symbol-shndx.test` for that, so this part was removed. 3) It tested `--dyn-symbols` and `--symbols` correlation. All following cases were moved to `symbols.test`: a) That `--dyn-symbols` does not trigger showing regular symbols.. b) That `--symbols` triggers `--dyn-symbols` implicitly. c) That `--dyn-symbols` and `--symbols` works fine together. Differential revision: https://reviews.llvm.org/D71697
* [llvm-readobj/llvm-readelf][test] - Add testing for EI_OSABI and ↵Georgii Rymar2019-12-252-0/+352
| | | | | | | | EI_ABIVERSION fields of an ELF header. We had no separate tests for these fields. Differential revision: https://reviews.llvm.org/D71766
* [llvm-readobj] - Remove an excessive helper for printing dynamic tags.Georgii Rymar2019-12-241-65/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This removes the `getTypeString` from readeobj source because it almost duplicates the existent method: `ELFFile<ELFT>::getDynamicTagAsString`. Side effect: now it prints "<unknown:>0xHEXVALUE" instead of "(unknown)" for unknown values. llvm-readelf before this patch printed: ``` 0x0000000012345678 (unknown) 0x8765432187654321 0x000000006abcdef0 (unknown) 0x9988776655443322 0x0000000076543210 (unknown) 0x5555666677778888 ``` and now it prints: ``` 0x0000000012345678 (<unknown:>0x12345678) 0x8765432187654321 0x000000006abcdef0 (<unknown:>0x6abcdef0) 0x9988776655443322 0x0000000076543210 (<unknown:>0x76543210) 0x5555666677778888 ``` GNU reaedlf prints different thing: ``` 0x0000000012345678 (<unknown>: 12345678) 0x8765432187654321 0x000000006abcdef0 (Operating System specific: 6abcdef0) 0x9988776655443322 0x0000000076543210 (Processor Specific: 76543210) 0x5555666677778888 ``` I am not sure we want to follow GNU here. Even if we do, it should be separate patch probably. The new output looks better and closer to GNU anyways, and the code is a bit simpler. Differential revision: https://reviews.llvm.org/D71835
* [llvm-readobj][test] - Stop using Inputs/trivial.obj.elf-x86-64.Georgii Rymar2019-12-236-114/+179
| | | | | | | | This rewrites a few tests to stop using the trivial.obj.elf-x86-64 precompiled object and removes it. Differential revision: https://reviews.llvm.org/D71662
* [llvm-readobj][test] - Improve dyn-symbols.test.Georgii Rymar2019-12-193-187/+183
| | | | | | | | | This removes the precompiled binary used, simplifies the first test case, adds comments and llvm-readelf tool invocations. It also adds a test case for checking versioning symbols. Differential revision: https://reviews.llvm.org/D71595
* [llvm-readobj][test] - Refactor mips-st-other.testGeorgii Rymar2019-12-194-25/+39
| | | | | | | This removes 2 precompiled binaries, adds testing for STO_* flags missing, refines and renames the test. Differential revision: https://reviews.llvm.org/D71651
* [llvm-readobj][llvm-objdump] - Cleanup testing of dynamic tags dumping.Georgii Rymar2019-12-192-393/+310
| | | | | | | | | | | | | | | | | | We have the `elf-dynamic-tags-machine-specific.yaml` input shared between the llvm-readobj and llvm-objdump test. It looks strange, because tools usually does not share inputs. Also there are following problems related: 1) `elf-dynamic-tags-machine-specific.yaml` input contains excessive YAML parts. 2) objdump's test case never test AARCH64 tags. 3) There are unknown tags in the `elf-dynamic-tags-machine-specific.yaml` and `dynamic-tags-machine-specific.test`, though we already testing unknown tags in `\llvm-readobj\ELF\dynamic-tags.test` and `llvm-objdump\elf-dynamic-section.test` tests. This patch removes the shared input and refines the test cases to resolve issues mentioned. Differential revision: https://reviews.llvm.org/D71602
* [llvm-readobj][test] - Move a comment. NFC.Georgii Rymar2019-12-181-2/+2
| | | | I've forgot to address this review comment.
* [llvm-readobj][test] - Cleanup hash-histogram.testGeorgii Rymar2019-12-181-26/+86
| | | | | | | | | | | | | In this test case we use 3 precompiled objects to test how we print a histogram for an GNU hash section. It does not make sense to use precompiled objects for that. Also we could have 2 tests: one for 32 and another for 64 bits target. This patch does this change. It is not possible to remove these precompiled objects because they are used elsewhere. Differential revision: https://reviews.llvm.org/D71606
* [llvm-readelf] - Change letters used for SHF_ARM_PURECODE and ↵Georgii Rymar2019-12-183-41/+85
| | | | | | | | | | | | SHF_X86_64_LARGE flags. GNU uses `l` for SHF_X86_64_LARGE and `y` for SHF_ARM_PURECODE. Lets follow. To do this I had to refactor and refine how we print the help flags description. It was too generic and inconsistent with GNU readelf. Differential revision: https://reviews.llvm.org/D71464
* [llvm-readelf][llvm-readobj] - Reimplement the logic of section flags dumping.Georgii Rymar2019-12-183-5/+172
| | | | | | | | | | | | | | | | | Our logic that dumped the flags was buggy. For LLVM style it dumped SHF_MASKPROC/SHF_MASKOS named constants, though they are not flags, but masks. For GNU style it was just very inconsistent with GNU which has logic that is not straightforward. Imagine we have sh_flags == 0x90000000. SHF_EXCLUDE ("E") has a value of 0x80000000 and SHF_MASKPROC is 0xf0000000. GNU readelf will not print "E" or "Ep" in this case, but will print just "p". It only will print "E" when no other processor flag is set. I had to investigate the GNU source to find the algorithm and now our logic should match it. Differential revision: https://reviews.llvm.org/D71462
* [llvm-readobj] - Fix letters used for dumping section types in GNU style.Georgii Rymar2019-12-131-3/+123
| | | | | | | | | | | | | | I've noticed that when we have all regular flags set, we print "WAEXMSILoGTx" instead of "WAXMSILOGTCE" printed by GNU readelf. It happens because: 1) We print SHF_EXCLUDE at the wrong place. 2) We do not recognize SHF_COMPRESSED, we print "x" instead of "C". 3) We print "o" instead of "O" for SHF_OS_NONCONFORMING. This patch fixes differences and adds test cases. Differential revision: https://reviews.llvm.org/D71418
* [llvm-readobj][test] - Add a test for testing regular section flags and ↵Georgii Rymar2019-12-125-76/+148
| | | | | | | | | | | | | | cleanup flags testing. This: 1) Adds a test for testing all section flags (`section-flags.test`). 2) Renames `sec-flags.test`->`section-arch-flags.test` and performs a clean up. 3) Removes `compression.zlib.style.elf-x86-64` binary and a test case for SHF_COMPRESSED flag, because them are now excessive. 4) Adds missing MIPS flags and a test for SHF_ARM_PURECODE. Differential revision: https://reviews.llvm.org/D71333
* [llvm-readobj][test] - Cleanup and split tests in tools/llvm-readobj folder.Georgii Rymar2019-12-1228-2088/+2180
| | | | | | | | | | | | | tools/llvm-readobj currently contains tests that are either general for all file types or that mix file types inside. This patch refactors these test and leaves only general tests in that folder. All other tests were moved to ELF/COFF/MachO and wasm accordingly. I tried to minimize amount of changes, so most of the test parts remained unchanged. Any further refactorings and improvements for particular tests should be done independently from this patch. Differential revision: https://reviews.llvm.org/D71269
* [llvm-readobj][llvm-readelf] - Remove excessive empty lines when reporting ↵Georgii Rymar2019-12-118-127/+94
| | | | | | | | | | errors and warnings. After recent changes it is now seems possible to get rid of printing '\n' before each error and warning. This makes the output cleaner. Differential revision: https://reviews.llvm.org/D71246
* [llvm-readelf] - Do no print an empty symbol version as "<corrupt>"Georgii Rymar2019-12-111-1/+1
| | | | | | | | | | | | | It is discussed here https://reviews.llvm.org/D71118#inline-643172 Currently when a version is empty, llvm-readelf prints: "000: 0 (*local*) 2 (<corrupt>)" But GNU readelf does not treat empty section as corrupt. There is no sense in having empty versions anyways it seems, but this change is for consistency with GNU. Differential revision: https://reviews.llvm.org/D71243
* [llvm-readobj] Fix/improve printing WinEH unwind info for linked PE imagesMartin Storsjö2019-12-113-0/+349
| | | | | | | | | | | | | | | | | | | | ARMWinEHPrinter was already designed to handle linked PE images (since d2941b43f40d), but resolving symbols didn't consistently take the image base into account (as linked images seldom have a symbol table, except for in MinGW setups). Win64EHDumper wasn't really designed to handle linked images (it would crash if executed on such a file), but a few concepts (getSymbol, taking a virtual address instead of a relocation, and getSectionContaining for finding the section containing a certain virtual address) can be borrowed from ARMWinEHPrinter. Adjust ARMWinEHPrinter to print the address of the exception handler routine as a VA instead of an RVA, consistently with other addresses in the same printout, and make Win64EHDumper print addresses similarly for image cases. Differential Revision: https://reviews.llvm.org/D71303
* [llvm-readelf/llvm-readobj] - Improved the error reporting in a few method ↵Georgii Rymar2019-12-103-13/+73
| | | | | | | | | | | | | | | | | | related to versioning. I was investigating a change previously discussed that eliminates an excessive empty lines from the output when we report warnings and errors (https://reviews.llvm.org/D70826#inline-639055) and found that we need this refactoring or alike to achieve that. The problem is that some of our functions that finds symbol versions just fail instead of returning errors or printing warnings. Another problem is that they might print a warning on the same line with the regular output. In this patch I've splitted getting of the version information and dumping of it for GNU printVersionSymbolSection(). I had to change a few methods to return Error or Expected<> to do that properly. Differential revision: https://reviews.llvm.org/D71118
* [llvm-readobj][test] - Move platform specific test cases and their inputs to ↵Georgii Rymar2019-12-10314-1283/+66
| | | | | | | | | | | | separate folders. This creates the next subfolders in the test directory: "COFF", "ELF", "MachO", "wasm". I've also removed platform specific prefixes, like "coff-*". One unused binary was removed as well: `Inputs/relocs.obj.elf-mips` Differential revision: https://reviews.llvm.org/D71203
* [test][tools] Add missing and improve testingJames Henderson2019-12-095-13/+403
| | | | | | | | | | | Mostly this adds testing for certain aliases in more explicit ways. There are also a few tidy-ups, and additions of missing testing, where the feature was either not tested at all, or not tested explicitly and sufficiently. Reviewed by: MaskRay, rupprecht, grimar Differential Revision: https://reviews.llvm.org/D71116
* [llvm-readobj][llvm-readelf] - Refactor parsing of the SHT_GNU_versym section.Georgii Rymar2019-12-064-3/+225
| | | | | | | This introduce a new helper which is used to parse the SHT_GNU_versym section. LLVM/GNU styles implementations now use it to share the logic. Differential revision: https://reviews.llvm.org/D71054
* [llvm-readobj] - Implement --dependent-libraries flag.Georgii Rymar2019-12-061-0/+74
| | | | | | | | | | There is no way to dump SHT_LLVM_DEPENDENT_LIBRARIES sections currently. This patch implements this. The section is described here: https://llvm.org/docs/Extensions.html#sht-llvm-dependent-libraries-section-dependent-libraries Differential revision: https://reviews.llvm.org/D70665
* [ELF] Support for PT_GNU_PROPERTY in header and toolsPeter Smith2019-12-041-0/+17
| | | | | | | | | | | | | The PT_GNU_PROPERTY is generated by a linker to describe the .note.gnu.property section. The Linux kernel uses this program header to locate the .note.gnu.property section. It is described in "The Linux gABI extension" Include support for llvm-readelf, llvm-readobj and the yaml reader and writers. Differential Revision: https://reviews.llvm.org/D70959
* [Object/ELF] - Refine the error reported when section's offset + size ↵Georgii Rymar2019-12-032-2/+2
| | | | | | | | | | | | | | | overruns the file buffer. This is a follow-up requested in comments for D70826. It changes the message from "section X has a sh_offset (Y) + sh_size (Z) that cannot be represented" to "section X has a sh_offset (Y) + sh_size (Z) that is greater than the file size (0xABC)" when section's sh_offset + sh_size overruns a file buffer. Differential revision: https://reviews.llvm.org/D70893
* [llvm-readobj/llvm-readelf] - Simplify the code that dumps versions.Georgii Rymar2019-12-022-22/+121
| | | | | | | | | | | | After changes introduced in D70495 and D70826 its now possible to significantly simplify the code we have. This also fixes an issue: previous code assumed that version strings should always be read from the dynamic string table. While it is normally true, the string table should be taken from the corresponding sh_link field. Differential revision: https://reviews.llvm.org/D70855
* [llvm-readelf/llvm-readobj] - Check the version of SHT_GNU_verneed section ↵Georgii Rymar2019-12-021-0/+31
| | | | | | | | | | | | | | | entries. It is a follow-up for D70826 and it is similar to D70810. SHT_GNU_verneed contains the following fields: `vn_version`: Version of structure. This value is currently set to 1, and will be reset if the versioning implementation is incompatibly altered. (https://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/symversion.html) We should check it for correctness. Differential revision: https://reviews.llvm.org/D70842
* [llvm-readobj/llvm-readelf] - Reimplement dumping of the SHT_GNU_verneed ↵Georgii Rymar2019-12-021-14/+222
| | | | | | | | | | section. This is similar to D70495, but for SHT_GNU_verneed section. It solves the same problems: different implementations, lack of error reporting and no test coverage. DIfferential revision: https://reviews.llvm.org/D70826
* [llvm-readelf][test] - Update comment in elf-verdef-invalid.test. NFC.Georgii Rymar2019-11-291-1/+1
| | | | | It was suggested to change it during review of D70810, but I've forgotten to update it before commit.
* [llvm-readelf/llvm-readobj] - Check version of SHT_GNU_verdef section ↵Georgii Rymar2019-11-291-7/+35
| | | | | | | | | | | | | | | | | entries when dumping. Elfxx_Verdef contains the following field: vd_version Version revision. This field shall be set to 1. (https://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/symversion.html) Our code should check the struct version for correctness. This patch does that. (This will help to simplify or eliminate ELFDumper<ELFT>::LoadVersionDefs() which has it's own logic to parse version definitions for no reason. It checks the struct version currently). Differential revision: https://reviews.llvm.org/D70810
* [llvm-readelf] - Make GNU style dumping of invalid SHT_GNU_verdef be ↵Georgii Rymar2019-11-281-5/+5
| | | | | | | | | | | | consistent with LLVM style. When we dump SHT_GNU_verdef section that has sh_link that references a non-existent section, llvm-readobj reports a warning and continues dump, but llvm-readelf fails with a error. This patch fixes the issue and opens road for futher follow-ups for improving the printGNUVersionSectionProlog(). Differential revision: https://reviews.llvm.org/D70776
* [llvm-readelf][llvm-readobj][test] - Cleanup test cases for versioning sections.Georgii Rymar2019-11-283-237/+239
| | | | | | | | | | | | | | | | | | Currently we have 2 tests for testing versioning sections: 1) elf-versioninfo.test 2) elf-invalid-versioning.test The first one currently checks how versioning sections are dumped + how tools dump invalid SHT_GNU_verdef section. The second despite of its name contains only tests for invalid SHT_GNU_verneed section. In this patch I`ve renamed elf-invalid-versioning.test->elf-verneed-invalid.test, and moved a few tests from elf-versioninfo.test to a new elf-verdef-invalid.test. It will help to maintain these and a new tests for broken versioning sections. Differential revision:
* [llvm-readobj] - Always print "Predecessors" for version definition sections.Georgii Rymar2019-11-271-0/+6
| | | | | | | | | | | | | This is a follow-up discussed in D70495 thread. The current logic is unusual for llvm-readobj. It doesn't print predecessors list when it is empty. This is not good for machine parsers. D70495 had to add this condition during refactoring to reduce amount of changes, in tests, because the original code also had a similar logic. Now seems it is time to get rid of it. This patch does it. Differential revision: https://reviews.llvm.org/D70717
* [llvm-readobj/llvm-readelf] - Reimplement dumping of the SHT_GNU_verdef section.Georgii Rymar2019-11-261-4/+240
| | | | | | | | | | | | Currently we have following issues: 1) We have 2 different implementations with a different behaviors for GNU/LLVM styles. 2) Errors are either not handled at all or we call report_fatal_error with not helpfull messages. 3) There is no test coverage even for those errors that are reported. This patch reimplements parsing of the SHT_GNU_verdef section entries in a single place, adds a few error messages and test coverage. Differential revision: https://reviews.llvm.org/D70495
* [llvm-readobj][test] - Cleanup the many-sections.s test case.Georgii Rymar2019-11-263-27/+47
| | | | | | | It removes 2 precompiled binaries used which are now can be crafted with the use of yaml2obj. Differential revision: https://reviews.llvm.org/D70711
* [llvm-readobj] - Improve dumping of the SHT_LLVM_LINKER_OPTIONS sections.Georgii Rymar2019-11-201-7/+36
| | | | | | | I've added a few tests that shows how the current code could overrun the section data buffer while dumping. I had to rewrite the code to fix this. Differential revision: https://reviews.llvm.org/D70112
* [llvm-readobj/llvm-readelf] - Improve dumping of versioning sections.Georgii Rymar2019-11-202-36/+143
| | | | | | | | | | | | | Our elf-versioninfo.test is not perfect. It does not properly test how flags are dumped and also we have a bug: they are dumped as enums in LLVM style now, i.e not dumped properly. GNU style uses a `versionFlagToString` method to build a string from flags which seems is consistent with GNU readelf. In this patch I fixed the issues mentioned. Differential revision: https://reviews.llvm.org/D70399
* [llvm-readelf/llvm-readobj][test] - Convert elf-linker-options.ll to use YAML.Georgii Rymar2019-11-122-12/+30
| | | | | | | | | This converts elf-linker-options.ll to use yaml2obj instead of llc, improves and cleanups it a bit. This opens a road to add an additional tests for checking the broken cases. Differential revision: https://reviews.llvm.org/D70004
* [llvm-readobj] - Simplify elf-hash-symbols.test. NFCI.Georgii Rymar2019-11-071-10/+24
| | | | | | | | It converts binary contents of .hash and .gnu.hash that were generated by a linker to YAML descriptions. I've also dropped Shift2 and BloomFilter values because they are not needed here. Differential revision: https://reviews.llvm.org/D69881
* [llvm-readobj] Change errors to warnings for symbol section name dumpingJames Henderson2019-11-042-15/+183
| | | | | | | | | | | | | | | Also only print each such warning once. LLVM-style output will now print "<?>" for sections it cannot identify, e.g. because the section index is invalid. GNU output continues to print the raw index. In both cases where the st_shndx value is SHN_XINDEX and the index cannot be looked up in the SHT_SYMTAB_SHNDX section (e.g. because it is missing), the symbol is printed like other symbols with st_shndx >= SHN_LORESERVE. Reviewed by: grimar, MaskRay Differential Revision: https://reviews.llvm.org/D69671
* [NFC][llvm-readobj] Split getSectionIndexName function into twoJames Henderson2019-11-011-36/+33
| | | | | | | | | | | | | | | | | | | getSectionIndexName was trying to fetch two things at once, which led to a somewhat tricky to understand interface involving passing output parameters in, and also made it hard to return Errors further up the stack. This change is in preparation for changing the error handling. Additionally, update a related test now that yaml2obj supports SHT_SYMTAB_SHNDX properly (see d3963051c490), and add missing LLVM-style coverage for symbols with shndx SHN_XINDEX. This test (after fixing) caught a mistake in my first attempt at this patch, hence I'm including it as part of this patch. Reviewed by: grimar, MaskRay Differential Revision: https://reviews.llvm.org/D69670
* [yaml2obj/obj2yaml] - Add support for SHT_GNU_HASH section.georgerim2019-10-311-0/+1
| | | | | | | This adds parsing and dumping support for GNU hash sections. They are described nicely here: https://blogs.oracle.com/solaris/gnu-hash-elf-sections-v2 Differential revision: https://reviews.llvm.org/D69399
* [llvm-readelf/llvm-readobj] - Improve dumping of broken versioning sections.Georgii Rymar2019-10-311-33/+302
| | | | | | | | This updates the elf-invalid-versioning.test test case: makes a cleanup, adds llvm-readobj calls and fixes 2 crash/assert issues I've found (test cases are provided). Differential revision: https://reviews.llvm.org/D68705
* [llvm-readobj] - Fix a comment in stack-sizes.test. NFC.Georgii Rymar2019-10-291-1/+1
| | | | To address post commit review comment for D69167.
* [yaml2obj] - Make .symtab to be not mandatory section for SHT_REL[A] section.Georgii Rymar2019-10-292-1/+1
| | | | | | | | | | | | | | Before this change .symtab section was required for SHT_REL[A] section declarations. yaml2obj automatically defined it in case when YAML document did not have it. With this change it is now possible to produce an object that has a relocation section, but has no symbol table. It simplifies the code and also it is inline with how we handle Link fields for another special sections. Differential revision: https://reviews.llvm.org/D69260
* [yaml2obj, obj2yaml] - Add support for SHT_NOTE sections.georgerim2019-10-252-4/+9
| | | | | | | | | | | | | | | | | | | | | SHT_NOTE is the section that consists of namesz, descsz, type, name + padding, desc + padding data. This patch teaches yaml2obj, obj2yaml to dump and parse them. This patch implements the section how it is described here: https://docs.oracle.com/cd/E23824_01/html/819-0690/chapter6-18048.html Which says: "For 64–bit objects and 32–bit objects, each entry is an array of 4-byte words in the format of the target processor" The official specification is different http://www.sco.com/developers/gabi/latest/ch5.pheader.html#note_section And says: "n 64-bit objects (files with e_ident[EI_CLASS] equal to ELFCLASS64), each entry is an array of 8-byte words in the format of the target processor. In 32-bit objects (files with e_ident[EI_CLASS] equal to ELFCLASS32), each entry is an array of 4-byte words in the format of the target processor" Since LLVM uses the first, 32-bit way, this patch follows it. Differential revision: https://reviews.llvm.org/D68983
OpenPOWER on IntegriCloud