[llvm-objcopy] Add few file processing directives

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353521 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eugene Leviant
2019-02-08 14:37:54 +00:00
parent 005af434d1
commit e436b1687a
6 changed files with 78 additions and 5 deletions
+17 -5
View File
@@ -226,9 +226,9 @@ static const MachineInfo &getOutputFormatMachineInfo(StringRef Format) {
return Iter->getValue();
}
static void addGlobalSymbolsFromFile(std::vector<NameOrRegex> &Symbols,
BumpPtrAllocator &Alloc,
StringRef Filename, bool UseRegex) {
static void addSymbolsFromFile(std::vector<NameOrRegex> &Symbols,
BumpPtrAllocator &Alloc, StringRef Filename,
bool UseRegex) {
StringSaver Saver(Alloc);
SmallVector<StringRef, 16> Lines;
auto BufOrErr = MemoryBuffer::getFile(Filename);
@@ -445,17 +445,29 @@ DriverConfig parseObjcopyOptions(ArrayRef<const char *> ArgsArr) {
InputArgs.hasArg(OBJCOPY_decompress_debug_sections);
for (auto Arg : InputArgs.filtered(OBJCOPY_localize_symbol))
Config.SymbolsToLocalize.emplace_back(Arg->getValue(), UseRegex);
for (auto Arg : InputArgs.filtered(OBJCOPY_localize_symbols))
addSymbolsFromFile(Config.SymbolsToLocalize, DC.Alloc, Arg->getValue(),
UseRegex);
for (auto Arg : InputArgs.filtered(OBJCOPY_keep_global_symbol))
Config.SymbolsToKeepGlobal.emplace_back(Arg->getValue(), UseRegex);
for (auto Arg : InputArgs.filtered(OBJCOPY_keep_global_symbols))
addGlobalSymbolsFromFile(Config.SymbolsToKeepGlobal, DC.Alloc,
Arg->getValue(), UseRegex);
addSymbolsFromFile(Config.SymbolsToKeepGlobal, DC.Alloc, Arg->getValue(),
UseRegex);
for (auto Arg : InputArgs.filtered(OBJCOPY_globalize_symbol))
Config.SymbolsToGlobalize.emplace_back(Arg->getValue(), UseRegex);
for (auto Arg : InputArgs.filtered(OBJCOPY_globalize_symbols))
addSymbolsFromFile(Config.SymbolsToGlobalize, DC.Alloc, Arg->getValue(),
UseRegex);
for (auto Arg : InputArgs.filtered(OBJCOPY_weaken_symbol))
Config.SymbolsToWeaken.emplace_back(Arg->getValue(), UseRegex);
for (auto Arg : InputArgs.filtered(OBJCOPY_weaken_symbols))
addSymbolsFromFile(Config.SymbolsToWeaken, DC.Alloc, Arg->getValue(),
UseRegex);
for (auto Arg : InputArgs.filtered(OBJCOPY_strip_symbol))
Config.SymbolsToRemove.emplace_back(Arg->getValue(), UseRegex);
for (auto Arg : InputArgs.filtered(OBJCOPY_strip_symbols))
addSymbolsFromFile(Config.SymbolsToRemove, DC.Alloc, Arg->getValue(),
UseRegex);
for (auto Arg : InputArgs.filtered(OBJCOPY_keep_symbol))
Config.SymbolsToKeep.emplace_back(Arg->getValue(), UseRegex);