diff options
Diffstat (limited to 'llvm/tools/llvm-objcopy/llvm-objcopy.cpp')
-rw-r--r-- | llvm/tools/llvm-objcopy/llvm-objcopy.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp index 20ce93bb40e..eb1d0de90d5 100644 --- a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp +++ b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp @@ -117,6 +117,10 @@ static cl::list<std::string> AddSection( "add-section", cl::desc("Make a section named <section> with the contents of <file>."), cl::value_desc("section=file")); +static cl::opt<bool> LocalizeHidden( + "localize-hidden", + cl::desc( + "Mark all symbols that have hidden or internal visibility as local")); using SectionPred = std::function<bool(const SectionBase &Sec)>; @@ -180,6 +184,14 @@ template <class ELFT> void CopyBinary(const ELFObjectFile<ELFT> &ObjFile) { if (!SplitDWO.empty()) SplitDWOToFile<ELFT>(ObjFile, SplitDWO.getValue()); + // Localize: + + if (LocalizeHidden) { + Obj->getSymTab()->localize([](const Symbol &Sym) { + return Sym.Visibility == STV_HIDDEN || Sym.Visibility == STV_INTERNAL; + }); + } + SectionPred RemovePred = [](const SectionBase &) { return false; }; // Removes: |