Eugene Zelenko | 0ad18f8 | 2017-11-01 21:16:06 +0000 | [diff] [blame] | 1 | //===- llvm-objcopy.cpp ---------------------------------------------------===// |
Petr Hosek | 05a04cb | 2017-08-01 00:33:58 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
Eugene Zelenko | 0ad18f8 | 2017-11-01 21:16:06 +0000 | [diff] [blame] | 9 | |
Petr Hosek | 05a04cb | 2017-08-01 00:33:58 +0000 | [diff] [blame] | 10 | #include "llvm-objcopy.h" |
| 11 | #include "Object.h" |
Eugene Zelenko | 0ad18f8 | 2017-11-01 21:16:06 +0000 | [diff] [blame] | 12 | #include "llvm/ADT/STLExtras.h" |
| 13 | #include "llvm/ADT/StringRef.h" |
| 14 | #include "llvm/ADT/Twine.h" |
| 15 | #include "llvm/BinaryFormat/ELF.h" |
| 16 | #include "llvm/Object/Binary.h" |
| 17 | #include "llvm/Object/ELFObjectFile.h" |
| 18 | #include "llvm/Object/ELFTypes.h" |
| 19 | #include "llvm/Object/Error.h" |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 20 | #include "llvm/Option/Arg.h" |
| 21 | #include "llvm/Option/ArgList.h" |
| 22 | #include "llvm/Option/Option.h" |
Eugene Zelenko | 0ad18f8 | 2017-11-01 21:16:06 +0000 | [diff] [blame] | 23 | #include "llvm/Support/Casting.h" |
Petr Hosek | 05a04cb | 2017-08-01 00:33:58 +0000 | [diff] [blame] | 24 | #include "llvm/Support/CommandLine.h" |
Eugene Zelenko | 0ad18f8 | 2017-11-01 21:16:06 +0000 | [diff] [blame] | 25 | #include "llvm/Support/Compiler.h" |
| 26 | #include "llvm/Support/Error.h" |
| 27 | #include "llvm/Support/ErrorHandling.h" |
| 28 | #include "llvm/Support/ErrorOr.h" |
Petr Hosek | 05a04cb | 2017-08-01 00:33:58 +0000 | [diff] [blame] | 29 | #include "llvm/Support/FileOutputBuffer.h" |
Rui Ueyama | 197194b | 2018-04-13 18:26:06 +0000 | [diff] [blame] | 30 | #include "llvm/Support/InitLLVM.h" |
Alexander Shaposhnikov | cca6998 | 2018-05-07 19:32:09 +0000 | [diff] [blame] | 31 | #include "llvm/Support/Path.h" |
Eugene Zelenko | 0ad18f8 | 2017-11-01 21:16:06 +0000 | [diff] [blame] | 32 | #include "llvm/Support/raw_ostream.h" |
| 33 | #include <algorithm> |
| 34 | #include <cassert> |
| 35 | #include <cstdlib> |
| 36 | #include <functional> |
| 37 | #include <iterator> |
Petr Hosek | 05a04cb | 2017-08-01 00:33:58 +0000 | [diff] [blame] | 38 | #include <memory> |
| 39 | #include <string> |
| 40 | #include <system_error> |
Eugene Zelenko | 0ad18f8 | 2017-11-01 21:16:06 +0000 | [diff] [blame] | 41 | #include <utility> |
Petr Hosek | 05a04cb | 2017-08-01 00:33:58 +0000 | [diff] [blame] | 42 | |
| 43 | using namespace llvm; |
| 44 | using namespace object; |
| 45 | using namespace ELF; |
| 46 | |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 47 | namespace { |
| 48 | |
Alexander Shaposhnikov | cca6998 | 2018-05-07 19:32:09 +0000 | [diff] [blame] | 49 | enum ObjcopyID { |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 50 | OBJCOPY_INVALID = 0, // This is not an option ID. |
| 51 | #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ |
| 52 | HELPTEXT, METAVAR, VALUES) \ |
| 53 | OBJCOPY_##ID, |
Alexander Shaposhnikov | cca6998 | 2018-05-07 19:32:09 +0000 | [diff] [blame] | 54 | #include "ObjcopyOpts.inc" |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 55 | #undef OPTION |
| 56 | }; |
| 57 | |
| 58 | #define PREFIX(NAME, VALUE) const char *const NAME[] = VALUE; |
Alexander Shaposhnikov | cca6998 | 2018-05-07 19:32:09 +0000 | [diff] [blame] | 59 | #include "ObjcopyOpts.inc" |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 60 | #undef PREFIX |
| 61 | |
Alexander Shaposhnikov | 3326e78 | 2018-04-24 06:23:22 +0000 | [diff] [blame] | 62 | static const opt::OptTable::Info ObjcopyInfoTable[] = { |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 63 | #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ |
| 64 | HELPTEXT, METAVAR, VALUES) \ |
| 65 | {PREFIX, NAME, HELPTEXT, \ |
| 66 | METAVAR, OBJCOPY_##ID, opt::Option::KIND##Class, \ |
| 67 | PARAM, FLAGS, OBJCOPY_##GROUP, \ |
| 68 | OBJCOPY_##ALIAS, ALIASARGS, VALUES}, |
Alexander Shaposhnikov | cca6998 | 2018-05-07 19:32:09 +0000 | [diff] [blame] | 69 | #include "ObjcopyOpts.inc" |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 70 | #undef OPTION |
| 71 | }; |
| 72 | |
| 73 | class ObjcopyOptTable : public opt::OptTable { |
| 74 | public: |
| 75 | ObjcopyOptTable() : OptTable(ObjcopyInfoTable, true) {} |
| 76 | }; |
| 77 | |
Alexander Shaposhnikov | cca6998 | 2018-05-07 19:32:09 +0000 | [diff] [blame] | 78 | enum StripID { |
| 79 | STRIP_INVALID = 0, // This is not an option ID. |
| 80 | #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ |
| 81 | HELPTEXT, METAVAR, VALUES) \ |
| 82 | STRIP_##ID, |
| 83 | #include "StripOpts.inc" |
| 84 | #undef OPTION |
| 85 | }; |
| 86 | |
| 87 | static const opt::OptTable::Info StripInfoTable[] = { |
| 88 | #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ |
| 89 | HELPTEXT, METAVAR, VALUES) \ |
Alexander Shaposhnikov | d29bf4c | 2018-05-18 04:18:41 +0000 | [diff] [blame] | 90 | {PREFIX, NAME, HELPTEXT, \ |
| 91 | METAVAR, STRIP_##ID, opt::Option::KIND##Class, \ |
| 92 | PARAM, FLAGS, STRIP_##GROUP, \ |
| 93 | STRIP_##ALIAS, ALIASARGS, VALUES}, |
Alexander Shaposhnikov | cca6998 | 2018-05-07 19:32:09 +0000 | [diff] [blame] | 94 | #include "StripOpts.inc" |
| 95 | #undef OPTION |
| 96 | }; |
| 97 | |
| 98 | class StripOptTable : public opt::OptTable { |
| 99 | public: |
| 100 | StripOptTable() : OptTable(StripInfoTable, true) {} |
| 101 | }; |
| 102 | |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 103 | } // namespace |
| 104 | |
Petr Hosek | 05a04cb | 2017-08-01 00:33:58 +0000 | [diff] [blame] | 105 | // The name this program was invoked as. |
| 106 | static StringRef ToolName; |
| 107 | |
| 108 | namespace llvm { |
| 109 | |
Zachary Turner | 41a9ee9 | 2017-10-11 23:54:34 +0000 | [diff] [blame] | 110 | LLVM_ATTRIBUTE_NORETURN void error(Twine Message) { |
Petr Hosek | 05a04cb | 2017-08-01 00:33:58 +0000 | [diff] [blame] | 111 | errs() << ToolName << ": " << Message << ".\n"; |
| 112 | errs().flush(); |
| 113 | exit(1); |
| 114 | } |
| 115 | |
| 116 | LLVM_ATTRIBUTE_NORETURN void reportError(StringRef File, std::error_code EC) { |
| 117 | assert(EC); |
| 118 | errs() << ToolName << ": '" << File << "': " << EC.message() << ".\n"; |
| 119 | exit(1); |
| 120 | } |
| 121 | |
Eugene Zelenko | 0ad18f8 | 2017-11-01 21:16:06 +0000 | [diff] [blame] | 122 | LLVM_ATTRIBUTE_NORETURN void reportError(StringRef File, Error E) { |
Petr Hosek | 05a04cb | 2017-08-01 00:33:58 +0000 | [diff] [blame] | 123 | assert(E); |
| 124 | std::string Buf; |
| 125 | raw_string_ostream OS(Buf); |
| 126 | logAllUnhandledErrors(std::move(E), OS, ""); |
| 127 | OS.flush(); |
| 128 | errs() << ToolName << ": '" << File << "': " << Buf; |
| 129 | exit(1); |
| 130 | } |
Petr Hosek | 05a04cb | 2017-08-01 00:33:58 +0000 | [diff] [blame] | 131 | |
Eugene Zelenko | 0ad18f8 | 2017-11-01 21:16:06 +0000 | [diff] [blame] | 132 | } // end namespace llvm |
| 133 | |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 134 | struct CopyConfig { |
| 135 | StringRef OutputFilename; |
| 136 | StringRef InputFilename; |
| 137 | StringRef OutputFormat; |
| 138 | StringRef InputFormat; |
| 139 | StringRef BinaryArch; |
Alexander Shaposhnikov | fedb016 | 2018-02-09 23:33:31 +0000 | [diff] [blame] | 140 | |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 141 | StringRef SplitDWO; |
| 142 | StringRef AddGnuDebugLink; |
| 143 | std::vector<StringRef> ToRemove; |
| 144 | std::vector<StringRef> Keep; |
| 145 | std::vector<StringRef> OnlyKeep; |
| 146 | std::vector<StringRef> AddSection; |
Alexander Shaposhnikov | 40e9bdf | 2018-04-26 18:28:17 +0000 | [diff] [blame] | 147 | std::vector<StringRef> SymbolsToLocalize; |
Paul Semel | ee5be79 | 2018-04-27 19:09:44 +0000 | [diff] [blame] | 148 | std::vector<StringRef> SymbolsToGlobalize; |
Paul Semel | 3a8a56b | 2018-04-27 19:16:27 +0000 | [diff] [blame] | 149 | std::vector<StringRef> SymbolsToWeaken; |
Paul Semel | 4246a46 | 2018-05-09 21:36:54 +0000 | [diff] [blame] | 150 | std::vector<StringRef> SymbolsToRemove; |
Paul Semel | 5d97c82 | 2018-05-15 14:09:37 +0000 | [diff] [blame] | 151 | std::vector<StringRef> SymbolsToKeep; |
Alexander Shaposhnikov | 40e9bdf | 2018-04-26 18:28:17 +0000 | [diff] [blame] | 152 | StringMap<StringRef> SymbolsToRename; |
Alexander Shaposhnikov | cca6998 | 2018-05-07 19:32:09 +0000 | [diff] [blame] | 153 | bool StripAll = false; |
| 154 | bool StripAllGNU = false; |
| 155 | bool StripDebug = false; |
| 156 | bool StripSections = false; |
| 157 | bool StripNonAlloc = false; |
| 158 | bool StripDWO = false; |
| 159 | bool ExtractDWO = false; |
| 160 | bool LocalizeHidden = false; |
| 161 | bool Weaken = false; |
| 162 | bool DiscardAll = false; |
Jake Ehrlich | e40398a | 2018-05-15 20:53:53 +0000 | [diff] [blame] | 163 | bool OnlyKeepDebug = false; |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 164 | }; |
Jake Ehrlich | f03384d | 2017-10-11 18:09:18 +0000 | [diff] [blame] | 165 | |
Eugene Zelenko | 0ad18f8 | 2017-11-01 21:16:06 +0000 | [diff] [blame] | 166 | using SectionPred = std::function<bool(const SectionBase &Sec)>; |
Petr Hosek | 05a04cb | 2017-08-01 00:33:58 +0000 | [diff] [blame] | 167 | |
Jake Ehrlich | 777fb00 | 2017-12-15 20:17:55 +0000 | [diff] [blame] | 168 | bool IsDWOSection(const SectionBase &Sec) { return Sec.Name.endswith(".dwo"); } |
Jake Ehrlich | 5de70d9 | 2017-11-03 18:58:41 +0000 | [diff] [blame] | 169 | |
Jake Ehrlich | 76e9110 | 2018-01-25 22:46:17 +0000 | [diff] [blame] | 170 | bool OnlyKeepDWOPred(const Object &Obj, const SectionBase &Sec) { |
Jake Ehrlich | 5de70d9 | 2017-11-03 18:58:41 +0000 | [diff] [blame] | 171 | // We can't remove the section header string table. |
Jake Ehrlich | 76e9110 | 2018-01-25 22:46:17 +0000 | [diff] [blame] | 172 | if (&Sec == Obj.SectionNames) |
Jake Ehrlich | 5de70d9 | 2017-11-03 18:58:41 +0000 | [diff] [blame] | 173 | return false; |
| 174 | // Short of keeping the string table we want to keep everything that is a DWO |
| 175 | // section and remove everything else. |
| 176 | return !IsDWOSection(Sec); |
| 177 | } |
| 178 | |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 179 | std::unique_ptr<Writer> CreateWriter(const CopyConfig &Config, Object &Obj, |
| 180 | StringRef File, ElfType OutputElfType) { |
| 181 | if (Config.OutputFormat == "binary") { |
| 182 | return llvm::make_unique<BinaryWriter>(File, Obj); |
Jake Ehrlich | 76e9110 | 2018-01-25 22:46:17 +0000 | [diff] [blame] | 183 | } |
| 184 | // Depending on the initial ELFT and OutputFormat we need a different Writer. |
| 185 | switch (OutputElfType) { |
| 186 | case ELFT_ELF32LE: |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 187 | return llvm::make_unique<ELFWriter<ELF32LE>>(File, Obj, |
| 188 | !Config.StripSections); |
Jake Ehrlich | 76e9110 | 2018-01-25 22:46:17 +0000 | [diff] [blame] | 189 | case ELFT_ELF64LE: |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 190 | return llvm::make_unique<ELFWriter<ELF64LE>>(File, Obj, |
| 191 | !Config.StripSections); |
Jake Ehrlich | 76e9110 | 2018-01-25 22:46:17 +0000 | [diff] [blame] | 192 | case ELFT_ELF32BE: |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 193 | return llvm::make_unique<ELFWriter<ELF32BE>>(File, Obj, |
| 194 | !Config.StripSections); |
Jake Ehrlich | 76e9110 | 2018-01-25 22:46:17 +0000 | [diff] [blame] | 195 | case ELFT_ELF64BE: |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 196 | return llvm::make_unique<ELFWriter<ELF64BE>>(File, Obj, |
| 197 | !Config.StripSections); |
Jake Ehrlich | 76e9110 | 2018-01-25 22:46:17 +0000 | [diff] [blame] | 198 | } |
| 199 | llvm_unreachable("Invalid output format"); |
Jake Ehrlich | 5de70d9 | 2017-11-03 18:58:41 +0000 | [diff] [blame] | 200 | } |
| 201 | |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 202 | void SplitDWOToFile(const CopyConfig &Config, const Reader &Reader, |
| 203 | StringRef File, ElfType OutputElfType) { |
Jake Ehrlich | 76e9110 | 2018-01-25 22:46:17 +0000 | [diff] [blame] | 204 | auto DWOFile = Reader.create(); |
| 205 | DWOFile->removeSections( |
| 206 | [&](const SectionBase &Sec) { return OnlyKeepDWOPred(*DWOFile, Sec); }); |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 207 | auto Writer = CreateWriter(Config, *DWOFile, File, OutputElfType); |
Jake Ehrlich | 76e9110 | 2018-01-25 22:46:17 +0000 | [diff] [blame] | 208 | Writer->finalize(); |
| 209 | Writer->write(); |
Jake Ehrlich | 5de70d9 | 2017-11-03 18:58:41 +0000 | [diff] [blame] | 210 | } |
| 211 | |
Jake Ehrlich | ef3b80c | 2017-11-30 20:14:53 +0000 | [diff] [blame] | 212 | // This function handles the high level operations of GNU objcopy including |
| 213 | // handling command line options. It's important to outline certain properties |
| 214 | // we expect to hold of the command line operations. Any operation that "keeps" |
| 215 | // should keep regardless of a remove. Additionally any removal should respect |
| 216 | // any previous removals. Lastly whether or not something is removed shouldn't |
| 217 | // depend a) on the order the options occur in or b) on some opaque priority |
| 218 | // system. The only priority is that keeps/copies overrule removes. |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 219 | void HandleArgs(const CopyConfig &Config, Object &Obj, const Reader &Reader, |
| 220 | ElfType OutputElfType) { |
Jake Ehrlich | 5de70d9 | 2017-11-03 18:58:41 +0000 | [diff] [blame] | 221 | |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 222 | if (!Config.SplitDWO.empty()) { |
| 223 | SplitDWOToFile(Config, Reader, Config.SplitDWO, OutputElfType); |
Jake Ehrlich | 76e9110 | 2018-01-25 22:46:17 +0000 | [diff] [blame] | 224 | } |
Alexander Shaposhnikov | 6e7814c | 2018-05-22 18:24:07 +0000 | [diff] [blame^] | 225 | |
| 226 | // TODO: update or remove symbols only if there is an option that affects them. |
| 227 | if (Obj.SymbolTable) { |
| 228 | Obj.SymbolTable->updateSymbols([&](Symbol &Sym) { |
| 229 | if ((Config.LocalizeHidden && |
| 230 | (Sym.Visibility == STV_HIDDEN || Sym.Visibility == STV_INTERNAL)) || |
| 231 | (!Config.SymbolsToLocalize.empty() && |
| 232 | is_contained(Config.SymbolsToLocalize, Sym.Name))) |
| 233 | Sym.Binding = STB_LOCAL; |
| 234 | |
| 235 | if (!Config.SymbolsToGlobalize.empty() && |
| 236 | is_contained(Config.SymbolsToGlobalize, Sym.Name)) |
| 237 | Sym.Binding = STB_GLOBAL; |
| 238 | |
| 239 | if (!Config.SymbolsToWeaken.empty() && |
| 240 | is_contained(Config.SymbolsToWeaken, Sym.Name) && |
| 241 | Sym.Binding == STB_GLOBAL) |
| 242 | Sym.Binding = STB_WEAK; |
| 243 | |
| 244 | if (Config.Weaken && Sym.Binding == STB_GLOBAL && |
| 245 | Sym.getShndx() != SHN_UNDEF) |
| 246 | Sym.Binding = STB_WEAK; |
| 247 | |
| 248 | const auto I = Config.SymbolsToRename.find(Sym.Name); |
| 249 | if (I != Config.SymbolsToRename.end()) |
| 250 | Sym.Name = I->getValue(); |
| 251 | }); |
| 252 | |
| 253 | Obj.removeSymbols([&](const Symbol &Sym) { |
| 254 | if (!Config.SymbolsToKeep.empty() && |
| 255 | is_contained(Config.SymbolsToKeep, Sym.Name)) |
| 256 | return false; |
| 257 | |
| 258 | if (Config.DiscardAll && Sym.Binding == STB_LOCAL && |
| 259 | Sym.getShndx() != SHN_UNDEF && Sym.Type != STT_FILE && |
| 260 | Sym.Type != STT_SECTION) |
| 261 | return true; |
| 262 | |
| 263 | if (Config.StripAll || Config.StripAllGNU) |
| 264 | return true; |
| 265 | |
| 266 | if (!Config.SymbolsToRemove.empty() && |
| 267 | is_contained(Config.SymbolsToRemove, Sym.Name)) { |
| 268 | return true; |
| 269 | } |
| 270 | |
| 271 | return false; |
| 272 | }); |
| 273 | } |
Jake Ehrlich | 5de70d9 | 2017-11-03 18:58:41 +0000 | [diff] [blame] | 274 | |
Jake Ehrlich | f03384d | 2017-10-11 18:09:18 +0000 | [diff] [blame] | 275 | SectionPred RemovePred = [](const SectionBase &) { return false; }; |
| 276 | |
Jake Ehrlich | ef3b80c | 2017-11-30 20:14:53 +0000 | [diff] [blame] | 277 | // Removes: |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 278 | if (!Config.ToRemove.empty()) { |
| 279 | RemovePred = [&Config](const SectionBase &Sec) { |
| 280 | return std::find(std::begin(Config.ToRemove), std::end(Config.ToRemove), |
| 281 | Sec.Name) != std::end(Config.ToRemove); |
Jake Ehrlich | f03384d | 2017-10-11 18:09:18 +0000 | [diff] [blame] | 282 | }; |
Jake Ehrlich | 36a2eb3 | 2017-10-10 18:47:09 +0000 | [diff] [blame] | 283 | } |
Jake Ehrlich | f03384d | 2017-10-11 18:09:18 +0000 | [diff] [blame] | 284 | |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 285 | if (Config.StripDWO || !Config.SplitDWO.empty()) |
David Blaikie | 998ff81 | 2017-11-03 20:57:09 +0000 | [diff] [blame] | 286 | RemovePred = [RemovePred](const SectionBase &Sec) { |
Jake Ehrlich | 5de70d9 | 2017-11-03 18:58:41 +0000 | [diff] [blame] | 287 | return IsDWOSection(Sec) || RemovePred(Sec); |
| 288 | }; |
| 289 | |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 290 | if (Config.ExtractDWO) |
Jake Ehrlich | 5de70d9 | 2017-11-03 18:58:41 +0000 | [diff] [blame] | 291 | RemovePred = [RemovePred, &Obj](const SectionBase &Sec) { |
Jake Ehrlich | 76e9110 | 2018-01-25 22:46:17 +0000 | [diff] [blame] | 292 | return OnlyKeepDWOPred(Obj, Sec) || RemovePred(Sec); |
Jake Ehrlich | 5de70d9 | 2017-11-03 18:58:41 +0000 | [diff] [blame] | 293 | }; |
| 294 | |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 295 | if (Config.StripAllGNU) |
Jake Ehrlich | fabddf1 | 2017-11-13 22:02:07 +0000 | [diff] [blame] | 296 | RemovePred = [RemovePred, &Obj](const SectionBase &Sec) { |
| 297 | if (RemovePred(Sec)) |
| 298 | return true; |
| 299 | if ((Sec.Flags & SHF_ALLOC) != 0) |
| 300 | return false; |
Jake Ehrlich | 76e9110 | 2018-01-25 22:46:17 +0000 | [diff] [blame] | 301 | if (&Sec == Obj.SectionNames) |
Jake Ehrlich | fabddf1 | 2017-11-13 22:02:07 +0000 | [diff] [blame] | 302 | return false; |
Jake Ehrlich | 777fb00 | 2017-12-15 20:17:55 +0000 | [diff] [blame] | 303 | switch (Sec.Type) { |
Jake Ehrlich | fabddf1 | 2017-11-13 22:02:07 +0000 | [diff] [blame] | 304 | case SHT_SYMTAB: |
| 305 | case SHT_REL: |
| 306 | case SHT_RELA: |
| 307 | case SHT_STRTAB: |
| 308 | return true; |
| 309 | } |
| 310 | return Sec.Name.startswith(".debug"); |
| 311 | }; |
| 312 | |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 313 | if (Config.StripSections) { |
Jake Ehrlich | f03384d | 2017-10-11 18:09:18 +0000 | [diff] [blame] | 314 | RemovePred = [RemovePred](const SectionBase &Sec) { |
| 315 | return RemovePred(Sec) || (Sec.Flags & SHF_ALLOC) == 0; |
| 316 | }; |
Jake Ehrlich | f03384d | 2017-10-11 18:09:18 +0000 | [diff] [blame] | 317 | } |
| 318 | |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 319 | if (Config.StripDebug) { |
Jake Ehrlich | 1bfefc1 | 2017-11-13 22:13:08 +0000 | [diff] [blame] | 320 | RemovePred = [RemovePred](const SectionBase &Sec) { |
| 321 | return RemovePred(Sec) || Sec.Name.startswith(".debug"); |
| 322 | }; |
| 323 | } |
| 324 | |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 325 | if (Config.StripNonAlloc) |
Jake Ehrlich | d56725a | 2017-11-14 18:50:24 +0000 | [diff] [blame] | 326 | RemovePred = [RemovePred, &Obj](const SectionBase &Sec) { |
| 327 | if (RemovePred(Sec)) |
| 328 | return true; |
Jake Ehrlich | 76e9110 | 2018-01-25 22:46:17 +0000 | [diff] [blame] | 329 | if (&Sec == Obj.SectionNames) |
Jake Ehrlich | d56725a | 2017-11-14 18:50:24 +0000 | [diff] [blame] | 330 | return false; |
| 331 | return (Sec.Flags & SHF_ALLOC) == 0; |
| 332 | }; |
| 333 | |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 334 | if (Config.StripAll) |
Jake Ehrlich | 6ad72d0 | 2017-11-27 18:56:01 +0000 | [diff] [blame] | 335 | RemovePred = [RemovePred, &Obj](const SectionBase &Sec) { |
| 336 | if (RemovePred(Sec)) |
| 337 | return true; |
Jake Ehrlich | 76e9110 | 2018-01-25 22:46:17 +0000 | [diff] [blame] | 338 | if (&Sec == Obj.SectionNames) |
Jake Ehrlich | 6ad72d0 | 2017-11-27 18:56:01 +0000 | [diff] [blame] | 339 | return false; |
| 340 | if (Sec.Name.startswith(".gnu.warning")) |
| 341 | return false; |
| 342 | return (Sec.Flags & SHF_ALLOC) == 0; |
| 343 | }; |
| 344 | |
Jake Ehrlich | ef3b80c | 2017-11-30 20:14:53 +0000 | [diff] [blame] | 345 | // Explicit copies: |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 346 | if (!Config.OnlyKeep.empty()) { |
| 347 | RemovePred = [&Config, RemovePred, &Obj](const SectionBase &Sec) { |
Jake Ehrlich | ef3b80c | 2017-11-30 20:14:53 +0000 | [diff] [blame] | 348 | // Explicitly keep these sections regardless of previous removes. |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 349 | if (std::find(std::begin(Config.OnlyKeep), std::end(Config.OnlyKeep), |
| 350 | Sec.Name) != std::end(Config.OnlyKeep)) |
Jake Ehrlich | ef3b80c | 2017-11-30 20:14:53 +0000 | [diff] [blame] | 351 | return false; |
| 352 | |
| 353 | // Allow all implicit removes. |
Jake Ehrlich | 76e9110 | 2018-01-25 22:46:17 +0000 | [diff] [blame] | 354 | if (RemovePred(Sec)) |
Jake Ehrlich | ef3b80c | 2017-11-30 20:14:53 +0000 | [diff] [blame] | 355 | return true; |
Jake Ehrlich | ef3b80c | 2017-11-30 20:14:53 +0000 | [diff] [blame] | 356 | |
| 357 | // Keep special sections. |
Jake Ehrlich | 76e9110 | 2018-01-25 22:46:17 +0000 | [diff] [blame] | 358 | if (Obj.SectionNames == &Sec) |
Jake Ehrlich | ef3b80c | 2017-11-30 20:14:53 +0000 | [diff] [blame] | 359 | return false; |
Jake Ehrlich | 76e9110 | 2018-01-25 22:46:17 +0000 | [diff] [blame] | 360 | if (Obj.SymbolTable == &Sec || Obj.SymbolTable->getStrTab() == &Sec) |
Jake Ehrlich | ef3b80c | 2017-11-30 20:14:53 +0000 | [diff] [blame] | 361 | return false; |
Jake Ehrlich | 76e9110 | 2018-01-25 22:46:17 +0000 | [diff] [blame] | 362 | |
Jake Ehrlich | ef3b80c | 2017-11-30 20:14:53 +0000 | [diff] [blame] | 363 | // Remove everything else. |
| 364 | return true; |
| 365 | }; |
| 366 | } |
| 367 | |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 368 | if (!Config.Keep.empty()) { |
| 369 | RemovePred = [Config, RemovePred](const SectionBase &Sec) { |
Jake Ehrlich | ef3b80c | 2017-11-30 20:14:53 +0000 | [diff] [blame] | 370 | // Explicitly keep these sections regardless of previous removes. |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 371 | if (std::find(std::begin(Config.Keep), std::end(Config.Keep), Sec.Name) != |
| 372 | std::end(Config.Keep)) |
Jake Ehrlich | ef3b80c | 2017-11-30 20:14:53 +0000 | [diff] [blame] | 373 | return false; |
| 374 | // Otherwise defer to RemovePred. |
| 375 | return RemovePred(Sec); |
| 376 | }; |
| 377 | } |
| 378 | |
Alexander Shaposhnikov | 6e7814c | 2018-05-22 18:24:07 +0000 | [diff] [blame^] | 379 | // This has to be the last predicate assignment. |
| 380 | // If the option --keep-symbol has been specified |
| 381 | // and at least one of those symbols is present |
| 382 | // (equivalently, the updated symbol table is not empty) |
| 383 | // the symbol table and the string table should not be removed. |
| 384 | if (!Config.SymbolsToKeep.empty() && !Obj.SymbolTable->empty()) { |
| 385 | RemovePred = [&Obj, RemovePred](const SectionBase &Sec) { |
| 386 | if (&Sec == Obj.SymbolTable || &Sec == Obj.SymbolTable->getStrTab()) |
| 387 | return false; |
| 388 | return RemovePred(Sec); |
| 389 | }; |
| 390 | } |
| 391 | |
Jake Ehrlich | 76e9110 | 2018-01-25 22:46:17 +0000 | [diff] [blame] | 392 | Obj.removeSections(RemovePred); |
Jake Ehrlich | e8437de | 2017-12-19 00:47:30 +0000 | [diff] [blame] | 393 | |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 394 | if (!Config.AddSection.empty()) { |
| 395 | for (const auto &Flag : Config.AddSection) { |
| 396 | auto SecPair = Flag.split("="); |
Jake Ehrlich | e8437de | 2017-12-19 00:47:30 +0000 | [diff] [blame] | 397 | auto SecName = SecPair.first; |
| 398 | auto File = SecPair.second; |
| 399 | auto BufOrErr = MemoryBuffer::getFile(File); |
| 400 | if (!BufOrErr) |
| 401 | reportError(File, BufOrErr.getError()); |
| 402 | auto Buf = std::move(*BufOrErr); |
| 403 | auto BufPtr = reinterpret_cast<const uint8_t *>(Buf->getBufferStart()); |
| 404 | auto BufSize = Buf->getBufferSize(); |
Jake Ehrlich | 76e9110 | 2018-01-25 22:46:17 +0000 | [diff] [blame] | 405 | Obj.addSection<OwnedDataSection>(SecName, |
| 406 | ArrayRef<uint8_t>(BufPtr, BufSize)); |
Jake Ehrlich | e8437de | 2017-12-19 00:47:30 +0000 | [diff] [blame] | 407 | } |
| 408 | } |
| 409 | |
Alexander Shaposhnikov | 40e9bdf | 2018-04-26 18:28:17 +0000 | [diff] [blame] | 410 | if (!Config.AddGnuDebugLink.empty()) |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 411 | Obj.addSection<GnuDebugLinkSection>(Config.AddGnuDebugLink); |
Jake Ehrlich | 76e9110 | 2018-01-25 22:46:17 +0000 | [diff] [blame] | 412 | } |
Jake Ehrlich | ea07d3c | 2018-01-25 22:15:14 +0000 | [diff] [blame] | 413 | |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 414 | std::unique_ptr<Reader> CreateReader(StringRef InputFilename, |
| 415 | ElfType &OutputElfType) { |
Jake Ehrlich | 76e9110 | 2018-01-25 22:46:17 +0000 | [diff] [blame] | 416 | // Right now we can only read ELF files so there's only one reader; |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 417 | auto Out = llvm::make_unique<ELFReader>(InputFilename); |
Jake Ehrlich | 76e9110 | 2018-01-25 22:46:17 +0000 | [diff] [blame] | 418 | // We need to set the default ElfType for output. |
| 419 | OutputElfType = Out->getElfType(); |
| 420 | return std::move(Out); |
Petr Hosek | 05a04cb | 2017-08-01 00:33:58 +0000 | [diff] [blame] | 421 | } |
| 422 | |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 423 | void ExecuteElfObjcopy(const CopyConfig &Config) { |
| 424 | ElfType OutputElfType; |
| 425 | auto Reader = CreateReader(Config.InputFilename, OutputElfType); |
Jake Ehrlich | a8c689e | 2018-04-12 00:40:50 +0000 | [diff] [blame] | 426 | auto Obj = Reader->create(); |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 427 | auto Writer = |
| 428 | CreateWriter(Config, *Obj, Config.OutputFilename, OutputElfType); |
| 429 | HandleArgs(Config, *Obj, *Reader, OutputElfType); |
Jake Ehrlich | a8c689e | 2018-04-12 00:40:50 +0000 | [diff] [blame] | 430 | Writer->finalize(); |
| 431 | Writer->write(); |
Petr Hosek | 05a04cb | 2017-08-01 00:33:58 +0000 | [diff] [blame] | 432 | } |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 433 | |
| 434 | // ParseObjcopyOptions returns the config and sets the input arguments. If a |
| 435 | // help flag is set then ParseObjcopyOptions will print the help messege and |
| 436 | // exit. |
| 437 | CopyConfig ParseObjcopyOptions(ArrayRef<const char *> ArgsArr) { |
| 438 | ObjcopyOptTable T; |
| 439 | unsigned MissingArgumentIndex, MissingArgumentCount; |
| 440 | llvm::opt::InputArgList InputArgs = |
| 441 | T.ParseArgs(ArgsArr, MissingArgumentIndex, MissingArgumentCount); |
Alexander Shaposhnikov | d29bf4c | 2018-05-18 04:18:41 +0000 | [diff] [blame] | 442 | |
Alexander Shaposhnikov | b07c22b | 2018-05-08 17:12:54 +0000 | [diff] [blame] | 443 | if (InputArgs.size() == 0) { |
| 444 | T.PrintHelp(errs(), "llvm-objcopy <input> [ <output> ]", "objcopy tool"); |
| 445 | exit(1); |
| 446 | } |
Alexander Shaposhnikov | d29bf4c | 2018-05-18 04:18:41 +0000 | [diff] [blame] | 447 | |
Alexander Shaposhnikov | b07c22b | 2018-05-08 17:12:54 +0000 | [diff] [blame] | 448 | if (InputArgs.hasArg(OBJCOPY_help)) { |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 449 | T.PrintHelp(outs(), "llvm-objcopy <input> [ <output> ]", "objcopy tool"); |
| 450 | exit(0); |
| 451 | } |
| 452 | |
| 453 | SmallVector<const char *, 2> Positional; |
| 454 | |
| 455 | for (auto Arg : InputArgs.filtered(OBJCOPY_UNKNOWN)) |
| 456 | error("unknown argument '" + Arg->getAsString(InputArgs) + "'"); |
| 457 | |
| 458 | for (auto Arg : InputArgs.filtered(OBJCOPY_INPUT)) |
| 459 | Positional.push_back(Arg->getValue()); |
| 460 | |
| 461 | if (Positional.empty()) |
| 462 | error("No input file specified"); |
| 463 | |
| 464 | if (Positional.size() > 2) |
| 465 | error("Too many positional arguments"); |
| 466 | |
| 467 | CopyConfig Config; |
| 468 | Config.InputFilename = Positional[0]; |
| 469 | Config.OutputFilename = Positional[Positional.size() == 1 ? 0 : 1]; |
| 470 | Config.InputFormat = InputArgs.getLastArgValue(OBJCOPY_input_target); |
| 471 | Config.OutputFormat = InputArgs.getLastArgValue(OBJCOPY_output_target); |
| 472 | Config.BinaryArch = InputArgs.getLastArgValue(OBJCOPY_binary_architecture); |
| 473 | |
| 474 | Config.SplitDWO = InputArgs.getLastArgValue(OBJCOPY_split_dwo); |
| 475 | Config.AddGnuDebugLink = InputArgs.getLastArgValue(OBJCOPY_add_gnu_debuglink); |
Alexander Shaposhnikov | 40e9bdf | 2018-04-26 18:28:17 +0000 | [diff] [blame] | 476 | |
| 477 | for (auto Arg : InputArgs.filtered(OBJCOPY_redefine_symbol)) { |
| 478 | if (!StringRef(Arg->getValue()).contains('=')) |
| 479 | error("Bad format for --redefine-sym"); |
| 480 | auto Old2New = StringRef(Arg->getValue()).split('='); |
| 481 | if (!Config.SymbolsToRename.insert(Old2New).second) |
| 482 | error("Multiple redefinition of symbol " + Old2New.first); |
| 483 | } |
| 484 | |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 485 | for (auto Arg : InputArgs.filtered(OBJCOPY_remove_section)) |
| 486 | Config.ToRemove.push_back(Arg->getValue()); |
| 487 | for (auto Arg : InputArgs.filtered(OBJCOPY_keep)) |
| 488 | Config.Keep.push_back(Arg->getValue()); |
| 489 | for (auto Arg : InputArgs.filtered(OBJCOPY_only_keep)) |
| 490 | Config.OnlyKeep.push_back(Arg->getValue()); |
| 491 | for (auto Arg : InputArgs.filtered(OBJCOPY_add_section)) |
| 492 | Config.AddSection.push_back(Arg->getValue()); |
| 493 | Config.StripAll = InputArgs.hasArg(OBJCOPY_strip_all); |
| 494 | Config.StripAllGNU = InputArgs.hasArg(OBJCOPY_strip_all_gnu); |
| 495 | Config.StripDebug = InputArgs.hasArg(OBJCOPY_strip_debug); |
| 496 | Config.StripDWO = InputArgs.hasArg(OBJCOPY_strip_dwo); |
| 497 | Config.StripSections = InputArgs.hasArg(OBJCOPY_strip_sections); |
| 498 | Config.StripNonAlloc = InputArgs.hasArg(OBJCOPY_strip_non_alloc); |
| 499 | Config.ExtractDWO = InputArgs.hasArg(OBJCOPY_extract_dwo); |
| 500 | Config.LocalizeHidden = InputArgs.hasArg(OBJCOPY_localize_hidden); |
Paul Semel | 2c0510f | 2018-05-02 20:14:49 +0000 | [diff] [blame] | 501 | Config.Weaken = InputArgs.hasArg(OBJCOPY_weaken); |
Paul Semel | 41695f8 | 2018-05-02 20:19:22 +0000 | [diff] [blame] | 502 | Config.DiscardAll = InputArgs.hasArg(OBJCOPY_discard_all); |
Jake Ehrlich | e40398a | 2018-05-15 20:53:53 +0000 | [diff] [blame] | 503 | Config.OnlyKeepDebug = InputArgs.hasArg(OBJCOPY_only_keep_debug); |
Paul Semel | b492494 | 2018-04-26 17:44:43 +0000 | [diff] [blame] | 504 | for (auto Arg : InputArgs.filtered(OBJCOPY_localize_symbol)) |
Alexander Shaposhnikov | 40e9bdf | 2018-04-26 18:28:17 +0000 | [diff] [blame] | 505 | Config.SymbolsToLocalize.push_back(Arg->getValue()); |
Paul Semel | ee5be79 | 2018-04-27 19:09:44 +0000 | [diff] [blame] | 506 | for (auto Arg : InputArgs.filtered(OBJCOPY_globalize_symbol)) |
| 507 | Config.SymbolsToGlobalize.push_back(Arg->getValue()); |
Paul Semel | 3a8a56b | 2018-04-27 19:16:27 +0000 | [diff] [blame] | 508 | for (auto Arg : InputArgs.filtered(OBJCOPY_weaken_symbol)) |
| 509 | Config.SymbolsToWeaken.push_back(Arg->getValue()); |
Paul Semel | 4246a46 | 2018-05-09 21:36:54 +0000 | [diff] [blame] | 510 | for (auto Arg : InputArgs.filtered(OBJCOPY_strip_symbol)) |
| 511 | Config.SymbolsToRemove.push_back(Arg->getValue()); |
Paul Semel | 5d97c82 | 2018-05-15 14:09:37 +0000 | [diff] [blame] | 512 | for (auto Arg : InputArgs.filtered(OBJCOPY_keep_symbol)) |
| 513 | Config.SymbolsToKeep.push_back(Arg->getValue()); |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 514 | |
| 515 | return Config; |
| 516 | } |
| 517 | |
Alexander Shaposhnikov | cca6998 | 2018-05-07 19:32:09 +0000 | [diff] [blame] | 518 | // ParseStripOptions returns the config and sets the input arguments. If a |
| 519 | // help flag is set then ParseStripOptions will print the help messege and |
| 520 | // exit. |
| 521 | CopyConfig ParseStripOptions(ArrayRef<const char *> ArgsArr) { |
| 522 | StripOptTable T; |
| 523 | unsigned MissingArgumentIndex, MissingArgumentCount; |
| 524 | llvm::opt::InputArgList InputArgs = |
| 525 | T.ParseArgs(ArgsArr, MissingArgumentIndex, MissingArgumentCount); |
| 526 | |
Alexander Shaposhnikov | b07c22b | 2018-05-08 17:12:54 +0000 | [diff] [blame] | 527 | if (InputArgs.size() == 0) { |
| 528 | T.PrintHelp(errs(), "llvm-strip <input> [ <output> ]", "strip tool"); |
| 529 | exit(1); |
| 530 | } |
Alexander Shaposhnikov | d29bf4c | 2018-05-18 04:18:41 +0000 | [diff] [blame] | 531 | |
Alexander Shaposhnikov | b07c22b | 2018-05-08 17:12:54 +0000 | [diff] [blame] | 532 | if (InputArgs.hasArg(STRIP_help)) { |
Alexander Shaposhnikov | cca6998 | 2018-05-07 19:32:09 +0000 | [diff] [blame] | 533 | T.PrintHelp(outs(), "llvm-strip <input> [ <output> ]", "strip tool"); |
| 534 | exit(0); |
| 535 | } |
| 536 | |
| 537 | SmallVector<const char *, 2> Positional; |
| 538 | for (auto Arg : InputArgs.filtered(STRIP_UNKNOWN)) |
| 539 | error("unknown argument '" + Arg->getAsString(InputArgs) + "'"); |
| 540 | for (auto Arg : InputArgs.filtered(STRIP_INPUT)) |
| 541 | Positional.push_back(Arg->getValue()); |
| 542 | |
| 543 | if (Positional.empty()) |
| 544 | error("No input file specified"); |
| 545 | |
| 546 | if (Positional.size() > 2) |
| 547 | error("Support for multiple input files is not implemented yet"); |
| 548 | |
| 549 | CopyConfig Config; |
| 550 | Config.InputFilename = Positional[0]; |
| 551 | Config.OutputFilename = Positional[0]; |
| 552 | |
| 553 | // Strip debug info only. |
| 554 | Config.StripDebug = InputArgs.hasArg(STRIP_strip_debug); |
| 555 | if (!Config.StripDebug) |
| 556 | Config.StripAll = true; |
Alexander Shaposhnikov | d29bf4c | 2018-05-18 04:18:41 +0000 | [diff] [blame] | 557 | |
Alexander Shaposhnikov | 18b5fb7 | 2018-05-11 05:27:06 +0000 | [diff] [blame] | 558 | for (auto Arg : InputArgs.filtered(STRIP_remove_section)) |
| 559 | Config.ToRemove.push_back(Arg->getValue()); |
| 560 | |
Alexander Shaposhnikov | cca6998 | 2018-05-07 19:32:09 +0000 | [diff] [blame] | 561 | return Config; |
| 562 | } |
| 563 | |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 564 | int main(int argc, char **argv) { |
| 565 | InitLLVM X(argc, argv); |
| 566 | ToolName = argv[0]; |
Alexander Shaposhnikov | cca6998 | 2018-05-07 19:32:09 +0000 | [diff] [blame] | 567 | CopyConfig Config; |
| 568 | if (sys::path::stem(ToolName).endswith_lower("strip")) |
| 569 | Config = ParseStripOptions(makeArrayRef(argv + 1, argc)); |
| 570 | else |
| 571 | Config = ParseObjcopyOptions(makeArrayRef(argv + 1, argc)); |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 572 | ExecuteElfObjcopy(Config); |
| 573 | } |