summaryrefslogtreecommitdiffstats
path: root/llvm/test/tools/llvm-objcopy
Commit message (Collapse)AuthorAgeFilesLines
...
* Recommit "[llvm-objcopy][MachO] Implement a layout algorithm for executables"Seiya Nuta2019-08-191-0/+291
| | | | | | | | | | | | | | | | Summary: The layout algorithm for relocatable objects and for executable are somewhat different. This patch implements the latter one based on the algorithm in LLD (MachOFileLayout). Reviewers: alexshap, rupprecht, jhenderson Reviewed By: alexshap Subscribers: jakehehrlich, abrachet, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D65539 llvm-svn: 369301
* Revert r369230 and r369231Seiya Nuta2019-08-191-291/+0
| | | | | | | | | | Looks these commits break CI builds: - http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-gn/builds/4159 This commit reverts r369230 and r369231 (git coommit: 4a198a7 and dee9546). llvm-svn: 369234
* [llvm-objcopy][MachO] Implement a layout algorithm for executablesSeiya Nuta2019-08-191-0/+291
| | | | | | | | | | | | | | | | Summary: The layout algorithm for relocatable objects and for executable are somewhat different. This patch implements the latter one based on the algorithm in LLD (MachOFileLayout). Reviewers: alexshap, rupprecht, jhenderson Reviewed By: alexshap Subscribers: jakehehrlich, abrachet, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D65539 llvm-svn: 369231
* [llvm-objcopy] Allow 'protected' visibility to be set when usingChris Jackson2019-08-151-5/+7
| | | | | | | | | | add-symbol Reviewers: Maskray, rupprecht Differential Revision: https://reviews.llvm.org/D65891 llvm-svn: 368982
* [llvm-strip] Support --strip-sectionsWolfgang Pieb2019-08-081-0/+5
| | | | | | | | | | | llvm-objcopy already supports --strip-sections. It is a good fit for its alias llvm-strip to support it as well. Reviewers: rupprecht, jhenderson Differential Revision: https://reviews.llvm.org/D65787 llvm-svn: 368241
* [llvm-objcopy] - Fix the strip-dwo-groups.test.George Rimar2019-08-021-10/+17
| | | | | | | | | | It was reported (https://reviews.llvm.org/D65273#1612246) that this test fails if the compilation directory contain a "debug_" substring. This should fix it. llvm-svn: 367702
* [llvm-objcopy] - Stop using Inputs/alloc-symtab.oGeorge Rimar2019-07-305-19/+46
| | | | | | | | | | | | | | | | Initially Inputs/alloc-symtab.o was added in D42222. It contains an allocatable .symtab section. Today we are able to create such sections using yaml2obj. Later people started using this input for no solid reason in their tests. Now multiple of tests are using it. (And those tests do not need such a specific case actually). In this patch I removed this binary and rewrote the few tests. Differential revision: https://reviews.llvm.org/D65278 llvm-svn: 367310
* [llvm-objcopy] Improve --add-section argument string parsingSergey Dmitriev2019-07-292-4/+25
| | | | | | Differential Revision: https://reviews.llvm.org/D65346 llvm-svn: 367236
* [llvm-objcopy] - Reimplement strip-dwo-groups.test to stop using the ↵George Rimar2019-07-292-35/+71
| | | | | | | | | | | | | | | | precompiled object. When llvm-copy removes .dwo sections the index of symbol table, the indices of the symbols and the indices of the sections which go after the removed ones changes. That affects on SHT_GROUP sections, which needs to be updated. Initially this test used a precompiled object, I rewrote it to use YAML and improved a bit. Differential revision: https://reviews.llvm.org/D65273 llvm-svn: 367202
* [llvm-objcopy] Add support for --add-section for COFFSergey Dmitriev2019-07-261-0/+56
| | | | | | | | This patch enables support for --add-section=... option for COFF objects. Differential Revision: https://reviews.llvm.org/D65040 llvm-svn: 367130
* [llvm-objcopy] Allow strip symtab in executables and DSOsEugene Leviant2019-07-235-87/+24
| | | | | | | Re-commit of the patch after addressing -Wl,--emit-relocs case. Differential revision: https://reviews.llvm.org/D61672 llvm-svn: 366787
* llvm-objcopy/test: add REQUIRES: shell for use of umaskDavid Blaikie2019-07-222-0/+2
| | | | | | (follow-up to r365162) llvm-svn: 366755
* [test] [llvm-objcopy] Fix broken test caseAlex Brachet2019-07-191-8/+15
| | | | | | | | | | | | | | | | Summary: The test case added in D62718 did not work unless the user was root because write bits were not set for the output file. This change uses only permissions with user write (0200) to ensure tests pass regardless of the users permissions. Reviewers: jhenderson, rupprecht, MaskRay, espindola, alexshap Reviewed By: MaskRay Subscribers: emaste, arichardson, jakehehrlich, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64302 llvm-svn: 366527
* [llvm-objcopy] Don't change permissions of non-regular output filesFangrui Song2019-07-111-0/+6
| | | | | | | | | | | | | | | | | | | | | | There is currently an EPERM error when a regular user executes `llvm-objcopy a.o /dev/null`. Worse, root can even change the mode bits of /dev/null. Fix it by checking if the output file is special. A new overload of llvm::sys::fs::setPermissions with FD as the parameter is added. Users should provide `perm & ~umask` as the parameter if they intend to respect umask. The existing overload of llvm::sys::fs::setPermissions may be deleted if we can find an implementation of fchmod() on Windows. fchmod() is usually better than chmod() because it saves syscalls and can avoid race condition. Reviewed By: jakehehrlich, jhenderson Differential Revision: https://reviews.llvm.org/D64236 llvm-svn: 365753
* Revert [llvm-objcopy] Allow strip symtab from executables and DSOsJordan Rupprecht2019-07-106-25/+88
| | | | | | | | | | | | | This reverts r365193 (git commit 194f16b3548bcb23a7f0fd638778ed72edd18d37) This patch doesn't work with binaries built w/ `--emit-relocs`, e.g. ``` $ echo 'int main() { return 0; }' | clang -Wl,--emit-relocs -x c - -o foo && llvm-objcopy --strip-unneeded foo llvm-objcopy: error: 'foo': not stripping symbol '__gmon_start__' because it is named in a relocation ``` llvm-svn: 365712
* [llvm-objcopy] Allow strip symtab from executables and DSOsEugene Leviant2019-07-056-88/+25
| | | | | | Differential revision: https://reviews.llvm.org/D61672 llvm-svn: 365193
* [Object/ELF.h] - Improve error reporting.George Rimar2019-07-052-6/+10
| | | | | | | | | | | | | | | | | The errors coming from ELF.h are usually not very useful because they are uninformative. This patch is a first step to improve the situation. I tested this patch with a run of check-llvm and found that few messages are untested. In this patch, I did not add more tests but marked all such cases with a "TODO" comment. For all tested messages I extended the error text to provide more details (see test cases changed). Differential revision: https://reviews.llvm.org/D64014 llvm-svn: 365183
* [llvm-objcopy][test] Fix respect-umask.test after D62718/r365162Fangrui Song2019-07-051-14/+3
| | | | llvm-svn: 365172
* Fix patch not passing test casesAlex Brachet2019-07-051-4/+3
| | | | llvm-svn: 365170
* Temporarily stop failing test caseAlex Brachet2019-07-051-3/+3
| | | | llvm-svn: 365168
* [llvm-objcopy] Change handling of output file permissionsAlex Brachet2019-07-043-0/+125
| | | | | | | | | | | | | | | | Summary: Address bug [[ https://bugs.llvm.org/show_bug.cgi?id=42082 | 42082 ]] where files were always outputted with 0775 permissions. Now, the output file is given either 0666 or 0777 if the object is executable. Reviewers: espindola, alexshap, rupprecht, jhenderson, jakehehrlich, MaskRay Reviewed By: rupprecht, jhenderson, jakehehrlich, MaskRay Subscribers: emaste, arichardson, jakehehrlich, MaskRay, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D62718 llvm-svn: 365162
* [llvm-objcopy] - Get rid of dynrel.elf precompiled binary from inputs.George Rimar2019-06-213-20/+64
| | | | | | | | | | We do not have to spread using the precompiled binaries in the tests, when we can use YAML. This patch removes the dynrel.elf binary and adds a few comments to the test cases. Differential revision: https://reviews.llvm.org/D63641 llvm-svn: 364052
* [NFC][llvm-objcopy] Fix overly restrictive od output checkHubert Tong2019-06-192-6/+6
| | | | | | | | | | | | | | The check against the output of `od` in the affected tests expect a specific input offset format. They also expect a specific offset value, not consistent with the EXAMPLE section for `od` in POSIX.1-2017 Chapter 4, while using the `-j` option. In particular, the example shows that the input offset begins at 0 following the bytes skipped. This patch adjusts the matching of the input offset to be more generic. In order to avoid false matches, it restricts the number of bytes to be formatted. llvm-svn: 363829
* [llvm-readobj] Allow --hex-dump/--string-dump to dump multiple sectionsFangrui Song2019-06-182-0/+2
| | | | | | | | | | | | | | | | | | 1) `-x foo` currently dumps one `foo`. This change makes it dump all `foo`. 2) `-x foo -x foo` currently dumps `foo` twice. This change makes it dump `foo` once. In addition, if foo has section index 9, `-x foo -x 9` dumps `foo` once. 3) Give a warning instead of an error if `foo` does not exist. The new behaviors match GNU readelf. Also, print a new line as a separator between two section dumps. GNU readelf uses two lines, but one seems good enough. Reviewed By: grimar, jhenderson Differential Revision: https://reviews.llvm.org/D63475 llvm-svn: 363683
* [llvm-strip] Error when using stdin twiceAlex Brachet2019-06-181-0/+26
| | | | | | | | | | | | | | | | Summary: Implements bug [[ https://bugs.llvm.org/show_bug.cgi?id=42204 | 42204 ]]. llvm-strip now warns when the same input file is used more than once, and errors when stdin is used more than once. Reviewers: jhenderson, rupprecht, espindola, alexshap Reviewed By: jhenderson, rupprecht Subscribers: emaste, arichardson, jakehehrlich, MaskRay, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D63122 llvm-svn: 363638
* [llvm-objcopy] Add elf32-sparc and elf32-sparcel targetSeiya Nuta2019-06-171-0/+12
| | | | | | | | | | | | | | | | | | | Summary: The "sparc"/"sparcel" architectures appears in ArchMap (used by -B option) but not in OutputFormatMap (used by -I/-O option). Add their targets into OutputFormatMap for consistency. Note that AFAIK there're no targets for 32-bit little-endian SPARC ("elf32-sparcel") in GNU binutils. Reviewers: espindola, alexshap, rupprecht, jhenderson, compnerd, jakehehrlich Reviewed By: jhenderson, compnerd, jakehehrlich Subscribers: jyknight, emaste, arichardson, fedor.sergeev, jakehehrlich, MaskRay, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D63238 llvm-svn: 363524
* [objcopy] Error when --preserve-dates is specified with standard streamsAlex Brachet2019-06-151-0/+23
| | | | | | | | | | | | | | | | Summary: llvm-objcopy/strip now error when -p is specified when reading from stdin or writing to stdout Reviewers: jhenderson, rupprecht, espindola, alexshap Reviewed By: jhenderson, rupprecht Subscribers: emaste, arichardson, jakehehrlich, MaskRay, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D63090 llvm-svn: 363485
* [llvm-objcopy][IHEX] Improve test case formatting. NFCEugene Leviant2019-06-141-75/+88
| | | | | | Differential revision: https://reviews.llvm.org/D63258 llvm-svn: 363359
* [llvm-objcopy] Changed command line parsing errorsAlex Brachet2019-06-1410-16/+16
| | | | | | | | | | | | | | | | Summary: Tidied up errors during command line parsing to be more consistent with the rest of llvm-objcopy errors. Reviewers: jhenderson, rupprecht, espindola, alexshap Reviewed By: jhenderson, rupprecht Subscribers: emaste, arichardson, MaskRay, llvm-commits, jakehehrlich Tags: #llvm Differential Revision: https://reviews.llvm.org/D62973 llvm-svn: 363350
* [llvm-objcopy] Fix sparc target endiannessSeiya Nuta2019-06-131-2/+8
| | | | | | | | | | | | | | | | Summary: AFAIK, the "sparc" target is big endian and the target for 32-bit little-endian SPARC is denoted as "sparcel". This patch fixes the endianness of "sparc" target and adds "sparcel" target for 32-bit little-endian SPARC. Reviewers: espindola, alexshap, rupprecht, jhenderson Reviewed By: jhenderson Subscribers: jyknight, emaste, arichardson, fedor.sergeev, jakehehrlich, MaskRay, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D63251 llvm-svn: 363336
* [llvm-objcopy] Implement IHEX readerEugene Leviant2019-06-132-0/+218
| | | | | | | This is the final part of IHEX format support in llvm-objcopy Differential revision: https://reviews.llvm.org/D62583 llvm-svn: 363243
* [llvm-objcopy] Fix SHT_GROUP ordering.Jordan Rupprecht2019-06-104-20/+74
| | | | | | | | | | | | | | | | | | | | | Summary: When llvm-objcopy sorts sections during finalization, it only sorts based on the offset, which can cause the group section to come after the sections it contains. This causes link failures when using gold to link objects created by llvm-objcopy. Fix this for now by copying GNU objcopy's behavior of placing SHT_GROUP sections first. In the future, we may want to remove this sorting entirely to more closely preserve the input file layout. This fixes https://bugs.llvm.org/show_bug.cgi?id=42052. Reviewers: jakehehrlich, jhenderson, MaskRay, espindola, alexshap Reviewed By: MaskRay Subscribers: phuongtrang148993, emaste, arichardson, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D62620 llvm-svn: 362973
* [llvm-objcopy][MachO] Recompute and update offset/size fields in the writerSeiya Nuta2019-06-082-0/+29
| | | | | | | | | | | | | | | | | | | | Summary: Recompute and update offset/size fields so that we can implement llvm-objcopy options like --only-section. This patch is the first step and focuses on supporting load commands that covered by existing tests: executable files and dynamic libraries are not supported. Reviewers: alexshap, rupprecht, jhenderson Reviewed By: alexshap, rupprecht Subscribers: compnerd, jakehehrlich, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D62652 llvm-svn: 362863
* llvm-objcopy: Implement --extract-partition and --extract-main-partition.Peter Collingbourne2019-06-073-0/+215
| | | | | | | | | | | | | | | | | | | This implements the functionality described in https://lld.llvm.org/Partitions.html. It works as follows: - Reads the section headers using the ELF header at file offset 0; - If extracting a loadable partition: - Finds the section containing the required partition ELF header by looking it up in the section table; - Reads the ELF and program headers from the section. - If extracting the main partition: - Reads the ELF and program headers from file offset 0. - Filters the section table according to which sections are in the program headers that it read: - If ParentSegment != nullptr or section is not SHF_ALLOC, then it goes in. - Sections containing partition ELF headers or program headers are excluded as there are no headers for these in ordinary ELF files. Differential Revision: https://reviews.llvm.org/D62364 llvm-svn: 362818
* [llvm-objcopy] - Emit error and don't crash if program header reaches past ↵George Rimar2019-06-071-0/+45
| | | | | | | | | | | | | | | | end of file. This is https://bugs.llvm.org/show_bug.cgi?id=42122. If an object file has a size less than program header's file [offset + size] (i.e. if we have overflow), llvm-objcopy crashes instead of reporting a error. The patch fixes this issue. Differential revision: https://reviews.llvm.org/D62898 llvm-svn: 362778
* [test][llvm-objcopy] Test llvm-objcopy with standard streamsAlex Brachet2019-06-041-0/+6
| | | | | | Differential Revision: https://reviews.llvm.org/D62817 llvm-svn: 362556
* [llvm-ar] Reapply Fix relative thin archive path handlingOwen Reynolds2019-06-041-4/+4
| | | | | | | | | | Includes a fix for an introduced build failure due to a post c++11 use of std::mismatch. This fixes some thin archive relative path issues, paths are shortened where possible and paths are output correctly when using the display table command. Differential Revision: https://reviews.llvm.org/D59491 llvm-svn: 362484
* Revert "[llvm-ar] Fix relative thin archive path handling"Dmitri Gribenko2019-06-031-4/+4
| | | | | | | | | | This reverts commit r362407. It broke compilation of llvm/lib/Object/ArchiveWriter.cpp: error: type 'llvm::sys::path::const_iterator' does not provide a call operator llvm-svn: 362413
* [llvm-ar] Fix relative thin archive path handlingOwen Reynolds2019-06-031-4/+4
| | | | | | | | This fixes some thin archive relative path issues, paths are shortened where possible and paths are output correctly when using the display table command. Differential Revision: https://reviews.llvm.org/D59491 llvm-svn: 362407
* [llvm-objcopy] Remove %p format specifiersEugene Leviant2019-05-301-3/+3
| | | | | | | On 32-bit machines %p expects 32 bit values, however addresses in llvm-objcopy are always 64 bits. llvm-svn: 362074
* Yet another attempt to fix buildbot after r361949Eugene Leviant2019-05-291-3/+3
| | | | | | | Looks like %p format specifier of createStringError behaves differently on different platforms llvm-svn: 361993
* [llvm-objcopy] Implement IHEX writerEugene Leviant2019-05-295-0/+260
| | | | | | Differential revision: https://reviews.llvm.org/D60270 llvm-svn: 361949
* [llvm-objcopy] - Strip undefined symbols if they are no longer referenced ↵George Rimar2019-05-241-0/+60
| | | | | | | | | | | | | following --only-section This is https://bugs.llvm.org/show_bug.cgi?id=40004. In this patch I teach llvm-objcopy to remove undefined symbols if them are not used anymore after applying -j/--only-section option. Differential revision: https://reviews.llvm.org/D62317 llvm-svn: 361642
* [llvm-objcopy] Add file names to error messagesSeiya Nuta2019-05-2310-24/+28
| | | | | | | | | | | | | | | | | | | Summary: This patch adds the file names to llvm-objcopy error messages. It makes easy to identify which file causes an error. Bugzilla: https://bugs.llvm.org/show_bug.cgi?id=41798 Reviewers: espindola, alexshap, rupprecht, jhenderson, jakehehrlich Reviewed By: rupprecht, jhenderson, jakehehrlich Subscribers: emaste, arichardson, jakehehrlich, MaskRay, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D61993 llvm-svn: 361450
* [llvm-objcopy] Tidy up error messagesJames Henderson2019-05-2221-21/+21
| | | | | | | | | | | | | | This patch brings various error messages into line with each other, by removing trailing full stops, and making the first letter lower-case. This addresses https://bugs.llvm.org/show_bug.cgi?id=40859. Reviewed by: jhenderson, rupprecht, jakehehrlich Differential Revision: https://reviews.llvm.org/D62072 Patch by Alex Brachet llvm-svn: 361384
* [NFC] Remove a blank line (test commit)Seiya Nuta2019-05-221-1/+0
| | | | llvm-svn: 361349
* [llvm-objcopy] Strip file symbols with --strip-unneededEugene Leviant2019-05-211-10/+8
| | | | | | Differential revision: https://reviews.llvm.org/D61641 llvm-svn: 361231
* [llvm-objcopy] Add additional testing for various casesJames Henderson2019-05-1010-41/+497
| | | | | | | | | | | | | This patch adds a number of tests to test various cases not covered by existing tests. All of them work correctly, with no need to change llvm-objcopy itself, although some do indicate possible areas for improvement. Reviewed by: MaskRay Differential Revision: https://reviews.llvm.org/D61727 llvm-svn: 360422
* [NFC]Fix British English -> American English issuesJames Henderson2019-05-081-2/+2
| | | | llvm-svn: 360252
* [llvm-objcopy] Improve error message for unrecognised archive memberJames Henderson2019-05-081-0/+45
| | | | | | | | | | | | | | Prior to this patch, llvm-objcopy's error messages for archives with unsupported members only mentioned the archive name, not the member name, making them unhelpful. This change improves it by approximately following GNU objcopy's error message syntax of "<archive name>(<member name>): <problem>". Reviewed by: grimar Differential Revision: https://reviews.llvm.org/D61674 llvm-svn: 360251
OpenPOWER on IntegriCloud