Index: test/tools/llvm-readobj/gnu-sections.test =================================================================== --- test/tools/llvm-readobj/gnu-sections.test +++ test/tools/llvm-readobj/gnu-sections.test @@ -8,6 +8,8 @@ RUN: llvm-readobj -W --sections \ RUN: %p/Inputs/relocs.obj.elf-x86_64 --elf-output-style=GNU \ RUN: | FileCheck %s -check-prefix ELF64 +RUN: llvm-readelf -W -S %p/Inputs/relocs.obj.elf-x86_64 \ +RUN: | FileCheck %s -check-prefix ELF64 ELF32: Section Headers: ELF32-NEXT: [Nr] Name Type Address Off Size ES Flg Lk Inf Al Index: tools/llvm-readobj/CMakeLists.txt =================================================================== --- tools/llvm-readobj/CMakeLists.txt +++ tools/llvm-readobj/CMakeLists.txt @@ -19,3 +19,5 @@ WasmDumper.cpp Win64EHDumper.cpp ) + +add_llvm_tool_symlink(llvm-readelf llvm-readobj) Index: tools/llvm-readobj/llvm-readobj.cpp =================================================================== --- tools/llvm-readobj/llvm-readobj.cpp +++ tools/llvm-readobj/llvm-readobj.cpp @@ -34,6 +34,7 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/ManagedStatic.h" +#include "llvm/Support/Path.h" #include "llvm/Support/PrettyStackTrace.h" #include "llvm/Support/ScopedPrinter.h" #include "llvm/Support/Signals.h" @@ -537,7 +538,8 @@ } int main(int argc, const char *argv[]) { - sys::PrintStackTraceOnErrorSignal(argv[0]); + StringRef ToolName = argv[0]; + sys::PrintStackTraceOnErrorSignal(ToolName); PrettyStackTraceProgram X(argc, argv); llvm_shutdown_obj Y; @@ -546,6 +548,9 @@ opts::WideOutput.setHiddenFlag(cl::Hidden); + if (sys::path::stem(ToolName).find("readelf") != StringRef::npos) + opts::Output = opts::GNU; + cl::ParseCommandLineOptions(argc, argv, "LLVM Object Reader\n"); // Default to stdin if no filename is specified.