[llvm] [llvm-objdump] Support --mcpu=help/--mattr=help without -d (PR #165661)
Ruoyu Qiu via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 10 02:05:25 PST 2025
================
@@ -3826,20 +3853,33 @@ int llvm_objdump_main(int argc, char **argv, const llvm::ToolContext &) {
!DisassembleSymbols.empty())
Disassemble = true;
- if (!ArchiveHeaders && !Disassemble && DwarfDumpType == DIDT_Null &&
- !DynamicRelocations && !FileHeaders && !PrivateHeaders && !RawClangAST &&
- !Relocations && !SectionHeaders && !SectionContents && !SymbolTable &&
- !DynamicSymbolTable && !UnwindInfo && !FaultMapSection && !Offloading &&
- !(MachOOpt &&
- (Bind || DataInCode || ChainedFixups || DyldInfo || DylibId ||
- DylibsUsed || ExportsTrie || FirstPrivateHeader ||
- FunctionStartsType != FunctionStartsMode::None || IndirectSymbols ||
- InfoPlist || LazyBind || LinkOptHints || ObjcMetaData || Rebase ||
- Rpaths || UniversalHeaders || WeakBind || !FilterSections.empty()))) {
+ const bool PrintCpuHelp = (MCPU == "help" || is_contained(MAttrs, "help"));
+
+ const bool ShouldDump =
+ ArchiveHeaders || Disassemble || DwarfDumpType != DIDT_Null ||
+ DynamicRelocations || FileHeaders || PrivateHeaders || RawClangAST ||
+ Relocations || SectionHeaders || SectionContents || SymbolTable ||
+ DynamicSymbolTable || UnwindInfo || FaultMapSection || Offloading ||
+ (MachOOpt &&
+ (Bind || DataInCode || ChainedFixups || DyldInfo || DylibId ||
+ DylibsUsed || ExportsTrie || FirstPrivateHeader ||
+ FunctionStartsType != FunctionStartsMode::None || IndirectSymbols ||
+ InfoPlist || LazyBind || LinkOptHints || ObjcMetaData || Rebase ||
+ Rpaths || UniversalHeaders || WeakBind || !FilterSections.empty()));
+
+ if (!ShouldDump && !PrintCpuHelp) {
T->printHelp(ToolName);
return 2;
}
+ // If the target triple is derived from the files, we display help message
+ // when disassembling them.
+ if (!Disassemble && PrintCpuHelp) {
----------------
cabbaken wrote:
Yes, that is correct. The output from `PrintCpuHelp` is identical to `!Disassemble && PrintCpuHelp`.
Furthermore, `llvm-objdump --triple=x86_64 --mcpu=help arm.o` will output the X86 help message using `PrintCpuHelp`.
https://github.com/llvm/llvm-project/pull/165661
More information about the llvm-commits
mailing list