summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-objcopy/ObjcopyOpts.td
Commit message (Collapse)AuthorAgeFilesLines
* [llvm-objcopy] Add --set-section-alignmentFangrui Song2019-10-021-0/+4
| | | | | | | | | | | | | Fixes PR43181. This option was recently added to GNU objcopy (binutils PR24942). `llvm-objcopy -I binary -O elf64-x86-64 --set-section-alignment .data=8` can set the alignment of .data. Reviewed By: grimar, jhenderson, rupprecht Differential Revision: https://reviews.llvm.org/D67656 llvm-svn: 373461
* [llvm-objcopy] Ignore -B --binary-architecture=Fangrui Song2019-09-141-2/+1
| | | | | | | | | | | | | | | | | | | | | | | GNU objcopy documents that -B is only useful with architecture-less input (i.e. "binary" or "ihex"). After D67144, -O defaults to -I, and -B is essentially a NOP. * If -O is binary/ihex, GNU objcopy ignores -B. * If -O is elf*, -B provides the e_machine field in GNU objcopy. So to convert a blob to an ELF, `-I binary -B i386:x86-64 -O elf64-x86-64` has to be specified. `-I binary -B i386:x86-64 -O elf64-x86-64` creates an ELF with its e_machine field set to EM_NONE in GNU objcopy, but a regular x86_64 ELF in elftoolchain elfcopy. Follow the elftoolchain approach (ignoring -B) to simplify code. Users that expect their command line portable should specify -B. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D67215 llvm-svn: 371914
* [llvm-objcopy] Allow the visibility of symbols created by --binary andChris Jackson2019-08-301-0/+5
| | | | | | --add-symbol to be specified with --new-symbol-visibility llvm-svn: 370458
* [llvm-objcopy] Allow 'protected' visibility to be set when usingChris Jackson2019-08-151-1/+1
| | | | | | | | | | 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-151-97/+30
| | | | | | | | | | | | | | | | 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-objcopy][llvm-strip] Fix help text typo for --allow-broken-linksJames Henderson2019-06-251-1/+1
| | | | llvm-svn: 364307
* llvm-objcopy: Implement --extract-partition and --extract-main-partition.Peter Collingbourne2019-06-071-0/+7
| | | | | | | | | | | | | | | | | | | 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] Add --prefix-alloc-sectionsJames Henderson2019-05-081-0/+4
| | | | | | | | | | | | | | | | This patch adds support for --prefix-alloc-sections, which adds a prefix to every allocated section names. It adds a prefix after renaming section names by --rename-section as GNU objcopy does. Fixes PR41266: https://bugs.llvm.org/show_bug.cgi?id=41266 Differential Revision: https://reviews.llvm.org/D60042 Patch by Seiya Nuta. llvm-svn: 360233
* [llvm-objcopy] Accept --long-option but not -long-optionFangrui Song2019-04-261-27/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: llvm-{objcopy,strip} (and many other LLVM binary utilities) accept cl::opt style -long-option as well as many short options (e.g. -p -S -x). People who use them as replacement of GNU binutils often use the grouped option syntax (POSIX Utility Conventions), e.g. -Sx => -S -x, -Wd => -W -d, -sj.text => -s -j.text There is ambiguity if a long option starts with the character used by a short option. Drop the support for -long-option to resolve the ambiguity. This divergence from other utilities is accepted (other utilities continue supporting -long-option). https://lists.llvm.org/pipermail/llvm-dev/2019-April/131786.html Reviewers: alexshap, jakehehrlich, jhenderson, rupprecht, espindola Reviewed By: jakehehrlich, jhenderson, rupprecht Subscribers: grimar, emaste, arichardson, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D60439 llvm-svn: 359265
* [llvm-objcopy][llvm-strip] Add switch to allow removing referenced sectionsJames Henderson2019-04-181-0/+6
| | | | | | | | | | | | | | | | | | | | llvm-objcopy currently emits an error if a section to be removed is referenced by another section. This is a reasonable thing to do, but is different to GNU objcopy. We should allow users who know what they are doing to have a way to produce the invalid ELF. This change adds a new switch --allow-broken-links to both llvm-strip and llvm-objcopy to do precisely that. The corresponding sh_link field is then set to 0 instead of an error being emitted. I cannot use llvm-readelf/readobj to test the link fields because they emit an error if any sections, like the .dynsym, cannot be properly loaded. Reviewed by: rupprecht, grimar Differential Revision: https://reviews.llvm.org/D60324 llvm-svn: 358649
* [llvm-objcopy] Add --keep-symbols optionYi Kong2019-04-011-0/+9
| | | | | | Differential Revision: https://reviews.llvm.org/D60054 llvm-svn: 357418
* [llvm-strip] Hook up (unimplemented) --only-keep-debugJordan Rupprecht2019-03-141-1/+4
| | | | | | | | For ELF, we accept but ignore --only-keep-debug. Do the same for llvm-strip. COFF does implement this, so update the test that it is supported. llvm-svn: 356207
* [llvm-objcopy]Don't implicitly strip sections in segmentsJames Henderson2019-03-141-9/+10
| | | | | | | | | | | | | | | | | | | | | | | | | This patch changes llvm-objcopy's behaviour to not strip sections that are in segments, if they otherwise would be due to a stripping operation (--strip-all, --strip-sections, --strip-non-alloc). This preserves the segment contents. It does not change the behaviour of --strip-all-gnu (although we could choose to do so), because GNU objcopy's behaviour in this case seems to be to strip the section, nor does it prevent removing of sections in segments with --remove-section (if a user REALLY wants to remove a section, we should probably let them, although I could be persuaded that warning might be appropriate). Tests have been added to show this latter behaviour. This fixes https://bugs.llvm.org/show_bug.cgi?id=41006. Reviewed by: grimar, rupprecht, jakehehrlich Differential Revision: https://reviews.llvm.org/D59293 This is a reland of r356129, attempting to fix greendragon failures due to a suspected compatibility issue with od on the greendragon bots versus other versions. llvm-svn: 356136
* Revert r356129 due to greendragon bot failuresJames Henderson2019-03-141-10/+9
| | | | llvm-svn: 356133
* [llvm-objcopy]Don't implicitly strip sections in segmentsJames Henderson2019-03-141-9/+10
| | | | | | | | | | | | | | | | | | | | | This patch changes llvm-objcopy's behaviour to not strip sections that are in segments, if they otherwise would be due to a stripping operation (--strip-all, --strip-sections, --strip-non-alloc). This preserves the segment contents. It does not change the behaviour of --strip-all-gnu (although we could choose to do so), because GNU objcopy's behaviour in this case seems to be to strip the section, nor does it prevent removing of sections in segments with --remove-section (if a user REALLY wants to remove a section, we should probably let them, although I could be persuaded that warning might be appropriate). Tests have been added to show this latter behaviour. This fixes https://bugs.llvm.org/show_bug.cgi?id=41006. Reviewed by: grimar, rupprecht, jakehehrlich Differential Revision: https://reviews.llvm.org/D59293 llvm-svn: 356129
* [llvm-objcopy] Add --set-start, --change-start and --adjust-startEugene Leviant2019-02-261-0/+10
| | | | | | Differential revision: https://reviews.llvm.org/D58173 llvm-svn: 354854
* [llvm-objcopy] Add --add-symbolEugene Leviant2019-02-251-0/+8
| | | | | | Differential revision: https://reviews.llvm.org/D58234 llvm-svn: 354787
* [llvm-objcopy] Add --strip-unneeded-symbol(s)Eugene Leviant2019-02-131-0/+9
| | | | | | Differential revision: https://reviews.llvm.org/D58027 llvm-svn: 353919
* [llvm-objcopy] Add few file processing directivesEugene Leviant2019-02-081-0/+21
| | | | | | Differential revision: https://reviews.llvm.org/D57877 llvm-svn: 353521
* [llvm-objcopy] Add --redefine-symsEugene Leviant2019-02-081-0/+10
| | | | | | Differential revision: https://reviews.llvm.org/D57738 llvm-svn: 353509
* [llvm-objcopy] Allow regular expressions in name comparisonEugene Leviant2019-02-061-0/+4
| | | | | | Differential revision: https://reviews.llvm.org/D57517 llvm-svn: 353289
* [llvm-objcopy] Support -X|--discard-locals.Jordan Rupprecht2019-01-301-0/+6
| | | | | | | | | | | | | | | | | | | Summary: This adds support for the --discard-locals flag, which acts similarly to --discard-all, except it only applies to compiler-generated symbols (i.e. symbols starting with `.L` in ELF). I am not sure about COFF local symbols: those appear to also use `.L` in most cases, but also use just `L` in other cases, so for now I am just leaving it unimplemented there. Fixes PR36160 Reviewers: jhenderson, alexshap, jakehehrlich, mstorsjo, espindola Reviewed By: jhenderson Subscribers: llvm-commits, emaste, arichardson Differential Revision: https://reviews.llvm.org/D57248 llvm-svn: 352626
* [llvm-objcopy] Implement --set-section-flags.Jordan Rupprecht2019-01-291-0/+7
| | | | | | | | | | | | | | | | | Summary: --set-section-flags is used to change the section flags (e.g. SHF_ALLOC) for given sections. The flags allowed are the same from the existing --rename-section=.old=.new[,flags] feature. Additionally, make sure that --set-section-flag cannot be used with --rename-section (either the source or destination), since --rename-section accepts flags. This avoids ambiguity for something like "--rename-section=.foo=.bar,alloc --set-section-flag=.bar,code". Reviewers: jhenderson, jakehehrlich, alexshap, espindola Reviewed By: jhenderson, jakehehrlich Subscribers: llvm-commits, emaste, arichardson Differential Revision: https://reviews.llvm.org/D57198 llvm-svn: 352505
* [llvm-objcopy] Add support for -g as an alias for --strip-debugDouglas Yung2019-01-251-0/+2
| | | | | | | | | | | | This change adds an option -g to llvm-objcopy which is an alias for the existing option --strip-debug. This fixes PR40003. Reviewed by: alexshap Differential Revision: https://reviews.llvm.org/D57217 llvm-svn: 352182
* [llvm-objcopy] Change --only-keep to --only-sectionJake Ehrlich2018-12-061-3/+3
| | | | | | | | | | | | I just hard core goofed when I wrote this and created a different name for no good reason. I'm failry aware of most "fresh" users of llvm-objcopy (that is, users which are not using it as a drop in replacement for GNU objcopy) and can say that only "-j" is being used by such people so this patch should strictly increase compatibility and not remove it. Differential Revision: https://reviews.llvm.org/D52180 llvm-svn: 348446
* [llvm-objcopy] Add --build-id-link-dir flagJake Ehrlich2018-12-031-0/+12
| | | | | | | | | | | | | | | This flag does not exist in GNU objcopy but has a major use case. Debugging tools support the .build-id directory structure to find debug binaries. There is no easy way to build this structure up however. One way to do it is by using llvm-readelf and some crazy shell magic. This implements the feature directly. It is most often the case that you'll want to strip a file and send the original to the .build-id directory but if you just want to send a file to the .build-id directory you can copy to /dev/null instead. Differential Revision: https://reviews.llvm.org/D54384 llvm-svn: 348174
* [llvm-objcopy] Hook up the -V alias to --version, output "GNU strip"Martin Storsjo2018-11-281-0/+1
| | | | | | | | | | | This allows libtool to detect the presence of llvm-strip and use it with the options --strip-debug and --strip-unneeded. Also hook up the -V alias for objcopy. Differential Revision: https://reviews.llvm.org/D54936 llvm-svn: 347731
* [llvm-objcopy] Rename --keep to --keep-section.Jordan Rupprecht2018-11-131-1/+2
| | | | | | | | | | | | | | | | Summary: llvm-objcopy/strip support `--keep` (for sections) and `--keep-symbols` (for symbols). For consistency and clarity, rename `--keep` to `--keep-section`. In fact, for GNU compatability, -K is --keep-symbol, so it's weird that the alias `-K` is not the same as the short-ish `--keep`. Reviewers: jakehehrlich, jhenderson, alexshap, MaskRay, espindola Reviewed By: jakehehrlich, MaskRay Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D54477 llvm-svn: 346782
* [llvm-objcopy/strip] [NFC] Clean up tablegen opts (clang-format + ↵Jordan Rupprecht2018-11-011-71/+84
| | | | | | reorganizing things). llvm-svn: 345896
* [llvm-strip] Support --keep and --strip-all-gnu from llvm-objcopyJordan Rupprecht2018-11-011-2/+2
| | | | | | | | | | | | | | Summary: Add --keep and --strip-all-gnu from llvm-objcopy into llvm-strip. Reviewers: jakehehrlich, jhenderson, alexshap Reviewed By: jhenderson, alexshap Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D53954 llvm-svn: 345861
* [llvm-objcopy] Support --{enable,disable}-deterministic-archivesJordan Rupprecht2018-11-011-0/+16
| | | | | | | | | | | | | | Summary: ar and objcopy/strip all support configuring whether archives are written deterministically (timestamps/UIDs/GIDs/etc zero'd). This has been ported to llvm-ar (the U/D modifiers) but not yet to llvm-objcopy/strip. Reviewers: jakehehrlich, jhenderson, alexshap Reviewed By: jhenderson Subscribers: ruiu, mgrang, llvm-commits Differential Revision: https://reviews.llvm.org/D53913 llvm-svn: 345859
* [llvm-objcopy] For multiclass Eq, associate help text with --name= , not ↵Fangrui Song2018-11-011-70/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | with --name Summary: Before: % llvm-objcopy -help ... --weaken-symbol=symbol Mark <symbol> as weak --weaken-symbol symbol Mark <symbol> as weak After: % llvm-objcopy -help ... --weaken-symbol=symbol Mark <symbol> as weak Reviewers: jhenderson, rupprecht, alexshap, jakehehrlich Reviewed By: jhenderson Subscribers: llvm-commits, kristina Differential Revision: https://reviews.llvm.org/D53983 llvm-svn: 345855
* [llvm-objcopy] Add -F|--target compatibilityJordan Rupprecht2018-10-121-0/+4
| | | | | | | | | | | | | | | | | Summary: This change adds support for the GNU --target flag, which sets both --input-target and --output-target. GNU objcopy doesn't do any checking for whether both --target and --{input,output}-target are used, and so it allows both, e.g. "--target A --output-target B" is equivalent to "--input-target A --output-target B" since the later command line flag would override earlier ones. This may be error prone, so I chose to implement it as an error if both are used. I'm not sure if anyone is actually using both. Reviewers: jakehehrlich, jhenderson, alexshap Reviewed By: jakehehrlich, alexshap Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D53029 llvm-svn: 344321
* [llvm-objcopy] Make -S an alias for --strip-allJake Ehrlich2018-10-091-2/+2
| | | | | | -S should be an alias for --strip-all not --strip-all-gnu llvm-svn: 344080
* [llvm-objcopy] Adding support for decompressing zlib compressed dwarf sections.Puyan Lotfi2018-10-011-0/+2
| | | | | | | | | | | | | | | Summary: I had added support for compressing dwarf sections in a prior commit, this one adds support for decompressing. Usage is: llvm-objcopy --decompress-debug-sections input.o output.o Reviewers: jakehehrlich, jhenderson, alexshap Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D51841 llvm-svn: 343451
* [llvm-objcopy/llvm-strip]: handle --versionJordan Rupprecht2018-09-211-0/+3
| | | | | | | | | | | | | | | | | Summary: Implement --version for objcopy and strip. I think there are LLVM utilities that automatically handle this, but that doesn't seem to work with custom parsing since this binary handles both objcopy and strip, so it uses custom parsing. This fixes PR38298 Reviewers: jhenderson, alexshap, jakehehrlich Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D52328 llvm-svn: 342702
* [llvm-objcopy] Add missing alias for --strip-all-gnuAlexander Shaposhnikov2018-09-171-0/+2
| | | | | | | | | | | | | This diff adds -S as an alias for --strip-all-gnu (for compatibility with binutils' objcopy). Patch by Dmitry Golovin! Test plan: make check-all Differential revision: https://reviews.llvm.org/D52163 llvm-svn: 342364
* [llvm-objcopy] Dwarf .debug section compression support (zlib, zlib-gnu).Puyan Lotfi2018-09-071-0/+6
| | | | | | | | | | | | | | | | | | | | | | | Third Attempt: - Alignment issues resolved. - zlib::isAvailable() detected. - ArrayRef misuse fixed. Usage: llvm-objcopy --compress-debug-sections=zlib foo.o llvm-objcopy --compress-debug-sections=zlib-gnu foo.o In both cases the debug section contents is compressed with zlib. In the GNU style case the header is the "ZLIB" magic string followed by the uint64 big- endian decompressed size. In the non-GNU mode the header is the Elf(32|64)_Chdr. Decompression support is coming soon. Differential Revision: https://reviews.llvm.org/D49678 llvm-svn: 341635
* Revert: [llvm-objcopy] Dwarf .debug section compression (Second Attempt).Puyan Lotfi2018-09-071-6/+0
| | | | | | Various bots still fail for unknown reason. llvm-svn: 341613
* [llvm-objcopy] Dwarf .debug section compression support (zlib, zlib-gnu).Puyan Lotfi2018-09-061-0/+6
| | | | | | | | | | | | | | | | | | | | Second Attempt. Alignment issues resolved. zlib::isAvailable() detected. Usage: llvm-objcopy --compress-debug-sections=zlib foo.o llvm-objcopy --compress-debug-sections=zlib-gnu foo.o In both cases the debug section contents is compressed with zlib. In the GNU style case the header is the "ZLIB" magic string followed by the uint64 big- endian decompressed size. In the non-GNU mode the header is the Elf(32|64)_Chdr. Decompression support is coming soon. Differential Revision: https://reviews.llvm.org/D49678 llvm-svn: 341607
* Revert r341342: Dwarf .debug section compression support (zlib, zlib-gnu).Chandler Carruth2018-09-041-6/+0
| | | | | | | | | | | | Also reverts follow-up commits r341343 and r341344. The primary commit continues to break some build bots even after the fixes in r341343 for UBSan issues: http://lab.llvm.org:8011/builders/clang-cmake-aarch64-full/builds/5823 It is also failing for me locally (linux, x86-64). llvm-svn: 341360
* [llvm-objcopy] Dwarf .debug section compression support (zlib, zlib-gnu).Puyan Lotfi2018-09-031-0/+6
| | | | | | | | | | | | | | | | | | | Usage: llvm-objcopy --compress-debug-sections=zlib foo.o llvm-objcopy --compress-debug-sections=zlib-gnu foo.o In both cases the debug section contents is compressed with zlib. In the GNU style case the header is the "ZLIB" magic string followed by the uint64 big- endian decompressed size. In the non-GNU mode the header is the Elf(32|64)_Chdr. Decompression support is coming soon. Differential Revision: https://reviews.llvm.org/D49678 llvm-svn: 341342
* [llvm-objcopy] Implement -G/--keep-global-symbol(s).Jordan Rupprecht2018-08-171-0/+18
| | | | | | | | | | | | | | | | | Summary: Port GNU Objcopy -G/--keep-global-symbol(s). This is slightly different than the already-implemented --globalize-symbol, which marks a symbol as global when copying. When --keep-global-symbol (alias -G) is used, *only* those symbols marked will stay global, and all other globals are demoted to local. (Also note that it doesn't *promote* a symbol to global). Additionally, there is a pluralized version of the flag --keep-global-symbols, which effectively applies --keep-global-symbol for every non-comment in a file. Reviewers: jakehehrlich, jhenderson, alexshap Reviewed By: jhenderson Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D50589 llvm-svn: 340105
* [llvm-strip] Add support for -p/--preserve-datesJordan Rupprecht2018-08-161-0/+6
| | | | | | | | | | | | | | Summary: [llvm-strip] Preserve access/modification timestamps when -p is used. Reviewers: jakehehrlich, jhenderson, alexshap Reviewed By: jhenderson Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D50744 llvm-svn: 339921
* [llvm-objcopy] Add --prefix-symbols optionPaul Semel2018-08-091-0/+3
| | | | | | Differential Revision: https://reviews.llvm.org/D50381 llvm-svn: 339362
* [llvm-objcopy] Add --dump-sectionPaul Semel2018-08-091-0/+3
| | | | | | Differential Revision: https://reviews.llvm.org/D49979 llvm-svn: 339358
* [llvm-objcopy] Add missing -I command line flag alias for --input-targetJordan Rupprecht2018-08-011-0/+1
| | | | llvm-svn: 338635
* [llvm-objcopy] Add support for --rename-section flags from gnu objcopyJordan Rupprecht2018-08-011-3/+7
| | | | | | | | | | | | | | | | | Summary: Add support for --rename-section flags from gnu objcopy. Not all flags appear to have an effect for ELF objects, but allowing them would allow easier drop-in replacement. Other unrecognized flags are rejected. This was only tested by comparing flags printed by "readelf -e <.o>" against the output of gnu vs llvm objcopy, it hasn't been tested to be valid beyond that. Reviewers: jakehehrlich, alexshap Subscribers: llvm-commits, paulsemel, alexshap Differential Revision: https://reviews.llvm.org/D49870 llvm-svn: 338582
* [llvm-objcopy] Add basic support for --rename-sectionJordan Rupprecht2018-07-201-0/+3
| | | | | | | | | | | | | | | Summary: Add basic support for --rename-section=old=new to llvm-objcopy. A full replacement for GNU objcopy requires also modifying flags (i.e. --rename-section=old=new,flag1,flag2); I'd like to keep that in a separate change to keep this simple. Reviewers: jakehehrlich, alexshap Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D49576 llvm-svn: 337604
* [llvm-objcopy] Add --keep-file-symbols optionPaul Semel2018-05-261-0/+2
| | | | | | | | This option prevent from removing file symbols while removing symbols. Differential Revision: https://reviews.llvm.org/D46830 llvm-svn: 333339
OpenPOWER on IntegriCloud