[llvm] [llvm-objcopy] Add llvm-objcopy option --set-visibility-sym (PR #80872)
James Henderson via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 8 00:38:56 PST 2024
================
@@ -962,6 +977,34 @@ objcopy::parseObjcopyOptions(ArrayRef<const char *> RawArgsArr,
Config.SymbolsToAdd.push_back(*SymInfo);
}
+ for (auto *Arg : InputArgs.filtered(OBJCOPY_set_visibility_sym)) {
+ if (!StringRef(Arg->getValue()).contains('='))
+ return createStringError(errc::invalid_argument,
+ "bad format for --set-visibility-sym");
+ auto SymAndVis = StringRef(Arg->getValue()).split('=');
+ Expected<uint8_t> Type = parseVisibilityType(SymAndVis.second);
+ if (!Type)
+ return Type.takeError();
+ ELFConfig.SetVisibilityType = Type.get();
+ if (Error E =
+ ELFConfig.SymbolsToSetVisibility.addMatcher(NameOrPattern::create(
+ SymAndVis.first, SymbolMatchStyle, ErrorCallback)))
+ return std::move(E);
+ }
+ for (auto *Arg : InputArgs.filtered(OBJCOPY_set_visibility_syms)) {
+ if (!StringRef(Arg->getValue()).contains('='))
+ return createStringError(errc::invalid_argument,
+ "bad format for --set-visibility-syms");
+ auto FileAndVis = StringRef(Arg->getValue()).split('=');
+ Expected<uint8_t> Type = parseVisibilityType(FileAndVis.second);
+ if (!Type)
+ return Type.takeError();
+ ELFConfig.SetVisibilityType = Type.get();
+ if (Error E = addSymbolsFromFile(ELFConfig.SymbolsToSetVisibility, DC.Alloc,
+ FileAndVis.first, SymbolMatchStyle,
+ ErrorCallback))
+ return std::move(E);
----------------
jh7370 wrote:
Test case?
https://github.com/llvm/llvm-project/pull/80872
More information about the llvm-commits
mailing list