Commit Graph

116 Commits

Author SHA1 Message Date
Jonas Devlieghere
686dfe3676 [Support] Make error banner optional in logAllUnhandledErrors
In a lot of places an empty string was passed as the ErrorBanner to
logAllUnhandledErrors. This patch makes that argument optional to
simplify the call sites.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346604 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-11 01:46:03 +00:00
Fangrui Song
63cd3e5cd3 [llvm-strip] Check "strip" with StringRef::contains instead of ends_with
Summary: If argv[0] is version suffixed, e.g. llvm-strip-7, this will still work.

Reviewers: rupprecht, jhenderson, alexshap, jakehehrlich

Reviewed By: rupprecht

Subscribers: alexshap, jakehehrlich, llvm-commits

Differential Revision: https://reviews.llvm.org/D54193

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346292 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-07 03:02:11 +00:00
Jordan Rupprecht
167fb18752 [llvm-objcopy] Support --{enable,disable}-deterministic-archives
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345859 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-01 17:36:37 +00:00
Alexander Shaposhnikov
245f8d7f3f [llvm-objcopy] Move elf-specific code into subfolder
In this diff the elf-specific code is moved into the subfolder ELF 
(and factored out from llvm-objcopy.cpp).

Test plan: make check-all

Differential revision: https://reviews.llvm.org/D53790


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345544 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-29 21:22:58 +00:00
Alexander Shaposhnikov
bcfd1f3ead [llvm-objcopy] Introduce dispatch mechanism based on the input
In this diff we introduce dispatch mechanism based on 
the type of the input (archive, object file, raw binary) 
and the format (coff, elf, macho).
We also move the ELF-specific code into the namespace llvm::objcopy::elf.

Test plan: make check-all

Differential revision: https://reviews.llvm.org/D53311


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345217 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-24 22:49:06 +00:00
Alexander Shaposhnikov
d043791034 [llvm-objcopy] Factor out Buffer
In this diff we move out the hierarchy of buffers from Object.h/Object.cpp 
into separate files since it is not ELF-specific and will be reused later. 
After this change Object.h/Object.cpp are almost exclusively ELF-specific.

Test plan: make check-all

Differential revision: https://reviews.llvm.org/D53298


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344585 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-16 05:40:18 +00:00
Alexander Shaposhnikov
bd934ffaab [llvm-objcopy] Factor out CopyConfig
In this diff we move out CopyConfig from llvm-oobjcopy.cpp into a separate header CopyConfig.h
to enable us (in the future) reuse this class in the other implementations of objcopy (for coff, mach-o).
Additionally this enables us to unload the complexity from llvm-objcopy.cpp a little bit.

Test plan: make check-all

Differential revision: https://reviews.llvm.org/D53006


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344307 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-11 22:33:50 +00:00
Armando Montanez
3cf846acd8 Test commit: fix typo in comment
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344185 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-10 21:16:57 +00:00
Fangrui Song
42f63b6f96 [opt] Change the parameter of OptTable::PrintHelp from Name to Usage and don't append "[options] <inputs>"
Summary:
Before, "[options] <inputs>" is unconditionally appended to the `Name` parameter. It is more flexible to change its semantic to `Usage` and let user customize the usage line.

% llvm-objcopy
...
USAGE: llvm-objcopy <input> [ <output> ] [options] <inputs>

With this patch:

% llvm-objcopy
...
USAGE: llvm-objcopy input [output]

Reviewers: rupprecht, alexshap, jhenderson

Reviewed By: rupprecht

Subscribers: jakehehrlich, mehdi_amini, steven_wu, dexonsmith, llvm-commits

Differential Revision: https://reviews.llvm.org/D51009

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344097 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-10 00:15:31 +00:00
Puyan Lotfi
cc27a05389 [llvm-objcopy] Adding support for decompressing zlib compressed dwarf sections.
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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343451 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-01 10:29:41 +00:00
Jordan Rupprecht
5b1329de30 [llvm-objcopy/llvm-strip]: handle --version
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342702 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-21 00:47:31 +00:00
Puyan Lotfi
ac820be777 [llvm-objcopy] Dwarf .debug section compression support (zlib, zlib-gnu).
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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341635 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-07 08:10:22 +00:00
Puyan Lotfi
df0bc37389 Revert: [llvm-objcopy] Dwarf .debug section compression (Second Attempt).
Various bots still fail for unknown reason.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341613 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-07 00:28:25 +00:00
Puyan Lotfi
ea363334ce [llvm-objcopy] Dwarf .debug section compression support (zlib, zlib-gnu).
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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341607 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-06 23:59:50 +00:00
Jordan Rupprecht
4906f3fb81 [llvm-strip] Support stripping multiple input files
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341464 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-05 13:10:03 +00:00
Chandler Carruth
cf0bf50e16 Revert r341342: Dwarf .debug section compression support (zlib, zlib-gnu).
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).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341360 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-04 11:55:57 +00:00
Puyan Lotfi
341c1a8af7 [llvm-objcopy] Dwarf .debug section compression support (zlib, zlib-gnu).
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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341342 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-03 22:25:56 +00:00
Jordan Rupprecht
72a8d84d5b [llvm-strip] Fix -p|--preserve-dates to not truncate output when used in-place.
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340996 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-29 23:21:56 +00:00
Fangrui Song
d984d20c63 [llvm-objcopy] Simplify find(X,Y) != X.end() with is_contained()
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340241 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-21 00:13:52 +00:00
Fangrui Song
2e10363382 [llvm-strip] Allow only one input
Summary: Before, llvm-strip accepted a second argument but it would just be ignored.

Reviewers: alexshap, jhenderson, paulsemel

Reviewed By: alexshap

Subscribers: jakehehrlich, rupprecht, llvm-commits

Differential Revision: https://reviews.llvm.org/D51004

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340229 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-20 23:01:57 +00:00
Jordan Rupprecht
dc7a888020 [llvm-objcopy] Implement -G/--keep-global-symbol(s).
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340105 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-17 22:34:48 +00:00
Jordan Rupprecht
cd514b66e8 [llvm-objcopy] Add support for -I binary -B <arch>.
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340070 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-17 18:51:11 +00:00
Jordan Rupprecht
7b455c4fd2 [llvm-strip] Add support for -p/--preserve-dates
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339921 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-16 18:29:40 +00:00
Jordan Rupprecht
a391f98615 [llvm-objcopy] NFC: Fix minor formatting issues
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339616 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-13 21:30:27 +00:00
Jordan Rupprecht
024925d385 [llvm-objcopy] NFC: Add some color to error()
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339404 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-09 22:52:03 +00:00
Paul Semel
ffc59809e8 [llvm-objcopy] Add --prefix-symbols option
Differential Revision: https://reviews.llvm.org/D50381

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339362 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-09 17:49:04 +00:00
Paul Semel
6bbc345f93 [llvm-objcopy] Add --dump-section
Differential Revision: https://reviews.llvm.org/D49979

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339358 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-09 17:05:21 +00:00
Puyan Lotfi
4aec14e3f6 [NFC] clang-format cleanup of a couple files in llvm-objcopy.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338752 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-02 18:16:52 +00:00
Jordan Rupprecht
742c679d08 [llvm-objcopy] Add support for --rename-section flags from gnu objcopy
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338582 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-01 16:23:22 +00:00
Fangrui Song
402cad0619 [llvm-objcopy] Make --strip-debug strip .gdb_index
Summary:
See binutils-gdb/bfd/elf.c, GNU objcopy also strips .stab* (STABS)
.line* (DWARF 1) .gnu.linkonce.wi.* (linkonce section for .debug_info) but
I'm not sure we need to be compatible with it.

Reviewers: dblaikie, alexshap, jakehehrlich, jhenderson

Reviewed By: alexshap, jakehehrlich

Subscribers: aprantl, JDevlieghere, jakehehrlich, llvm-commits

Differential Revision: https://reviews.llvm.org/D50100

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338443 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-31 21:26:35 +00:00
Fangrui Song
2ccd4fbdb9 [llvm-objcopy] Make --strip-debug strip .zdebug* (zlib-gnu) sections
This behavior matches GNU objcopy.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338173 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-27 22:51:36 +00:00
Stephen Hines
1028e2499b Handle the lack of a symbol table correctly.
Summary:
These two cases will trigger a dereference on a nullptr, since the
SymbolTable can be nonexistent for a given library, in addition to just
being empty.

Reviewers: alexshap

Reviewed By: alexshap

Subscribers: meikeb, kongyi, chh, jakehehrlich, llvm-commits, pirama

Differential Revision: https://reviews.llvm.org/D49534

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338062 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-26 20:05:31 +00:00
Jordan Rupprecht
ff83113c2f [llvm-objcopy] Add basic support for --rename-section
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337604 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-20 19:54:24 +00:00
Puyan Lotfi
b5b60c3d14 [NFC][llvm-objcopy] Cleanup namespace usage in llvm-objcopy.
Nest any classes not used outside of a file into anon. Nest any classes used
across files in llvm-objcopy into namespace llvm::objcopy.


Differential Revision: https://reviews.llvm.org/D49449





git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337337 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-18 00:10:51 +00:00
Puyan Lotfi
41306baa27 [NFC][llvm-objcopy] Make helper functions static
Anywhere in tools/llvm-objcopy where functions or classes are not referenced
outside of a given file, we change things to make the function or class static
or put inside an anonymous namespace.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337220 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-16 22:17:05 +00:00
Stephen Hines
df4581eddc Add --strip-all option back to llvm-strip.
Summary:
This option appears to have been dropped as part of the refactoring in
r331663. Unfortunately, if we want to use llvm-strip as a drop-in
replacement for strip, this option should still be available.

Reviewers: alexshap

Reviewed By: alexshap

Subscribers: meikeb, kongyi, chh, jakehehrlich, llvm-commits, pirama

Differential Revision: https://reviews.llvm.org/D49226

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336921 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-12 17:42:17 +00:00
Alexander Shaposhnikov
80e7ea0a47 [llvm-objcopy] Add support for static libraries
This diff adds support for handling static libraries 
to llvm-objcopy and llvm-strip.

Test plan: make check-all

Differential revision: https://reviews.llvm.org/D48413


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336455 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-06 17:51:03 +00:00
Paul Semel
f36d22b003 [llvm-strip] Expose --strip-unneeded option
Differential Revision: https://reviews.llvm.org/D47818

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334182 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-07 10:05:25 +00:00
Alexander Shaposhnikov
ad593b0363 [llvm-strip] Expose --discard-all option
Expose objcopy's --discard-all option in llvm-strip.

Test plan: make check-all

Differential revision: https://reviews.llvm.org/D47750


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334131 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-06 21:23:19 +00:00
Paul Semel
64284524f0 [llvm-objcopy] Fix null symbol handling
This fixes the bug where strip-all option was
leading to a malformed outputted ELF file.

Differential Revision: https://reviews.llvm.org/D47414

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333772 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-01 16:19:46 +00:00
Alexander Shaposhnikov
9eb9307162 [llvm-strip] Add -o option to llvm-strip
This diff implements the option -o 
for specifying a file to write the output to.

Test plan: make check-all

Differential revision: https://reviews.llvm.org/D47505


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333693 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-31 20:42:13 +00:00
Paul Semel
5af80c626e [llvm-objcopy] Add --keep-file-symbols option
This option prevent from removing file symbols while removing symbols.

Differential Revision: https://reviews.llvm.org/D46830

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333339 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-26 08:10:37 +00:00
Paul Semel
fe9deeb432 [llvm-objcopy] Add --strip-unneeded option
Differential Revision: https://reviews.llvm.org/D46896

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333267 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-25 11:01:25 +00:00
Alexander Shaposhnikov
0390dacdd0 [llvm-strip] Minor fix of the usage of TableGen
This is a small follow-up to the revisions r333117 and r331663.

1. Avoid the name conflicts of the generated variables for prefixes.
2. Apply clang-format -i -style=llvm to llvm-objcopy.cpp once again.
3. Add a test for the flag with double dash.

Test plan: make check-all


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333120 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-23 20:39:52 +00:00
Alexander Shaposhnikov
49011d2b65 [llvm-strip] Expose --keep-symbol option
Expose --keep-symbol option in llvm-strip.

Test plan: make check-all

Differential revision: https://reviews.llvm.org/D47222


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333117 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-23 19:44:19 +00:00
Alexander Shaposhnikov
8eff37b3dd [llvm-objcopy] Fix the behavior of --strip-* and --keep-symbol
If one runs llvm-objcopy --strip-all --keep-symbol foo
and the symbol table indeed contains the symbol "foo"
then it should not be removed.

Test plan: make check-all

Differential revision: https://reviews.llvm.org/D47052


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333008 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-22 18:24:07 +00:00
Paul Semel
7d79fc6afb Revert "[llvm-objcopy] Add --strip-unneeded option"
There is a use after free I didn't see. Need to investigate.

This reverts commit f7624abeb1.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332925 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-22 01:04:36 +00:00
Paul Semel
f7624abeb1 [llvm-objcopy] Add --strip-unneeded option
This option removes symbols that are not needed by relocations.

Differential Revision: https://reviews.llvm.org/D46896

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332915 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-21 22:50:32 +00:00
Alexander Shaposhnikov
2135b33dc5 [llvm-objcopy] Fix formatting
Apply clang-format -i -style=llvm to llvm-objcopy.cpp
NFC.

Test plan: make check-all


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332693 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-18 04:18:41 +00:00
Jake Ehrlich
bcc9a743a6 [llvm-objcopy] Add --only-keep-debug as a noop
This option just keeps being a problem and really needs to be implemented
in some fashion. Implementing it properly requires some kind of
"replaceSectionReference" method because all the existing links need to be
maintained. The desired behavior is just for allocated sections to become
NOBITS but actually implementing that is rather tricky due to the current
design of llvm-objcopy. However converting allocated sections to NOBITS is
just an optimization and not something debuggers need. Debuggers can debug
a stripped executable and take an unstripped executable for that stripped
executable as input. Additionally allocated sections account for a very
small part of debug binaries so this optimization is quite small. I propose
that for the time being we implement this as a NOP so that people can use
llvm-objcopy where they need to, just in a sub-optimal way.

This option has already blocked a lot of people and its currently blocking me.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332396 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-15 20:53:53 +00:00