summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-readobj
Commit message (Collapse)AuthorAgeFilesLines
* [llvm-readelf] Print EI_ABIVERSION as decimal instead of hexadecimalFangrui Song2020-01-061-2/+2
| | | | | | | | This matches GNU readelf and llvm-readobj. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D72234
* [llvm-readobj] - Remove an excessive helper for printing dynamic tags.Georgii Rymar2019-12-241-81/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [Tools] Fixes -Wrange-loop-analysis warningsMark de Wever2019-12-222-5/+5
| | | | | | This avoids new warnings due to D68912 adds -Wrange-loop-analysis to -Wall. Differential Revision: https://reviews.llvm.org/D71808
* [llvm-readob] - Refactor printing of sections flags. NFCI.Georgii Rymar2019-12-181-50/+54
| | | | | | | | This is a natural clean-up after D71462/D71464. It allows to define known section letters used for GNU style in one place. Differential revision: https://reviews.llvm.org/D71591
* [llvm-readelf] - Change letters used for SHF_ARM_PURECODE and ↵Georgii Rymar2019-12-181-10/+27
| | | | | | | | | | | | 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-181-27/+42
| | | | | | | | | | | | | | | | | 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/+4
| | | | | | | | | | | | | | 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][llvm-readelf] - Remove excessive empty lines when reporting ↵Georgii Rymar2019-12-111-2/+0
| | | | | | | | | | 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-112-6/+56
| | | | | | | | | | | | | | | | | | | | 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-101-42/+60
| | | | | | | | | | | | | | | | | | 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][llvm-readelf] - Refactor parsing of the SHT_GNU_versym section.Georgii Rymar2019-12-061-28/+118
| | | | | | | 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-063-0/+57
| | | | | | | | | | 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
* [llvm-readelf/llvm-readobj] - Remove getSecTypeName() helper.Georgii Rymar2019-12-051-16/+10
| | | | | | | We do not need it, we have `object::getELFSectionTypeName` that can be used instead. Differential revision: https://reviews.llvm.org/D71017
* [ELF] Support for PT_GNU_PROPERTY in header and toolsPeter Smith2019-12-041-0/+2
| | | | | | | | | | | | | 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
* [llvm-readobj/llvm-readelf] - Simplify the code that dumps versions.Georgii Rymar2019-12-021-131/+45
| | | | | | | | | | | | 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/+6
| | | | | | | | | | | | | | | 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-84/+168
| | | | | | | | | | 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/llvm-readobj] - Check version of SHT_GNU_verdef section ↵Georgii Rymar2019-11-291-0/+6
| | | | | | | | | | | | | | | | | 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-16/+24
| | | | | | | | | | | | 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-readobj] - Always print "Predecessors" for version definition sections.Georgii Rymar2019-11-271-3/+0
| | | | | | | | | | | | | 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-68/+149
| | | | | | | | | | | | 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] - Improve dumping of the SHT_LLVM_LINKER_OPTIONS sections.Georgii Rymar2019-11-201-6/+26
| | | | | | | 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-201-2/+2
| | | | | | | | | | | | | 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
* Using crtp to refactor the xcoff section headerdiggerlin2019-11-071-11/+2
| | | | | | | | | | | | | SUMMARY: According to https://reviews.llvm.org/D68575#inline-617586, Create a NFC patch for it. Using crtp to refactor the xcoff section header Move the define of SectionFlagsReservedMask and SectionFlagsTypeMask from XCOFFDumper.cpp to XCOFFObjectFile.h Reviewers: hubert.reinterpretcast,jasonliu Subscribers: rupprecht, seiyai,hiraditya Differential Revision: https://reviews.llvm.org/D69131
* [llvm-readobj] Change errors to warnings for symbol section name dumpingJames Henderson2019-11-041-15/+53
| | | | | | | | | | | | | | | 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/+48
| | | | | | | | | | | | | | | | | | | 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
* [NFC][llvm-readobj] Pull common code into a helperJames Henderson2019-11-011-18/+13
| | | | | | | | This will make planned changes to this code easier to make. Reviewed by: MaskRay, grimar Differential Revision: https://reviews.llvm.org/D69669
* [llvm-readelf/llvm-readobj] - Improve dumping of broken versioning sections.Georgii Rymar2019-10-311-11/+31
| | | | | | | | 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/Object] - Make ELFObjectFile::getRelocatedSection return ↵George Rimar2019-10-211-2/+10
| | | | | | | | | | | | | Expected<section_iterator> It returns just a section_iterator currently and have a report_fatal_error call inside. This change adds a way to return errors and handle them on caller sides. The patch also changes/improves current users and adds test cases. Differential revision: https://reviews.llvm.org/D69167 llvm-svn: 375408
* [llvm-readobj] - Refine the LLVM-style output to be consistent.George Rimar2019-10-172-4/+4
| | | | | | | | | | | | | | Our LLVM-style output was inconsistent. This patch changes the output in the following way: SHT_GNU_verdef { -> VersionDefinitions [ SHT_GNU_verneed { -> VersionRequirements [ Version symbols [ -> VersionSymbols [ EH_FRAME Header [ -> EHFrameHeader { Differential revision: https://reviews.llvm.org/D68636 llvm-svn: 375095
* [XCOFF]implement parsing relocation information for 32-bit xcoff object fileDigger Lin2019-10-151-1/+53
| | | | | | | | | | | | | | Summary: Parsing the relocation entry information for 32-bit xcoff object file including deal with the relocation overflow. Reviewers: hubert.reinterpretcast, jasonliu, sfertile, xingxue. Subscribers: hiraditya, rupprecht, seiya Differential Revision: https://reviews.llvm.org/D67008 llvm-svn: 374946
* [llvm-readobj][xcoff] implement parsing overflow section header.Digger Lin2019-10-151-20/+60
| | | | | | | | | | | | | | | SUMMARY: in the xcoff, if the number of relocation entries or line number entries is overflow(large than or equal 65535) , there will be overflow section for it. The interpret of overflow section is different with generic section header, the patch implement parsing the overflow section. Reviewers: hubert.reinterpretcast,sfertile,jasonliu Subscribers: rupprecht, seiya Differential Revision: https://reviews.llvm.org/D68575 llvm-svn: 374941
* [llvm-readobj] - Remove excessive fields when dumping "Version symbols".George Rimar2019-10-111-8/+1
| | | | | | | | | | | This removes a few fields that are not useful: "Section Name", "Address", "Offset" and "Link" (they duplicated the information available under the "Sections [" tag). Differential revision: https://reviews.llvm.org/D68704 llvm-svn: 374541
* [llvm-readelf] - Do not enter an infinite loop when printing histogram.George Rimar2019-10-101-1/+13
| | | | | | | | | | This is similar to D68086. We are entering an infinite loop when dumping a histogram for a specially crafted .hash section with a loop in a chain. Differential revision: https://reviews.llvm.org/D68771 llvm-svn: 374344
* [AIX][XCOFF][NFC] Change the SectionLen field name of CSect Auxiliary entry ↵Jason Liu2019-10-091-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | to SectionOrLength. Summary: According the the XCOFF document, If Then XTY_SD x_scnlen contains the csect length. XTY_LD x_scnlen contains the symbol table index of the containing csect. XTY_CM x_scnlen contains the csect length. XTY_ER x_scnlen contains 0. Change the SectionLen member name to SectionOrLength is more reasonable. Authored By: DiggerLin Reviewed By: hubert.reinterpretcast Differential Revision: https://reviews.llvm.org/D68650 llvm-svn: 374179
* [llvm-readelf/llvm-objdump] - Improve/refactor the implementation of ↵George Rimar2019-10-072-28/+58
| | | | | | | | | | | | | | | | | SHT_LLVM_ADDRSIG section dumping. This patch: * Adds a llvm-readobj/llvm-readelf test file for SHT_LLVM_ADDRSIG sections. (we do not have any) * Enables dumping of SHT_LLVM_ADDRSIG with --all. * Changes the logic to report a warning instead of an error when something goes wrong during dumping (allows to continue dumping SHT_LLVM_ADDRSIG and other sections on error). * Refactors a piece of logic to a new toULEB128Array helper which might be used for GNU-style dumping implementation. Differential revision: https://reviews.llvm.org/D68383 llvm-svn: 373890
* [llvm-readobj] Remove redundant semicolon. NFCSimon Atanasyan2019-10-041-1/+1
| | | | llvm-svn: 373735
* [llvm-readobj][mips] Inline `printMipsPLTGOT` methodSimon Atanasyan2019-10-041-17/+9
| | | | llvm-svn: 373733
* [llvm-readobj][mips] Implement GNU-style printing of .MIPS.abiflags sectionSimon Atanasyan2019-10-041-39/+81
| | | | | | | | In this patch `llvm-readobj` prints ASEs flags on a single line separated by a comma. GNU `readelf` prints each ASEs flag on a separate line. It will be fixed later. llvm-svn: 373732
* [llvm-readobj] Replace arch-specific ObjDumper methods by the single ↵Simon Atanasyan2019-10-043-35/+27
| | | | | | | | | | | | | | | `printArchSpecificInfo` Initially llvm-readobj supports multiple command line options like `--arm-attributes` and `--mips-plt-got` for display ELF arch-specific information. Now all these options are superseded by the `--arch-specific` one. It makes sense to have a single `printArchSpecificInfo` method in the base `ObjDumper`, and hide all ELF/target specific details in the `ELFDumper::printArchSpecificInfo` override. Differential Revision: https://reviews.llvm.org/D68385 llvm-svn: 373731
* [llvm-readobj][mips] Remove non-standard --misp-xxx flagsSimon Atanasyan2019-10-031-27/+0
| | | | | | | | llvm-readobj "non-standard" flags `--mips-plt-got`, `--mips-abi-flags`, `--mips-reginfo`, and `--mips-options` are superseded by the `--arch-specific` flag and can be removed now. llvm-svn: 373590
* [llvm-readobj][mips] Display MIPS specific info under --arch-specific flagSimon Atanasyan2019-10-031-1/+8
| | | | | | | Old options `--mips-plt-got`, `--mips-abi-flags`, '--mips-reginfo`, and `--mips-options` wiil be deleted in a separate patch. llvm-svn: 373588
* [llvm-readobj][mips] Do not show an error if GOT is missedSimon Atanasyan2019-10-031-1/+1
| | | | | | It is not an error if a file does not contain GOT. llvm-svn: 373587
* [llvm-readelf] - Report a warning when .hash section contains a chain with a ↵George Rimar2019-10-021-0/+11
| | | | | | | | | | | | cycle. It is possible to craft a .hash section that triggers an infinite loop in llvm-readelf code. This patch fixes the issue and introduces a warning. Differential revision: https://reviews.llvm.org/D68086 llvm-svn: 373476
* [llvm-readobj/llvm-readelf] Delete --arm-attributes (alias for --arch-specific)Fangrui Song2019-10-011-2/+0
| | | | | | | | | | | | | | | | D68110 added --arch-specific (supported by GNU readelf) and made --arm-attributes an alias for it. The tests were later migrated to use --arch-specific. Note, llvm-readelf --arch-specific currently just uses llvm-readobj style output for ARM attributes. The readelf-style output is not implemented. Reviewed By: compnerd, kongyi, rupprecht Differential Revision: https://reviews.llvm.org/D68196 llvm-svn: 373291
* [llvm-readobj] Rename --arm-attributes to --arch-specificYi Kong2019-09-271-5/+9
| | | | | | | | | This is for compatibility with GNU readobj. --arm-attributes option is left as a hidden alias due to large number of tests using it. Differential Revision: https://reviews.llvm.org/D68110 llvm-svn: 373125
* [llvm-readobj/llvm-readelf] - .stack_sizes: demangle symbol names in ↵George Rimar2019-09-251-30/+28
| | | | | | | | | | | | | | | warnings reported. I started this patch as a refactoring, tried to make a helper for getting symbol names, similar to how we get section names used in warning messages. So this patch cleanups the code and fixes an issue: symbol names in warning messages were not demangled. Differential revision: https://reviews.llvm.org/D68012 llvm-svn: 372867
* [llvm-readobj] - Don't crash when dumping .stack_sizes and unable to find a ↵George Rimar2019-09-251-1/+1
| | | | | | | | | | | | | | | relocation resolver. The crash might happen when we have either a broken or unsupported object and trying to resolve relocations when dumping the .stack_sizes section. For the test case I used a 32-bits ELF header and a 64-bit relocation. In this case a null pointer is returned by the code instead of the relocation resolver function and then we crash. Differential revision: https://reviews.llvm.org/D67962 llvm-svn: 372838
* [llvm-readobj] - Stop treating ".stack_sizes.*" sections as stack sizes ↵George Rimar2019-09-231-3/+3
| | | | | | | | | | | | | | | | sections. llvm-readobj currently handles .stack_sizes.* (e.g. .stack_sizes.foo) as a normal stack sizes section. Though MC does not produce sections with such names. Also, linkers do not combine .stack_sizes.* into .stack_sizes. A mini discussion about this correctness issue is here: https://reviews.llvm.org/D67757#inline-609274 This patch changes implementation so that only now only '.stack_sizes' name is accepted as a real stack sizes section. Differential revision: https://reviews.llvm.org/D67824 llvm-svn: 372578
OpenPOWER on IntegriCloud