summaryrefslogtreecommitdiff
path: root/test/Object
AgeCommit message (Collapse)Author
2017-05-14[COFF] Gracefully handle empty .drectve sectionsShoaib Meenai
Running `llvm-readobj -coff-directives msvcrt.lib` resulted in this error: Invalid data was encountered while parsing the file This happened because some of the object files in the archive have empty `.drectve` sections. These empty sections result in a `parse_failed` error being returned from `COFFObjectFile::getSectionContents()`, which in turn caused `llvm-readobj` to stop. With this change, `getSectionContents` now returns success, and like before the resulting array is empty. Patch by Dave Lee. Differential Revision: https://reviews.llvm.org/D32652 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303014 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-10[llvm-readobj] Improve errors on invalid binarySam Clegg
The previous code was discarding the error message from createBinary() by calling errorToErrorCode(). This meant that such error were always reported unhelpfully as "Invalid data was encountered while parsing the file". Other tools such as llvm-objdump already produce a more the error message in this case. Differential Revision: https://reviews.llvm.org/D32985 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302664 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-09[WebAssembly] Fix validation of start functionSam Clegg
The check for valid start function was inverted. Added a new test in test/Object to check this case and fixed the existing tests in for ObjectYAML. Differential Revision: https://reviews.llvm.org/D32986 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302560 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-05[llvm-ar] errors go on stderr and not on stdout.Davide Italiano
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299548 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-03Reland r298901 with modifications (reverted in r298932)Weiming Zhao
Dont emit Mapping symbols for sections that contain only data. Summary: Dont emit mapping symbols for sections that contain only data. Reviewers: rengolin, weimingz, kparzysz, t.p.northover, peter.smith Reviewed By: t.p.northover Patched by Shankar Easwaran <shankare@codeaurora.org> Subscribers: alekseyshl, t.p.northover, llvm-commits Differential Revision: https://reviews.llvm.org/D30724 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299392 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-31[AMDGPU] Fix typo in test filename. NFC.Konstantin Zhuravlyov
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299271 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-29Add ifunc support to ModuleSymbolTable.Rafael Espindola
Do that by creating a global_values, which is similar to global_objects, but also iterates over aliases and ifuncs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299018 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-28Revert "Dont emit Mapping symbols for sections that contain only data."Weiming Zhao
It breaks some lld tests. This reverts commit 3a50eea6d9732ab40e9a7aebe6be777b53a8b35c. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298932 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-28Dont emit Mapping symbols for sections that contain only data.Weiming Zhao
Summary: Dont emit mapping symbols for sections that contain only data. Patched by Shankar Easwaran <shankare@codeaurora.org> Reviewers: rengolin, peter.smith, weimingz, kparzysz, t.p.northover Reviewed By: t.p.northover Subscribers: t.p.northover, llvm-commits Differential Revision: https://reviews.llvm.org/D30724 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298901 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-14Archives require a symbol table on Solaris, even if empty.Rafael Espindola
On Solaris ld (and some other tools that use the underlying utility libraries, such as elfdump) chokes on an archive library that has no symbol table. The Solaris tools always create one, even if it's empty. That bug has been fixed in the latest development line, and can probably be backported to a supported release, but it would be nice if LLVM's archiver could emit the empty symbol table, too. Patch by Danek Duvall! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297773 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-22Write to a temporary file in test instead of random file in the test directory.Benjamin Kramer
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295815 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-21Don't modify archive members unless really needed.Rafael Espindola
For whatever reason ld64 requires that member headers (not the member themselves) should be aligned. The only way to do that is to edit the previous member so that it ends at an aligned boundary. Since modifying data put in an archive is an undesirable property, llvm-ar should only do it when it is absolutely necessary. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295765 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-09test: adjust the test for the BSD formatSaleem Abdulrasool
The padding for ld64 changes the header to include the padding. Adjust the test to account for this. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294619 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-09Object: pad out BSD archive members to 8-bytesSaleem Abdulrasool
ld64 requires its archive members to be 8-byte aligned for 64-bit content and 4-byte aligned for 32-bit content. Opt for the larger alignment requirement. This ensures that ld64 can consume archives generated by llvm-ar. Thanks to Kevin Enderby for the hint about the ld64/cctools behaviours! Resolves PR28361! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294615 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-07Fix a typo in an error message for a check of invalid Mach-O files whereKevin Enderby
it was printing the field name fileoff instead of filesize. The original check was added in r278557. This was found in tracking down the problem that lead to the fix in r293842 - [dsymutil] Fix __LINKEDIT vmsize in dsymutil upgrade path rdar://30386075 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294354 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-03Object: Handle files without a dynamic symbol table.Peter Collingbourne
Differential Revision: https://reviews.llvm.org/D29482 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294013 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-30Change the llvm-obdump(1) behavior with the -macho flag and inappropriate ↵Kevin Enderby
file types. To better match the old darwin otool(1) behavior, when llvm-obdump(1) is used with the -macho option and the input file is not an object file simply print the file name and this message: foo: is not an object file and continue on to process other input files. Also in this case don’t exit non-zero. This should help in some OSS projects' with autoconf scripts that are expecting the old darwin otool(1) behavior. rdar://26828015 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293547 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-26[obj2yaml] Produce correct output for invalid relocations.Davide Italiano
R_X86_64_NONE can be emitted without a symbol associated (well, in theory it should never be emitted in an ABI-compliant relocatable object). So, if there's no symbol associated to a reloc, emit one with an empty name, instead of crashing. Ack'ed by Michael Spencer offline. PR: 31768 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293224 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-19Add support for the new LC_NOTE load command.Kevin Enderby
It describes a region of arbitrary data included in a Mach-O file. Its initial use is to record extra data in MH_CORE files. rdar://30001545 rdar://30001731 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292500 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-16[Object] Fixup permissions of input files.Davide Italiano
They just need to be read/dumped, so no need to set the exec bit on any of them. NFCI, I guess. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292171 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-16[llvm-objdump] Dump PT_NOTE as part of -p.Davide Italiano
PR: 31641 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292170 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-16[llvm-objdump] Dump PT_GNU_RELRO as part of -p.Davide Italiano
PR: 31641 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292169 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-13Object: Make IRObjectFile own multiple modules and enumerate symbols from ↵Peter Collingbourne
all modules. This implements multi-module support in IRObjectFile. Differential Revision: https://reviews.llvm.org/D26951 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289578 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-09llvm/test/Object/archive-thin-create.test: Make sure that %t is empty to ↵NAKAMURA Takumi
stabilize the test. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289202 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-06[llvm-readobj] - Teach readobj to print PT_OPENBSD_BOOTDATA headerGeorge Rimar
These are OpenBSD specific program headers. OpenBSD commit: https://github.com/openbsd/src/commit/d39116912b9536bd77326260dc5c6e593fd4ee24 It is required for fixing PR31288. Differential revision: https://reviews.llvm.org/D27456 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288831 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-04Prefix path when displaying thin archives.Rafael Espindola
Patch by Mark Santaniello. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288615 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-30Only computeRelativePath() on new membersDavid Callahan
Summary: When using thin archives, and processing the same archive multiple times, we were mangling existing entries. The root cause is that we were calling computeRelativePath() more than once. Here, we only call it when adding new members to an archive. Note that D27218 changes the way thin archives are printed, and will break the new unit test included here. Depending on which one lands first, the other will need to be slightly modified. Reviewers: rafael, davide Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D27217 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288280 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-28Add error checking for Mach-O universal files.Kevin Enderby
Add the checking for both the MachO::fat_header and the MachO::fat_arch struct values in the constructor for MachOUniversalBinary. Such that when the constructor for ObjectForArch is called it can assume the values in the MachO::fat_arch for the offset and size are contained in the file after the MachOUniversalBinary constructor is called for the Parent. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288084 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-23llvm-nm: Don't print value or size for undefined or weak symbolsMeador Inge
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287802 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-16[ELF] Convert ELF.h to Expected<T>.Davide Italiano
This has two advantages: 1) We slowly move away from ErrorOr to the new handling interface, in the hope of having an uniform error handling in LLVM, eventually. 2) We're starting to have *meaningful* error messages for invalid object ELF files, rather than a generic "parse error". At some point we should include also the offset to improve the quality of the diagnostic. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287081 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-15Object: replace backslashes with slashes in embedded relative thin archive ↵Peter Collingbourne
paths on Windows. This makes these thin archives portable between *nix and Windows. Differential Revision: https://reviews.llvm.org/D26696 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287038 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-03Add error handling to getEntry.Rafael Espindola
Issue found by inspection. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285951 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-03Replace a report_fatal_error with an ErrorOr.Rafael Espindola
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285942 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-03replace a report_fatal_error with a ErrorOr.Rafael Espindola
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285910 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-02Add the rest of the additional error checks for invalid Mach-O files whenKevin Enderby
the offsets and sizes of an element of the Mach-O file overlaps with another element in the Mach-O file. Some other tests for malformed Mach-O files now run into these checks so their tests were also adjusted. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285860 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-02Avoid a report_fatal_error in sections().Rafael Espindola
Have it return a ErrorOr<Range> and delete section_begin and section_end. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285807 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-01Don't compute DotShstrtab eagerly.Rafael Espindola
This saves a field that is not always used. It also avoids failing a program that doesn't need the section names. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285753 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-01Use the existing std::error_code out parameter.Rafael Espindola
This avoids calling exit with a partially constructed object. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285738 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-31More additional error checks for invalid Mach-O files whenKevin Enderby
the offsets and sizes of an element of the file overlaps with another element in the Mach-O file. This shows the approach to this testing for three elements and contains for tests for their overlap. Checking for all the remain elements will be added next. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285632 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-31Recommit r285285 - [Object/ELF] - Fixed behavior when ↵George Rimar
SectionHeaderTable->sh_size is too large. with fix: edited invalid-section-index2.elf input to pass the new check and fail on the same place it was intended to fail. Original commit message: Elf.h already has code checking that section table does not go past end of file. Problem is that this check may not work on values greater than UINT64_MAX / Header->e_shentsize because of calculation overflow. Parch fixes the issue. Differential revision: https://reviews.llvm.org/D25432 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285586 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-27Another additional error check for invalid Mach-O files for theKevin Enderby
obsolete load commands. Again the philosophy of the error checking in libObject for Mach-O files, the idea behind the checking is that we never will return a Mach-O file out of libObject that contains unknown things the library code can’t operate on. So known obsolete load commands will cause a hard error. Also to make things clear I have added comments to the values and structures in Support/Mach-O.h and Support/MachO.def as to what is obsolete. As noted in a TODO in the code, there may need to be a non-default mode to allow some unknown values for well structured Mach-O files with things like unknown load load commands. So things like using an old lldb on a newer Mach-O file could still provide some limited functionality. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285342 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-27Revert r285285 "[Object/ELF] - Fixed behavior when ↵George Rimar
SectionHeaderTable->sh_size is too large." It broke BB. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285288 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-27[Object/ELF] - Fixed behavior when SectionHeaderTable->sh_size is too large.George Rimar
Elf.h already has code checking that section table does not go past end of file. Problem is that this check may not work on values greater than UINT64_MAX / Header->e_shentsize because of calculation overflow. Parch fixes the issue. Differential revision: https://reviews.llvm.org/D25432 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285285 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-27[Object/ELF] - Do not allow overflow when checking section size/offset.George Rimar
Overflow was the reason of incorrect passing the check, patch fixes the case. Differentail revision: https://reviews.llvm.org/D25514 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285284 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-27[Object/ELF] - Do not crash if string table sh_size is equal to zero.George Rimar
Revealed using "id_000038,sig_11,src_000015,op_havoc,rep_16" from PR30540, when sh_size was 0, crash happened. Differential revision: https://reviews.llvm.org/D25091 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285282 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-26llvm-objdump: Make some error messages more consistentJustin Bogner
Most of the version of report_error were quoting the filename and printing a colon between the file name and the error message, but this one wasn't doing either of those. Fix the output to be more consistent. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285252 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-26Use printf instead of "echo -e" or "echo -n".Rui Ueyama
Not all echo commands support "-e". On the other hand, printf command is in POSIX, so it's more portable than "echo -e". git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285151 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-24nother additional error check for an invalid Mach-O fileKevin Enderby
when contained in a Mach-O universal file and the cputypes in both headers don’t match. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285026 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-20Another additional error check for invalid Mach-O files for theKevin Enderby
load commands that use the MachO::twolevel_hints_command type which includes only the LC_TWOLEVEL_HINTS load command. This is not used in llvm libObject code or in llvm tool code. But does appear in one of the binary test files. While this load command is obsolete it is easier to add code for it in libObject than edit or change the binary test case. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284769 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-19Next set of additional error checks for invalid Mach-O files for theKevin Enderby
load commands that use the MachO::thread_command type but are not used in llvm libObject code but used in llvm tool code. This includes the LC_UNIXTHREAD and LC_THREAD load commands. A quick note about the philosophy of the error checking in libObject for Mach-O files, the idea behind the checking is that we never will return a Mach-O file out of libObject that contains unknown things in the load commands. To do this the 32-bit ARM and PPC general tread states needed to be defined as two test case binaries contained them. If other thread states for other CPUs need to be added we will do that as needed. Going forward the LC_MAIN load command is used to set the entry point in Mach-O executables these days instead of an LC_UNIXTHREAD as was done in the past. So today only in core files are LC_THREAD load commands and thread states usually found. Other thread states have not yet been defined in include/Support/MachO.h at this time. But that can be added as needed with their corresponding checking also added. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284668 91177308-0d34-0410-b5e6-96231b3b80d8