summaryrefslogtreecommitdiffstats
path: root/llvm/test/tools/llvm-objcopy
Commit message (Collapse)AuthorAgeFilesLines
...
* [llvm-objcopy] Add --strip-all option to llvm-objcopyJake Ehrlich2017-11-131-0/+54
| | | | | | | | | | | | | | This change adds a slightly less extreme form of stripping. It should remove any section that starts with ".debug" and should remove any symbol table or relocations. In general this strips out most of the stuff you don't need to execute but leaves a number of things around. This behavior has been designed to be compatible with GNU strip/objcopy --strip-all so that anywhere you currently use --strip-all you should be able to use llvm-objcopy as a drop in replacement. Differential Revision: https://reviews.llvm.org/D39769 llvm-svn: 318092
* Make sure an error is always handled.Rafael Espindola2017-11-081-0/+11
| | | | llvm-svn: 317724
* [llvm-objcopy] Add support for dwarf fissionJake Ehrlich2017-11-032-0/+43
| | | | | | | | This change adds support for dwarf fission. Differential Revision: https://reviews.llvm.org/D39207 llvm-svn: 317350
* [llvm-objcopy] Fix bug in how segment alignment was being handledJake Ehrlich2017-11-022-0/+107
| | | | | | | | | | | | | | | Just aligning segment offsets to segment alignment is incorrect and also wastes more space than is needed. The requirement is that p_offset == p_addr modulo p_align *not* that p_offset == 0 modulo p_align. Generally speaking we've been using p_addr == 0 modulo p_align. In fact yaml2obj can't even produce a valid situation which causes llvm-objcopy to produce incorrect results because alignment and offset were both inherited from the sections the program header covers. This change fixes this bad behavior in llvm-objcopy. Differential Revision: https://reviews.llvm.org/D39132 llvm-svn: 317284
* Reland "[llvm-objcopy] Add support for --strip-sections to remove all ↵Jake Ehrlich2017-10-111-0/+66
| | | | | | | | | | | | | | | | | | | | | section headers leaving only program headers and loadable segment data" ubsan caught an issue I made where I was converting a null pointer to a reference. elf utils implements a particularly extreme form of stripping that I'd like to support. eu-strip has an option called "strip-sections" that removes all section headers and leaves only program headers and the segment data. I have implemented this option partly as a test but mainly because in Fuchsia we would like to use this option to minimize the size of our executables. The other strip options that are on my list include --strip-all and --strip-debug. This is a preliminary implementation that I'd like to start using in Fuchsia builds if possible. This change implements such a stripping option for llvm-objcopy Differential Revision: https://reviews.llvm.org/D38335 llvm-svn: 315484
* Revert "[llvm-objcopy] Add support for --strip-sections to remove all ↵Jake Ehrlich2017-10-111-66/+0
| | | | | | | | section headers leaving only program headers and loadable segment data" This reverts commit rL315412 llvm-svn: 315417
* [llvm-objcopy] Add support for --strip-sections to remove all section ↵Jake Ehrlich2017-10-111-0/+66
| | | | | | | | | | | | | | | | | | headers leaving only program headers and loadable segment data elf utils implements a particularly extreme form of stripping that I'd like to support. eu-strip has an option called "strip-sections" that removes all section headers and leaves only program headers and the segment data. I have implemented this option partly as a test but mainly because in Fuchsia we would like to use this option to minimize the size of our executables. The other strip options that are on my list include --strip-all and --strip-debug. This is a preliminary implementation that I'd like to start using in Fuchsia builds if possible. This change implements such a stripping option for llvm-objcopy Differential Revision: https://reviews.llvm.org/D38335 llvm-svn: 315412
* [llvm-objcopy] Add ability to remove multiple sections by nameJake Ehrlich2017-10-101-0/+130
| | | | | | | | | This change adds the ability to use the "-R"/"-remove-section" option multiple times. Differential Revision: https://reviews.llvm.org/D38332 llvm-svn: 315385
* [llvm-objcopy] Add support for removing sectionsJake Ehrlich2017-10-109-0/+597
| | | | | | | | | | | This change adds support for removing sections using the -R field (as GNU objcopy does as well). This change should let us add many helpful tests and is a proper stepping stone for adding more general kinds of stripping. Differential Revision: https://reviews.llvm.org/D38260 llvm-svn: 315346
* Revert "temporary"Jake Ehrlich2017-10-109-597/+0
| | | | | | | | | I forgot to add a proper commit message. I'm reverting this to fix that. This reverts commit r315344. llvm-svn: 315345
* temporaryJake Ehrlich2017-10-109-0/+597
| | | | llvm-svn: 315344
* [llvm-objcopy] Fix major layout bugs in llvm-objcopyJake Ehrlich2017-10-041-0/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | Somehow a few massive errors slipped though the cracks of testing. 1. The code in Segment::finalize was left over from the old layout algorithm. In certain situations this would cause very strange issues with segment layout. For instance in the shift-segments.test case it would cause the second segment to have the same offset as the first. 2. In debugging this I discovered another issue. Namely section alignment was not being computed based on Section->Align but instead Section->Offset which is bizarre and makes no sense. I have no clue how it worked in the first place. This issue is also fixed 3. Fixing #2 exposed a bug where things were not being written past the end of the file that technically should have been. This was because in certain cases (like overlapping-segments) the end of the file wouldn't always be bumped if the offset could be chosen relative to an existing segment that already had it's offset chosen. For fully nested segments this is fine but for overlapping segments this leaves the end of the file short. So I changed how the offset is bumped when looping though segments. Differential Revision: https://reviews.llvm.org/D38436 llvm-svn: 314918
* [llvm-objcopy] Add support for dynamic relocationsJake Ehrlich2017-09-262-0/+19
| | | | | | | | | | | | | | | This change adds support for dynamic relocations (allocated SHT_REL/SHT_RELA sections with a dynamic symbol table as their link). The binary I added for the test is here: https://drive.google.com/file/d/0B3gtIAmiMwZXSjJUZE9pUjd4M0k/view?usp=sharing Unless support for dynamic symbol tables in yaml2obj is added this is needed. Differential Revision: https://reviews.llvm.org/D37915 llvm-svn: 314227
* Reland "[llvm-objcopy] Add support for .dynamic, .dynsym, and .dynstr"Jake Ehrlich2017-09-202-0/+0
| | | | | | | | | | | | | I did not upload two binaries that I reference in tests. This change adds support for sections involved in dynamic loading such as SHT_DYNAMIC, SHT_DYNSYM, and allocated string tables. The two added binaries used for tests can be downloaded here and here Differential Revision: https://reviews.llvm.org/D36560 llvm-svn: 313772
* Reland "[llvm-objcopy] Add support for .dynamic, .dynsym, and .dynstr"Jake Ehrlich2017-09-203-0/+123
| | | | | | | | | | | | | | I overzealously landed this before I was sure that another change wouldn't break the build that this change depends on. This change adds support for sections involved in dynamic loading such as SHT_DYNAMIC, SHT_DYNSYM, and allocated string tables. The two added binaries used for tests can be downloaded here and here Differential Revision: https://reviews.llvm.org/D36560 llvm-svn: 313767
* Reland "[llvm-objcopy] Add support for nested and overlapping segments"Jake Ehrlich2017-09-195-0/+455
| | | | | | | | | | | I didn't initialize a pointer to be nullptr that I needed to. This change adds support for nested and even overlapping segments. This means that PT_PHDR, PT_GNU_RELRO, PT_TLS, and PT_DYNAMIC can be supported properly. Differential Revision: https://reviews.llvm.org/D36558 llvm-svn: 313682
* Revert "[llvm-objcopy] Add support for .dynamic, .dynsym, and .dynstr"Jake Ehrlich2017-09-195-123/+0
| | | | | | | This reverts commit r313663. Broken because overlapping-sections was reverted. llvm-svn: 313665
* Revert "[llvm-objcopy] Add support for nested and overlapping segments"Jake Ehrlich2017-09-195-455/+0
| | | | | | This reverts commit r313656. Appears to be broken on Windows. llvm-svn: 313664
* [llvm-objcopy] Add support for .dynamic, .dynsym, and .dynstrJake Ehrlich2017-09-195-0/+123
| | | | | | | | | | | | | | | This change adds support for sections involved in dynamic loading such as SHT_DYNAMIC, SHT_DYNSYM, and allocated string tables. The two added binaries used for tests can be downloaded [[ https://drive.google.com/file/d/0B3gtIAmiMwZXOXE3T0RobFg4ZTg/view?usp=sharing | here ]] and [[ https://drive.google.com/file/d/0B3gtIAmiMwZXTFJSQUJZMGxNSXc/view?usp=sharing | here ]] Differential Revision: https://reviews.llvm.org/D36560 llvm-svn: 313663
* [llvm-objcopy] Add test to check that architecture specific values are not ↵Jake Ehrlich2017-09-192-1/+16
| | | | | | | | | | | used on wrong architecture. This change adds a test that checks the an error is produced when a hexagon specific reserved section index is used but e_machine is not EM_HEXAGON. Differential Revision: https://reviews.llvm.org/D38017 llvm-svn: 313661
* [llvm-objcopy] Add support for nested and overlapping segmentsJake Ehrlich2017-09-195-0/+455
| | | | | | | | | This change adds support for nested and even overlapping segments. This means that PT_PHDR, PT_GNU_RELRO, PT_TLS, and PT_DYNAMIC can be supported properly. Differential Revision: https://reviews.llvm.org/D36558 llvm-svn: 313656
* [llvm-objcopy] Add e_machine validity check for reserved section indexesPetr Hosek2017-09-131-1/+1
| | | | | | | | | | | | | As discussed on llvm-commits it was decided it would be best to check e_machine before declaring that a reserved section index is valid. The only special e_machine value that matters here is EM_HEXAGON. This change adds a special check for EM_HEXAGON. Patch by Jake Ehrlich Differential Revision: https://reviews.llvm.org/D37767 llvm-svn: 313114
* [llvm-objcopy] Add support for special section indexes in symbol table ↵Petr Hosek2017-09-073-0/+135
| | | | | | | | | | | | | | | greater than SHN_LORESERVE As is indexes above SHN_LORESERVE will not be handled correctly because they'll be treated as indexes of sections rather than special values that should just be copied. This change adds support to copy them though. Patch by Jake Ehrlich Differential Revision: https://reviews.llvm.org/D37393 llvm-svn: 312756
* Reland "[llvm-objcopy] Add support for relocations"Petr Hosek2017-09-062-0/+121
| | | | | | | | | | | This change adds support for SHT_REL and SHT_RELA sections in llvm-objcopy. Patch by Jake Ehrlich Differential Revision: https://reviews.llvm.org/D36554 llvm-svn: 312680
* Revert "[llvm-objcopy] Add support for relocations"Petr Hosek2017-09-062-121/+0
| | | | | | This reverts r312643 because it's failing on llvm-i686-linux-RA. llvm-svn: 312645
* [llvm-objcopy] Add support for relocationsPetr Hosek2017-09-062-0/+121
| | | | | | | | | | | This change adds support for SHT_REL and SHT_RELA sections in llvm-objcopy. Patch by Jake Ehrlich Differential Revision: https://reviews.llvm.org/D36554 llvm-svn: 312643
* Reland "[llvm] Add symbol table support to llvm-objcopy"Petr Hosek2017-08-291-0/+93
| | | | | | | | | | This change adds support for SHT_SYMTAB sections. Patch by Jake Ehrlich Differential Revision: https://reviews.llvm.org/D34167 llvm-svn: 311974
* Revert "[llvm] Add symbol table support to llvm-objcopy"Petr Hosek2017-08-261-93/+0
| | | | | | This reverts commit r311826 because it's failing on llvm-i686-linux-RA. llvm-svn: 311827
* [llvm] Add symbol table support to llvm-objcopyPetr Hosek2017-08-261-0/+93
| | | | | | | | | | This change adds support for SHT_SYMTAB sections. Patch by Jake Ehrlich Differential Revision: https://reviews.llvm.org/D34167 llvm-svn: 311826
* [llvm][llvm-objcopy] When outputting to binary don't output segments that ↵Petr Hosek2017-08-042-0/+4
| | | | | | | | | | | | | | | | | cover no sections Sometimes LLD will produce a PT_LOAD segment that only covers the headers (and covers no sections). GNU objcopy does not output the segment contents for these sections. In particular this is an issue in building magenta because the final link step for the kernel would produce just such a PT_LOAD segment. This change is to support this case and to match what GNU objcopy does in this case. Patch by Jake Ehrlich Differential Revision: https://reviews.llvm.org/D36196 llvm-svn: 310149
* Reland "[llvm][llvm-objcopy] Added support for outputting to binary in ↵Petr Hosek2017-08-042-0/+62
| | | | | | | | | | | | | | | | llvm-objcopy" This change adds the "-O binary" flag which directs llvm-objcopy to output the object file to the same format as GNU objcopy does when given the flag "-O binary". This was done by splitting the Object class into two subclasses ObjectELF and ObjectBianry which each output a different format but relay on the same code to read in the Object in Object. Patch by Jake Ehrlich Differential Revision: https://reviews.llvm.org/D34480 llvm-svn: 310127
* Revert "[llvm][llvm-objcopy] Added support for outputting to binary in ↵Petr Hosek2017-08-042-62/+0
| | | | | | | | | | llvm-objcopy" This breaks the build on clang-s390x-linux. This reverts commit r310018. llvm-svn: 310026
* Reland "[llvm][llvm-objcopy] Added support for outputting to binary in ↵Petr Hosek2017-08-042-0/+62
| | | | | | | | | | | | | | | | llvm-objcopy" This change adds the "-O binary" flag which directs llvm-objcopy to output the object file to the same format as GNU objcopy does when given the flag "-O binary". This was done by splitting the Object class into two subclasses ObjectELF and ObjectBianry which each output a different format but relay on the same code to read in the Object in Object. Patch by Jake Ehrlich Differential Revision: https://reviews.llvm.org/D34480 llvm-svn: 310018
* Revert "Reland "[llvm][llvm-objcopy] Added support for outputting to binary ↵Petr Hosek2017-08-022-62/+0
| | | | | | | | | | in llvm-objcopy"" This is failing to compile on 32-bit ARM bots. This reverts commit r309768. llvm-svn: 309771
* Reland "[llvm][llvm-objcopy] Added support for outputting to binary in ↵Petr Hosek2017-08-012-0/+62
| | | | | | | | | | | | | | | | llvm-objcopy" This change adds the "-O binary" flag which directs llvm-objcopy to output the object file to the same format as GNU objcopy does when given the flag "-O binary". This was done by splitting the Object class into two subclasses ObjectELF and ObjectBianry which each output a different format but relay on the same code to read in the Object in Object. Patch by Jake Ehrlich Differential Revision: https://reviews.llvm.org/D34480 llvm-svn: 309768
* Revert "[llvm][llvm-objcopy] Added support for outputting to binary in ↵Petr Hosek2017-08-012-62/+0
| | | | | | | | | | | llvm-objcopy" The change seems to be failing on bots which are using gcc and bfd.ld as a host compiler and linker. This reverts commit r309658. llvm-svn: 309660
* [llvm][llvm-objcopy] Added support for outputting to binary in llvm-objcopyPetr Hosek2017-08-012-0/+62
| | | | | | | | | | | | | | This change adds the "-O binary" flag which directs llvm-objcopy to output the object file to the same format as GNU objcopy does when given the flag "-O binary". This was done by splitting the Object class into two subclasses ObjectELF and ObjectBianry which each output a different format but relay on the same code to read in the Object in Object. Patch by Jake Ehrlich Differential Revision: https://reviews.llvm.org/D34480 llvm-svn: 309658
* Reland "[LLVM][llvm-objcopy] Added basic plumbing to get things started"Petr Hosek2017-08-013-0/+173
| | | | | | | | | | | | | | | As discussed on llvm-dev I've implemented the first basic steps towards llvm-objcopy/llvm-objtool (name pending). This change adds the ability to copy (without modification) 64-bit little endian ELF executables that have SHT_PROGBITS, SHT_NOBITS, SHT_NULL and SHT_STRTAB sections. Patch by Jake Ehrlich Differential Revision: https://reviews.llvm.org/D33964 llvm-svn: 309643
* Revert "Reland "[LLVM][llvm-objcopy] Added basic plumbing to get things ↵Petr Hosek2017-07-273-170/+0
| | | | | | | | | | started"" This change is failing tests on Windows bots due to permissions. This reverts commit r309249. llvm-svn: 309251
* Reland "[LLVM][llvm-objcopy] Added basic plumbing to get things started"Petr Hosek2017-07-273-0/+170
| | | | | | | | | | | | | | | As discussed on llvm-dev I've implemented the first basic steps towards llvm-objcopy/llvm-objtool (name pending). This change adds the ability to copy (without modification) 64-bit little endian ELF executables that have SHT_PROGBITS, SHT_NOBITS, SHT_NULL and SHT_STRTAB sections. Patch by Jake Ehrlich Differential Revision: https://reviews.llvm.org/D33964 llvm-svn: 309249
* Revert "Reland "[LLVM][llvm-objcopy] Added basic plumbing to get things ↵Petr Hosek2017-07-253-170/+0
| | | | | | | | started"" This reverts commit 960873b10dd071298c817ba74ef2228f94ead7a1. llvm-svn: 309037
* Reland "[LLVM][llvm-objcopy] Added basic plumbing to get things started"Petr Hosek2017-07-253-0/+170
| | | | | | | | | | | | | | | As discussed on llvm-dev I've implemented the first basic steps towards llvm-objcopy/llvm-objtool (name pending). This change adds the ability to copy (without modification) 64-bit little endian ELF executables that have SHT_PROGBITS, SHT_NOBITS, SHT_NULL and SHT_STRTAB sections. Patch by Jake Ehrlich Differential Revision: https://reviews.llvm.org/D33964 llvm-svn: 309032
* Revert "Reland "[LLVM][llvm-objcopy] Added basic plumbing to get things ↵Petr Hosek2017-07-223-170/+0
| | | | | | | | started"" This reverts commit 2b52298eb28ba4d3eca113353a348c02a6ef1f93. llvm-svn: 308822
* Reland "[LLVM][llvm-objcopy] Added basic plumbing to get things started"Petr Hosek2017-07-223-0/+170
| | | | | | | | | | | | | | | As discussed on llvm-dev I've implemented the first basic steps towards llvm-objcopy/llvm-objtool (name pending). This change adds the ability to copy (without modification) 64-bit little endian ELF executables that have SHT_PROGBITS, SHT_NOBITS, SHT_NULL and SHT_STRTAB sections. Patch by Jake Ehrlich Differential Revision: https://reviews.llvm.org/D33964 llvm-svn: 308821
* Revert "[LLVM][llvm-objcopy] Added basic plumbing to get things started"Petr Hosek2017-07-213-150/+0
| | | | | | This reverts commit 2f423248e140b94b8377660d4d2fe9364f30febe. llvm-svn: 308806
* Reland "[LLVM][llvm-objcopy] Added basic plumbing to get things started"Petr Hosek2017-07-213-0/+150
| | | | | | | | | | | | | | | As discussed on llvm-dev I've implemented the first basic steps towards llvm-objcopy/llvm-objtool (name pending). This change adds the ability to copy (without modification) 64-bit little endian ELF executables that have SHT_PROGBITS, SHT_NOBITS, SHT_NULL and SHT_STRTAB sections. Patch by Jake Ehrlich Differential Revision: https://reviews.llvm.org/D33964 llvm-svn: 308803
* Revert "[LLVM][llvm-objcopy] Added basic plumbing to get things started"Petr Hosek2017-07-203-170/+0
| | | | | | This reverts commit 98f9792e7ca5bbd9eb43bda72bf497957cfb6eb8. llvm-svn: 308569
* [LLVM][llvm-objcopy] Added basic plumbing to get things startedPetr Hosek2017-07-193-0/+170
As discussed on llvm-dev I've implemented the first basic steps towards llvm-objcopy/llvm-objtool (name pending). This change adds the ability to copy (without modification) 64-bit little endian ELF executables that have SHT_PROGBITS, SHT_NOBITS, SHT_NULL and SHT_STRTAB sections. Patch by Jake Ehrlich Differential Revision: https://reviews.llvm.org/D33964 llvm-svn: 308559
OpenPOWER on IntegriCloud