Index: test/tools/llvm-readobj/gnu-sections.test
===================================================================
--- test/tools/llvm-readobj/gnu-sections.test
+++ test/tools/llvm-readobj/gnu-sections.test
@@ -2,6 +2,8 @@
RUN: | FileCheck %s -check-prefix ELF32
RUN: llvm-readobj -s %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"
@@ -50,6 +51,10 @@
cl::desc(""),
cl::ZeroOrMore);
+ // -W
+ cl::opt IgnoredW("W",
+ cl::desc("Ignored for compatibility with GNU readelf"));
+
// -file-headers, -h
cl::opt FileHeaders("file-headers",
cl::desc("Display file headers "));
@@ -57,12 +62,16 @@
cl::desc("Alias for --file-headers"),
cl::aliasopt(FileHeaders));
- // -sections, -s
+ // -sections, -s, -S
+ // Note: In GNU readelf, -s means --symbols!
cl::opt Sections("sections",
cl::desc("Display all sections."));
cl::alias SectionsShort("s",
cl::desc("Alias for --sections"),
cl::aliasopt(Sections));
+ cl::alias SectionsShortUpper("S",
+ cl::desc("Alias for --sections"),
+ cl::aliasopt(Sections));
// -section-relocations, -sr
cl::opt SectionRelocations("section-relocations",
@@ -526,13 +535,18 @@
}
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;
// Register the target printer for --version.
cl::AddExtraVersionPrinter(TargetRegistry::printRegisteredTargetsForVersion);
+ opts::IgnoredW.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.