Skip to content

Commit 02fb5c0

Browse files
committed
Made Changes
1 parent 718edfe commit 02fb5c0

File tree

5 files changed

+18
-14
lines changed

5 files changed

+18
-14
lines changed

llvm/include/llvm/ObjCopy/CommonConfig.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ struct CommonConfig {
274274
bool StripNonAlloc = false;
275275
bool StripSections = false;
276276
bool StripUnneeded = false;
277+
bool Verbose = false;
277278
bool Weaken = false;
278279
bool DecompressDebugSections = false;
279280

llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,7 @@ static Error verifyNoteSection(StringRef Name, endianness Endianness,
782782
// system. The only priority is that keeps/copies overrule removes.
783783
static Error handleArgs(const CommonConfig &Config, const ELFConfig &ELFConfig,
784784
ElfType OutputElfType, Object &Obj) {
785+
Obj.isVerboseEnabled = Config.Verbose;
785786
if (Config.OutputArch) {
786787
Obj.Machine = Config.OutputArch->EMachine;
787788
Obj.OSABI = Config.OutputArch->OSABI;

llvm/lib/ObjCopy/ELF/ELFObject.cpp

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ Error SymbolTableSection::removeSymbols(
768768
std::remove_if(std::begin(Symbols) + 1, std::end(Symbols),
769769
[ToRemove](const SymPtr &Sym) {
770770
if (ToRemove(*Sym)) {
771-
dbgs()<<"Symbols Removed:"<<Sym->Name<< "\n";
771+
llvm::outs() << "Symbols Removed:" << Sym->Name<< "\n";
772772
return true;
773773
}
774774
return false;
@@ -2236,6 +2236,9 @@ Error Object::removeSections(
22362236
for (auto &RemoveSec : make_range(Iter, std::end(Sections))) {
22372237
for (auto &Segment : Segments)
22382238
Segment->removeSection(RemoveSec.get());
2239+
if (isVerboseEnabled) {
2240+
llvm::outs() << "Removed Section: " << (RemoveSec.get()->Name);
2241+
}
22392242
RemoveSec->onRemove();
22402243
RemoveSections.insert(RemoveSec.get());
22412244
}
@@ -2255,18 +2258,10 @@ Error Object::removeSections(
22552258

22562259
// Transfer removed sections into the Object RemovedSections container for use
22572260
// later.
2258-
for(auto &KeepSec : make_range(std::begin(Sections) , Iter))
2259-
{
2260-
2261-
if (Error E = KeepSec->removeSectionReferences(
2262-
AllowBrokenLinks, [&RemoveSections](const SectionBase *Sec) {
2263-
return RemoveSections.find(Sec) != RemoveSections.end();
2264-
}))
2265-
std::move(Iter, Sections.end(), std::back_inserter(RemovedSections));
2266-
dbgs()<<"Sections Removed:"<<KeepSec->Name<<'\n';
2267-
Sections.erase(Iter, std::end(Sections));
2268-
return Error::success();
2269-
}
2261+
std::move(Iter, Sections.end(), std::back_inserter(RemovedSections));
2262+
// Now finally get rid of them all together.
2263+
Sections.erase(Iter, std::end(Sections));
2264+
return Error::success();
22702265
}
22712266

22722267
Error Object::replaceSections(
@@ -2296,8 +2291,12 @@ Error Object::replaceSections(
22962291
Error Object::removeSymbols(function_ref<bool(const Symbol &)> ToRemove) {
22972292
if (SymbolTable)
22982293
for (const SecPtr &Sec : Sections)
2299-
if (Error E = Sec->removeSymbols(ToRemove))
2294+
if (Error E = Sec->removeSymbols(ToRemove)){
2295+
if (isVerboseEnabled){
2296+
llvm::outs() << "Removed Symbols:" << Sec->Name;
2297+
}
23002298
return E;
2299+
}
23012300
return Error::success();
23022301
}
23032302

llvm/lib/ObjCopy/ELF/ELFObject.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,6 +1195,7 @@ class Object {
11951195
uint32_t Flags;
11961196

11971197
bool HadShdrs = true;
1198+
bool isVerboseEnabled = true;
11981199
bool MustBeRelocatable = false;
11991200
StringTableSection *SectionNames = nullptr;
12001201
SymbolTableSection *SymbolTable = nullptr;

llvm/tools/llvm-objcopy/ObjcopyOptions.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,7 @@ objcopy::parseObjcopyOptions(ArrayRef<const char *> ArgsArr,
11031103
OBJCOPY_verify_note_sections, OBJCOPY_no_verify_note_sections, true);
11041104

11051105
Config.OnlyKeepDebug = InputArgs.hasArg(OBJCOPY_only_keep_debug);
1106+
Config.Verbose = InputArgs.hasArg(OBJCOPY_verbose);
11061107
ELFConfig.KeepFileSymbols = InputArgs.hasArg(OBJCOPY_keep_file_symbols);
11071108
MachOConfig.KeepUndefined = InputArgs.hasArg(OBJCOPY_keep_undefined);
11081109
Config.DecompressDebugSections =
@@ -1586,6 +1587,7 @@ objcopy::parseStripOptions(ArrayRef<const char *> RawArgsArr,
15861587
Config.StripAllGNU = InputArgs.hasArg(STRIP_strip_all_gnu);
15871588
MachOConfig.StripSwiftSymbols = InputArgs.hasArg(STRIP_strip_swift_symbols);
15881589
Config.OnlyKeepDebug = InputArgs.hasArg(STRIP_only_keep_debug);
1590+
Config.Verbose = InputArgs.hasArg(STRIP_verbose);
15891591
ELFConfig.KeepFileSymbols = InputArgs.hasArg(STRIP_keep_file_symbols);
15901592
MachOConfig.KeepUndefined = InputArgs.hasArg(STRIP_keep_undefined);
15911593

0 commit comments

Comments
 (0)