summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-objcopy
Commit message (Collapse)AuthorAgeFilesLines
...
* [llvm-objcopy] Allow the visibility of symbols created by --binary andChris Jackson2019-08-308-23/+57
| | | | | | --add-symbol to be specified with --new-symbol-visibility llvm-svn: 370458
* [llvm-objcopy] Strip debug sections when running with --strip-unneeded.Jordan Rupprecht2019-08-231-1/+1
| | | | | | | | | | | | | | | | | | | Summary: GNU --strip-unneeded strips debugging sections as well. Do that for llvm-objcopy as well. Additionally, add a test that verifies we keep the .gnu_debuglink section. This apparently was not always the case, and I'm not sure which commit fixed it, but there doesn't appear to be any test coverage to make sure we continue to do so. This fixes PR41043. Reviewers: jhenderson, jakehehrlich, espindola, alexshap Subscribers: emaste, arichardson, MaskRay, abrachet, seiya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D66623 llvm-svn: 369761
* Fight a bit against global initializers. NFC.Benjamin Kramer2019-08-221-1/+1
| | | | llvm-svn: 369695
* [llvm-objcopy][NFC] Refactor symbol/section matchingJordan Rupprecht2019-08-224-44/+58
| | | | | | | | | | | | | | | | | | | Summary: The matchers for section/symbol related flags (e.g. `--keep-symbol=Name` or `--regex --keep-symbol=foo.*`) are currently just vectors that are matched linearlly. However, adding wildcard support would require negative matching too, e.g. a symbol should be removed if it matches a wildcard *but* doesn't match some other wildcard. To make the next patch simpler, consolidate matching logic to a class defined in CopyConfig that takes care of matching. Reviewers: jhenderson, seiya, MaskRay, espindola, alexshap Reviewed By: jhenderson, MaskRay Subscribers: emaste, arichardson, jakehehrlich, abrachet, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D66432 llvm-svn: 369689
* [llvm-objcopy] Append '\n' to warning messagesFangrui Song2019-08-201-1/+1
| | | | | | | | | | | | | Currently the warning message of `llvm-strip %t.o %t.o` does not include the trailing newline. Fix this by appending a '\n'. This is the only warning llvm-objcopy and llvm-strip can issue. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D66475 llvm-svn: 369391
* Fix MSVC "result of 32-bit shift implicitly converted to 64 bits" warning. NFCI.Simon Pilgrim2019-08-201-1/+2
| | | | llvm-svn: 369366
* [llvm-objcopy][MachO] Fix method names. NFC.Seiya Nuta2019-08-201-2/+2
| | | | | | | | | | | | | | Reviewers: alexshap, rupprecht, jhenderson Reviewed By: alexshap, rupprecht Subscribers: jakehehrlich, abrachet, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D65540 llvm-svn: 369346
* Recommit "[llvm-objcopy][MachO] Implement a layout algorithm for executables"Seiya Nuta2019-08-191-20/+46
| | | | | | | | | | | | | | | | 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
* Recommit "[llvm-objcopy][MachO] Support load commands used in ↵Seiya Nuta2019-08-199-210/+560
| | | | | | | | | | | | | | | | | | | | | executables/shared libraries" Summary: This patch implements copying some load commands that appear in executables/shared libraries such as the indirect symbol table. I don't add tests intentionally because this patch is incomplete: we need a layout algorithm for executables/shared libraries. I'll submit it as a separate patch with tests. Reviewers: alexshap, rupprecht, jhenderson, compnerd Reviewed By: alexshap Subscribers: abrachet, mgorny, mgrang, MaskRay, mtrent, jakehehrlich, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D63395 llvm-svn: 369298
* [Object/COFF.h] - Stop returning std::error_code in a few methods. NFCI.George Rimar2019-08-191-12/+4
| | | | | | | | | | There are 4 methods that return std::error_code now, though they do not have to because they are always succeed. I refactored them. This allows to simplify the code in tools a bit. llvm-svn: 369263
* Revert r369230 and r369231Seiya Nuta2019-08-199-586/+210
| | | | | | | | | | 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-20/+46
| | | | | | | | | | | | | | | | 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][MachO] Support load commands used in executables/shared librariesSeiya Nuta2019-08-199-210/+560
| | | | | | | | | | | | | | | | | | | Summary: This patch implements copying some load commands that appear in executables/shared libraries such as the indirect symbol table. I don't add tests intentionally because this patch is incomplete: we need a layout algorithm for executables/shared libraries. I'll submit it as a separate patch with tests. Reviewers: alexshap, rupprecht, jhenderson, compnerd Reviewed By: alexshap Subscribers: abrachet, mgorny, mgrang, MaskRay, mtrent, jakehehrlich, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D63395 llvm-svn: 369230
* [llvm] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-155-17/+17
| | | | | | | | Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. llvm-svn: 369013
* [llvm-objcopy] Allow 'protected' visibility to be set when usingChris Jackson2019-08-152-1/+2
| | | | | | | | | | add-symbol Reviewers: Maskray, rupprecht Differential Revision: https://reviews.llvm.org/D65891 llvm-svn: 368982
* [llvm-objcopy] Move duplicate tablegen from objcopy and strip into one fileMichael Pozulp2019-08-153-191/+155
| | | | | | | | | | | | | | | | Summary: This avoids maintaining the same options in two different places. Reviewers: jhenderson, alexshap, rupprecht, MaskRay Reviewed By: jhenderson, rupprecht, MaskRay Subscribers: MaskRay, wolfgangp, jakehehrlich, abrachet, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D65991 llvm-svn: 368961
* [llvm-strip] Support --strip-sectionsWolfgang Pieb2019-08-082-0/+4
| | | | | | | | | | | 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] Improve --add-section argument string parsingSergey Dmitriev2019-07-292-5/+11
| | | | | | Differential Revision: https://reviews.llvm.org/D65346 llvm-svn: 367236
* [llvm-objcopy] Add support for --add-section for COFFSergey Dmitriev2019-07-262-24/+54
| | | | | | | | 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-233-1/+27
| | | | | | | Re-commit of the patch after addressing -Wl,--emit-relocs case. Differential revision: https://reviews.llvm.org/D61672 llvm-svn: 366787
* [llvm-objcopy] Don't change permissions of non-regular output filesFangrui Song2019-07-111-2/+13
| | | | | | | | | | | | | | | | | | | | | | 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-103-25/+1
| | | | | | | | | | | | | 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-053-1/+25
| | | | | | Differential revision: https://reviews.llvm.org/D61672 llvm-svn: 365193
* [llvm-objcopy][NFC] Refactor output target parsing v2Seiya Nuta2019-07-054-36/+90
| | | | | | | | | | | | | | | | | | | | | Summary: Use an enum instead of string to hold the output file format in Config.InputFormat and Config.OutputFormat. It's essential to support other output file formats other than ELF. This patch originally has been submitted as D63239. However, there was an use-of-uninitialized-value bug and reverted in r364379 (git commit 4ee933c). This patch includes the fix for the bug by setting Config.InputFormat/Config.OutputFormat in parseStripOptions. Reviewers: espindola, alexshap, rupprecht, jhenderson Reviewed By: jhenderson Subscribers: emaste, arichardson, jakehehrlich, MaskRay, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64170 llvm-svn: 365173
* Fix patch not passing test casesAlex Brachet2019-07-051-1/+2
| | | | llvm-svn: 365170
* [llvm-objcopy] Change handling of output file permissionsAlex Brachet2019-07-041-10/+26
| | | | | | | | | | | | | | | | 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: silence warning introduced in r364296Nicolai Haehnle2019-06-262-2/+6
| | | | | Change-Id: I306e866d497e55945fb3b471eb0727b63ad9e4b9 llvm-svn: 364460
* Revert [llvm-objcopy][NFC] Refactor output target parsingRumeet Dhindsa2019-06-264-86/+36
| | | | | | | | | | | | | | | | This reverts r364254 (git commit 545f001d1b9a7b58a68d75e70bfc36c841de8999) This change causes some llvm-obcopy tests to fail with valgrind. Following is the output for basic-keep.test Command Output (stderr): -- ==107406== Conditional jump or move depends on uninitialised value(s) ==107406== at 0x1A30DD: executeObjcopy(llvm::objcopy::CopyConfig const&) (llvm-objcopy.cpp:235) ==107406== by 0x1A3935: main (llvm-objcopy.cpp:294) llvm-svn: 364379
* Revert [llvm-objcopy][NFCI] Fix build failure with GCCRumeet Dhindsa2019-06-261-2/+0
| | | | | | | | | | | | This reverts r364263 (git commit 81eb82840524818ec0ec14285c866c09b9634df0) This commit is related to r364254 which is causing some llvm-objcopy tests to fail with valgrind. Error: Conditional jump or move depends on uninitialised value(s) llvm-svn: 364378
* [llvm-objcopy][llvm-strip] Fix help text typo for --allow-broken-linksJames Henderson2019-06-252-2/+2
| | | | llvm-svn: 364307
* AMDGPU/MC: Add .amdgpu_lds directiveNicolai Haehnle2019-06-252-13/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The directive defines a symbol as an group/local memory (LDS) symbol. LDS symbols behave similar to common symbols for the purposes of ELF, using the processor-specific SHN_AMDGPU_LDS as section index. It is the linker and/or runtime loader's job to "instantiate" LDS symbols and resolve relocations that reference them. It is not possible to initialize LDS memory (not even zero-initialize as for .bss). We want to be able to link together objects -- starting with relocatable objects, but possible expanding to shared objects in the future -- that access LDS memory in a flexible way. LDS memory is in an address space that is entirely separate from the address space that contains the program image (code and normal data), so having program segments for it doesn't really make sense. Furthermore, we want to be able to compile multiple kernels in a compilation unit which have disjoint use of LDS memory. In that case, we may want to place LDS symbols differently for different kernels to save memory (LDS memory is very limited and physically private to each kernel invocation), so we can't simply place LDS symbols in a .lds section. Hence this solution where LDS symbols always stay undefined. Change-Id: I08cbc37a7c0c32f53f7b6123aa0afc91dbc1748f Reviewers: arsenm, rampitec, t-tye, b-sumner, jsjodin Subscribers: kzhuravl, jvesely, wdng, yaxunl, dstuttard, tpr, rupprecht, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D61493 llvm-svn: 364296
* [llvm-objcopy][NFCI] Fix build failure with GCCSeiya Nuta2019-06-251-0/+2
| | | | | | Here is unreachable since the switch statement above is exhaustive. llvm-svn: 364263
* [llvm-objcopy][NFC] Refactor output target parsingSeiya Nuta2019-06-254-36/+86
| | | | | | | | | | | | | | | | | Summary: Use an enum instead of string to hold the output file format in Config.InputFormat and Config.OutputFormat. It's essential to support other output file formats other than ELF. Reviewers: espindola, alexshap, rupprecht, jhenderson Reviewed By: rupprecht, jhenderson Subscribers: jyknight, compnerd, emaste, arichardson, fedor.sergeev, jakehehrlich, MaskRay, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D63239 llvm-svn: 364254
* [llvm-objcopy][MachO] Fix strict-aliasing warning. NFCISeiya Nuta2019-06-241-3/+1
| | | | | | | | | | | | | | | | | | | Summary: Use MachOObjectFile::isRelocationScattered instead of reinterpret_cast. Fixes https://bugs.llvm.org/show_bug.cgi?id=42360 Reviewers: alexshap, rupprecht, jhenderson Reviewed By: alexshap Subscribers: dendibakh, bjope, uabelho, jakehehrlich, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D63699 llvm-svn: 364252
* [llvm-objcopy][MachO] Rebuild the symbol/string table in the writerSeiya Nuta2019-06-217-76/+136
| | | | | | | | | | | | | | | | Summary: Build the string table using StringTableBuilder, reassign symbol indices, and update symbol indices in relocations to allow adding/modifying/removing symbols from the object. Reviewers: alexshap, rupprecht, jhenderson Reviewed By: alexshap Subscribers: mgorny, jakehehrlich, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D63309 llvm-svn: 364000
* [llvm-strip] Error when using stdin twiceAlex Brachet2019-06-183-4/+27
| | | | | | | | | | | | | | | | 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/+3
| | | | | | | | | | | | | | | | | | | 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-2/+12
| | | | | | | | | | | | | | | | 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] Remove no-op flush of errsAlex Brachet2019-06-141-1/+0
| | | | | | | | | | | | Reviewers: alexshap, rupprecht, jhenderson Subscribers: jakehehrlich, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D63313 llvm-svn: 363354
* [llvm-objcopy] Changed command line parsing errorsAlex Brachet2019-06-142-19/+19
| | | | | | | | | | | | | | | | 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-1/+2
| | | | | | | | | | | | | | | | 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-135-49/+302
| | | | | | | 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-101-2/+8
| | | | | | | | | | | | | | | | | | | | | 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
* Fix MSVC "32-bit shift implicitly converted to 64 bits" warning. NFCI.Simon Pilgrim2019-06-101-1/+1
| | | | llvm-svn: 362927
* [llvm-objcopy][MachO] Recompute and update offset/size fields in the writerSeiya Nuta2019-06-085-11/+262
| | | | | | | | | | | | | | | | | | | | 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
* Unbreak 32-bit build.Peter Collingbourne2019-06-071-1/+1
| | | | llvm-svn: 362827
* Fix -Wunused-lambda-capture warning. NFCI.Simon Pilgrim2019-06-071-1/+1
| | | | llvm-svn: 362822
* llvm-objcopy: Implement --extract-partition and --extract-main-partition.Peter Collingbourne2019-06-076-36/+97
| | | | | | | | | | | | | | | | | | | 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/+5
| | | | | | | | | | | | | | | | 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
* [llvm-objcopy] test commitAlex Brachet2019-06-011-1/+1
| | | | llvm-svn: 362289
OpenPOWER on IntegriCloud