// This test checks that --section works correctly
// RUN: llvm-objdump -h %p/Inputs/section-filter.obj -j=.text \
-// RUN: -j=.bss | FileCheck %s
+// RUN: --section=.bss | FileCheck %s
# CHECK: .text
# CHECK-NOT: .data
cl::desc("Print the linker optimization hints for "
"Mach-O objects (requires -macho)"));
-cl::list<std::string>
- llvm::DumpSections("section",
- cl::desc("Prints the specified segment,section for "
- "Mach-O objects (requires -macho)"));
-
cl::opt<bool>
llvm::InfoPlist("info-plist",
cl::desc("Print the info plist section as strings for "
if (verbose)
CreateSymbolAddressMap(O, &AddrMap);
- for (unsigned i = 0; i < DumpSections.size(); ++i) {
- StringRef DumpSection = DumpSections[i];
+ for (unsigned i = 0; i < FilterSections.size(); ++i) {
+ StringRef DumpSection = FilterSections[i];
std::pair<StringRef, StringRef> DumpSegSectName;
DumpSegSectName = DumpSection.split(',');
StringRef DumpSegName, DumpSectName;
// UniversalHeaders or ArchiveHeaders.
if (Disassemble || PrivateHeaders || ExportsTrie || Rebase || Bind ||
LazyBind || WeakBind || IndirectSymbols || DataInCode || LinkOptHints ||
- DylibsUsed || DylibId || ObjcMetaData || (DumpSections.size() != 0)) {
+ DylibsUsed || DylibId || ObjcMetaData || (FilterSections.size() != 0)) {
outs() << Filename;
if (!ArchiveMemberName.empty())
outs() << '(' << ArchiveMemberName << ')';
PrintSectionHeaders(MachOOF);
if (SectionContents)
PrintSectionContents(MachOOF);
- if (DumpSections.size() != 0)
+ if (FilterSections.size() != 0)
DumpSectionContents(Filename, MachOOF, !NonVerbose);
if (InfoPlist)
DumpInfoPlistSectionContents(Filename, MachOOF);
diContext.reset(new DWARFContextInMemory(*DbgObj));
}
- if (DumpSections.size() == 0)
+ if (FilterSections.size() == 0)
outs() << "(" << DisSegName << "," << DisSectName << ") section\n";
for (unsigned SectIdx = 0; SectIdx != Sections.size(); SectIdx++) {
static cl::alias
SectionHeadersShorter("h", cl::desc("Alias for --section-headers"),
cl::aliasopt(SectionHeaders));
+
cl::list<std::string>
-llvm::Sections("j", cl::desc("Operate on the specified sections only"));
+llvm::FilterSections("section", cl::desc("Operate on the specified sections only. "
+ "With -macho dump segment,section"));
+cl::alias
+static FilterSectionsj("j", cl::desc("Alias for --section"),
+ cl::aliasopt(llvm::FilterSections));
cl::list<std::string>
llvm::MAttrs("mattr",
static int ReturnValue = EXIT_SUCCESS;
namespace {
-typedef std::function<int(llvm::object::SectionRef const &)> FilterPredicate;
+typedef std::function<bool(llvm::object::SectionRef const &)> FilterPredicate;
class SectionFilterIterator {
public:
llvm::object::ObjectFile const &Object;
};
SectionFilter ToolSectionFilter(llvm::object::ObjectFile const &O) {
- if (Sections.empty()) {
- return SectionFilter([](llvm::object::SectionRef const &) { return 0; }, O);
- }
return SectionFilter([](llvm::object::SectionRef const &S) {
+ if(FilterSections.empty())
+ return false;
llvm::StringRef String;
std::error_code error = S.getName(String);
- if (error) {
- return error.value();
- }
- if (std::find(Sections.begin(), Sections.end(),
- String) != Sections.end()) {
- return 0;
- }
- return 1;
+ if (error)
+ return true;
+ return std::find(FilterSections.begin(),
+ FilterSections.end(),
+ String) == FilterSections.end();
},
O);
}
&& !(DylibsUsed && MachOOpt)
&& !(DylibId && MachOOpt)
&& !(ObjcMetaData && MachOOpt)
- && !(DumpSections.size() != 0 && MachOOpt)
+ && !(FilterSections.size() != 0 && MachOOpt)
&& !PrintFaultMaps) {
cl::PrintHelpMessage();
return 2;
extern cl::opt<std::string> ArchName;
extern cl::opt<std::string> MCPU;
extern cl::list<std::string> MAttrs;
-extern cl::list<std::string> Sections;
-extern cl::list<std::string> DumpSections;
+extern cl::list<std::string> FilterSections;
extern cl::opt<bool> Disassemble;
extern cl::opt<bool> DisassembleAll;
extern cl::opt<bool> NoShowRawInsn;