- Jan 11, 2019
-
-
Martin Storsjö authored
Previously, this was broken - by setting PointerToSymbolTable to zero but still actually writing the string table length, the object file header was corrupted. Differential Revision: https://reviews.llvm.org/D56584 llvm-svn: 350926
-
- Jan 10, 2019
-
-
Martin Storsjö authored
llvm-svn: 350899
-
Martin Storsjö authored
Differential Revision: https://reviews.llvm.org/D55881 llvm-svn: 350893
-
- Jan 08, 2019
-
-
James Henderson authored
This fixes https://bugs.llvm.org/show_bug.cgi?id=40097. The problem was caused by a regression in r188022. See also r350614. Reviewed by: rupprecht, mstorsjo, Higuoxing, jakehehrlich Differential Revision: https://reviews.llvm.org/D56319 llvm-svn: 350615
-
- Jan 07, 2019
-
-
Jordan Rupprecht authored
Summary: The -O flag is currently being mostly ignored; it's only checked whether or not the output format is "binary". This adds support for a few formats (e.g. elf64-x86-64), so that when specified, the output can change between 32/64 bit and sizes/alignments are updated accordingly. This fixes PR39135 Reviewers: jakehehrlich, jhenderson, alexshap, espindola Reviewed By: jhenderson Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D53667 llvm-svn: 350541
-
- Jan 03, 2019
-
-
Jordan Rupprecht authored
[llvm-objcopy][ELF] Implement a mutable section visitor that updates size-related fields (Size, EntrySize, Align) before layout. Summary: Fix EntrySize, Size, and Align before doing layout calculation. As a side cleanup, this removes a dependence on sizeof(Elf_Sym) within BinaryReader, so we can untemplatize that. This unblocks a cleaner implementation of handling the -O<format> flag. See D53667 for a previous attempt. Actual implementation of the -O<format> flag will come in an upcoming commit, this is largely a NFC (although not _totally_ one, because alignment on binary input was actually wrong before). Reviewers: jakehehrlich, jhenderson, alexshap, espindola Reviewed By: jhenderson Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D56211 llvm-svn: 350336
-
- Dec 20, 2018
-
-
George Rimar authored
This is https://bugs.llvm.org/show_bug.cgi?id=40005, Patch teaches llvm-objcopy to preserve OS/ABI and ABIVersion fields of ELF header. (Currently, it drops them to zero). Differential revision: https://reviews.llvm.org/D55886 llvm-svn: 349738
-
- Dec 19, 2018
-
-
Martin Storsjö authored
This is an initial implementation of no-op passthrough copying of COFF with objcopy. Differential Revision: https://reviews.llvm.org/D54939 llvm-svn: 349605
-
- Dec 06, 2018
-
-
Jake Ehrlich authored
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
-
- Dec 05, 2018
-
-
Michal Gorny authored
Split timestamp preservation tests into atime and mtime test, and skip the former on NetBSD. When the filesystem is mounted noatime, NetBSD not only inhibits implicit atime updates but also prevents setting atime via utime(), causing the test to fail. Differential Revision: https://reviews.llvm.org/D55271 llvm-svn: 348354
-
- Dec 03, 2018
-
-
Jake Ehrlich authored
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
-
- Nov 30, 2018
-
-
Alexander Shaposhnikov authored
In this diff the elf-specific tests are moved into the subfolder llvm-objcopy/ELF (the change was discussed in the comments on https://reviews.llvm.org/D54674). A separate code reivew wasn't sent for this change since Phabricator is failing to create such a large diff. Test plan: make check-all make check-llvm-tools make check-llvm-tools-llvm-objcopy llvm-svn: 347958
-
- Nov 28, 2018
-
-
Martin Storsjö authored
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
-
- Nov 13, 2018
-
-
Jordan Rupprecht authored
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
-
- Nov 01, 2018
-
-
Jordan Rupprecht authored
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
-
Jordan Rupprecht authored
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
-
Jordan Rupprecht authored
Summary: --localize-symbol and --localize-hidden will currently localize common symbols. GNU objcopy will not localize these symbols even when explicitly requested, which seems reasonable; common symbols should always be global so they can be merged during linking. See PR39461 Reviewers: jakehehrlich, jhenderson, alexshap, MaskRay, espindola Reviewed By: jakehehrlich, jhenderson, alexshap, MaskRay Subscribers: emaste, arichardson, alexshap, MaskRay, llvm-commits Differential Revision: https://reviews.llvm.org/D53782 llvm-svn: 345856
-
- Oct 30, 2018
-
-
Jordan Rupprecht authored
Summary: --keep-global-symbol and --globalize-symbol don't make sense for undefined symbols, so it should be ignored for those symbols. This matches GNU objcopy behavior. Reviewers: jhenderson, alexshap, jakehehrlich, espindola Reviewed By: jhenderson, jakehehrlich Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D53733 llvm-svn: 345614
-
- Oct 23, 2018
-
-
Jordan Rupprecht authored
[llvm-strip] Support -s alias for --strip-all. Make both strip and objcopy case sensitive to support both -s (--strip-all) and -S (--strip-debug). Summary: GNU strip supports both `-s` and `-S` as aliases for `--strip-all` and `--strip-debug`, respectfully. As part of this, it turns out that strip/objcopy were accepting case insensitive command line args. I'm not sure if there was an explicit reason for this. The only others uses of this are llvm-cvtres/llvm-mt/llvm-lib, which are all tools specific for windows support. Forcing case sensitivity allows both aliases to exist, but seems like a good idea anyway. And as a surprise test case adjustment, the llvm-strip unit test was running with `-keep=unavailable_symbol`, despite `keep` not be a valid flag for strip. This is because there is a flag `-K` which, when case insensitivity is permitted, allows it to be interpreted as `-K` = `eep=unavailable_symbol` (e.g. to allow `-Kfoo` == `--keep-symbol=foo`). Reviewers: jakehehrlich, jhenderson, alexshap Reviewed By: jakehehrlich Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D53163 llvm-svn: 345068
-
- Oct 15, 2018
-
-
Jordan Rupprecht authored
llvm-svn: 344550
-
- Oct 12, 2018
-
-
Jordan Rupprecht authored
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
-
- Oct 09, 2018
-
-
Jake Ehrlich authored
-S should be an alias for --strip-all not --strip-all-gnu llvm-svn: 344080
-
- Oct 01, 2018
-
-
Puyan Lotfi authored
M test/tools/llvm-objcopy/compress-and-decompress-debug-sections-error.test llvm-svn: 343454
-
Puyan Lotfi authored
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
-
- Sep 21, 2018
-
-
Jordan Rupprecht authored
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
-
- Sep 17, 2018
-
-
Alexander Shaposhnikov authored
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
-
- Sep 12, 2018
-
-
Julie Hockett authored
Submitted on behalf of Armando Montanez (amontanez@google.com). Objects with unused program headers copied by objcopy would always have nonzero values for program header offset and program header entry size. While technically valid, this atypical behavior triggers warnings in some tools. This change sets the two fields to zero when the program header is unused, better fitting the general expectations for unused program header data. Section headers behaved somewhat similarly (though only with the entry size), and are fixed in this revision as well. Differential Revision: https://reviews.llvm.org/D51961 llvm-svn: 342065
-
- Sep 07, 2018
-
-
Puyan Lotfi authored
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
-
Jordan Rupprecht authored
Windows ls prints dates as "1997-05-05" instead of "May 05 1997", so only check for a leading space. llvm-svn: 341614
-
Puyan Lotfi authored
Various bots still fail for unknown reason. llvm-svn: 341613
-
Puyan Lotfi authored
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
-
Jordan Rupprecht authored
[llvm-strip] Fix -p test to check for explicit spaces around dates, to avoid when the filename happens to contain 1995/1997. llvm-svn: 341595
-
- Sep 05, 2018
-
-
Jordan Rupprecht authored
Summary: Allow strip to be called on multiple input files, which is interpreted as stripping N files in place. Using multiple input files is incompatible with -o. To allow this, create a `DriverConfig` struct which just wraps a list of `CopyConfigs`. objcopy will only ever have a single `CopyConfig`, but strip will have N (where N >= 1) CopyConfigs. Reviewers: alexshap, jakehehrlich Reviewed By: alexshap, jakehehrlich Subscribers: MaskRay, jakehehrlich, llvm-commits Differential Revision: https://reviews.llvm.org/D51660 llvm-svn: 341464
-
Jordan Rupprecht authored
Summary: Fixes the error "Link field value 0 in section .rela.plt is invalid" when copying/stripping certain binaries. Minimal repro: ``` $ cat /tmp/a.c int main() { return 0; } $ clang -static /tmp/a.c -o /tmp/a $ llvm-strip /tmp/a -o /tmp/b llvm-strip: error: Link field value 0 in section .rela.plt is invalid. ``` Reviewers: jakehehrlich, alexshap Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D51493 llvm-svn: 341419
-
- Sep 04, 2018
-
-
Chandler Carruth authored
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
-
Puyan Lotfi authored
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
-
- Aug 30, 2018
-
-
Jordan Rupprecht authored
The restoreDateOnFile() method used to preserve dates uses sys::fs::openFileForWrite(). That method defaults to opening files with CD_CreateAlways, which truncates the output file if it exists. Use CD_OpenExisting instead to open it and *not* truncate it, which also has the side benefit of erroring if the file does not exist (it should always exist, because we just wrote it out). Also, fix the test case to make sure the output is a valid output file, and not empty. The extra test assertions are enough to catch this regression. llvm-svn: 340996
-
- Aug 18, 2018
-
-
Jordan Rupprecht authored
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
-
- Aug 17, 2018
-
-
Jordan Rupprecht authored
llvm-svn: 340071
-
Jordan Rupprecht authored
Summary: The -I (--input-target) and -B (--binary-architecture) flags exist but are currently silently ignored. This adds support for -I binary for architectures i386, x86-64 (and alias i386:x86-64), arm, aarch64, sparc, and ppc (powerpc:common64). This is largely based on D41687. This is done by implementing an additional subclass of Reader, BinaryReader, which works by interpreting the input file as contents for .data field, sets up a synthetic header, and adds additional sections/symbols (e.g. _binary__tmp_data_txt_start). Reviewers: jakehehrlich, alexshap, jhenderson, javed.absar Reviewed By: jhenderson Subscribers: jyknight, nemanjai, kbarton, fedor.sergeev, jrtc27, kristof.beyls, paulsemel, llvm-commits Differential Revision: https://reviews.llvm.org/D50343 llvm-svn: 340070
-