[llvm] 6103fdf - [ifs][elfabi] Merge llvm-ifs/elfabi tools
Haowei Wu via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 19 11:23:56 PDT 2021
Author: Haowei Wu
Date: 2021-07-19T11:23:19-07:00
New Revision: 6103fdfab4e2c051c070e2994db8b696fc440048
URL: https://github.com/llvm/llvm-project/commit/6103fdfab4e2c051c070e2994db8b696fc440048
DIFF: https://github.com/llvm/llvm-project/commit/6103fdfab4e2c051c070e2994db8b696fc440048.diff
LOG: [ifs][elfabi] Merge llvm-ifs/elfabi tools
This change merges llvm-elfabi and llvm-ifs tools.
Differential Revision: https://reviews.llvm.org/D100139
Added:
llvm/tools/llvm-ifs/ErrorCollector.cpp
llvm/tools/llvm-ifs/ErrorCollector.h
Modified:
clang/cmake/caches/Fuchsia-stage2.cmake
clang/lib/Driver/ToolChains/InterfaceStubs.cpp
clang/test/InterfaceStubs/driver-test.c
llvm/include/llvm/InterfaceStub/ELFObjHandler.h
llvm/include/llvm/InterfaceStub/IFSHandler.h
llvm/include/llvm/InterfaceStub/IFSStub.h
llvm/lib/InterfaceStub/ELFObjHandler.cpp
llvm/lib/InterfaceStub/IFSHandler.cpp
llvm/lib/InterfaceStub/IFSStub.cpp
llvm/test/CMakeLists.txt
llvm/test/tools/llvm-ifs/binary-read-add-soname.test
llvm/test/tools/llvm-ifs/binary-read-arch.test
llvm/test/tools/llvm-ifs/binary-read-bad-soname.test
llvm/test/tools/llvm-ifs/binary-read-bad-vaddr.test
llvm/test/tools/llvm-ifs/binary-read-neededlibs-bad-offset.test
llvm/test/tools/llvm-ifs/binary-read-neededlibs.test
llvm/test/tools/llvm-ifs/binary-read-no-dt-strsz.test
llvm/test/tools/llvm-ifs/binary-read-no-dt-strtab.test
llvm/test/tools/llvm-ifs/binary-read-no-dynamic.test
llvm/test/tools/llvm-ifs/binary-read-replace-soname.test
llvm/test/tools/llvm-ifs/binary-read-soname-no-null.test
llvm/test/tools/llvm-ifs/binary-read-soname.test
llvm/test/tools/llvm-ifs/binary-read-syms-gnu-hash.test
llvm/test/tools/llvm-ifs/binary-read-syms-sysv-hash.test
llvm/test/tools/llvm-ifs/conflict-header-triple.ifs
llvm/test/tools/llvm-ifs/conflict-header-version.ifs
llvm/test/tools/llvm-ifs/conflict-size.ifs
llvm/test/tools/llvm-ifs/conflict-type.ifs
llvm/test/tools/llvm-ifs/conflict-weak.ifs
llvm/test/tools/llvm-ifs/default-empty.ifs
llvm/test/tools/llvm-ifs/empty1.ifs
llvm/test/tools/llvm-ifs/empty2.ifs
llvm/test/tools/llvm-ifs/fail-file-open.test
llvm/test/tools/llvm-ifs/fail-file-write-windows.test
llvm/test/tools/llvm-ifs/fail-file-write.test
llvm/test/tools/llvm-ifs/func.ifs
llvm/test/tools/llvm-ifs/ifs-emits-current-version.test
llvm/test/tools/llvm-ifs/ifs-read-basic.test
llvm/test/tools/llvm-ifs/ios-tbd.ifs
llvm/test/tools/llvm-ifs/macos-tbd.ifs
llvm/test/tools/llvm-ifs/object-function-size-weak-combo.ifs
llvm/test/tools/llvm-ifs/object.ifs
llvm/test/tools/llvm-ifs/output-target-error.test
llvm/test/tools/llvm-ifs/preserve-dates-ifs.test
llvm/test/tools/llvm-ifs/preserve-dates-stub.test
llvm/test/tools/llvm-ifs/read-elf-dynsym.test
llvm/test/tools/llvm-ifs/read-ifs-as-elf.test
llvm/test/tools/llvm-ifs/read-ifs-as-ifs.test
llvm/test/tools/llvm-ifs/read-ifs-with-bad-bitwidth.test
llvm/test/tools/llvm-ifs/read-ifs-with-bad-endianness.test
llvm/test/tools/llvm-ifs/read-unsupported-file.test
llvm/test/tools/llvm-ifs/strip-target.test
llvm/test/tools/llvm-ifs/strong.ifs
llvm/test/tools/llvm-ifs/tvos-tbd.ifs
llvm/test/tools/llvm-ifs/version-ok.ifs
llvm/test/tools/llvm-ifs/watchos-tbd.ifs
llvm/test/tools/llvm-ifs/weak-mismatch.ifs
llvm/test/tools/llvm-ifs/weak.ifs
llvm/test/tools/llvm-ifs/write-stub-no-nonlocal-symbol.test
llvm/test/tools/llvm-ifs/write-stub.test
llvm/tools/llvm-ifs/CMakeLists.txt
llvm/tools/llvm-ifs/llvm-ifs.cpp
llvm/unittests/InterfaceStub/ELFYAMLTest.cpp
llvm/utils/gn/secondary/llvm/test/BUILD.gn
Removed:
llvm/tools/llvm-elfabi/CMakeLists.txt
llvm/tools/llvm-elfabi/ErrorCollector.cpp
llvm/tools/llvm-elfabi/ErrorCollector.h
llvm/tools/llvm-elfabi/llvm-elfabi.cpp
llvm/utils/gn/secondary/llvm/tools/llvm-elfabi/BUILD.gn
################################################################################
diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake b/clang/cmake/caches/Fuchsia-stage2.cmake
index c031465002cca..aa45c1549340b 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -246,7 +246,7 @@ set(LLVM_TOOLCHAIN_TOOLS
llvm-dlltool
llvm-dwarfdump
llvm-dwp
- llvm-elfabi
+ llvm-ifs
llvm-gsymutil
llvm-lib
llvm-lipo
diff --git a/clang/lib/Driver/ToolChains/InterfaceStubs.cpp b/clang/lib/Driver/ToolChains/InterfaceStubs.cpp
index 57acf338df5c4..05a13db8d0cff 100644
--- a/clang/lib/Driver/ToolChains/InterfaceStubs.cpp
+++ b/clang/lib/Driver/ToolChains/InterfaceStubs.cpp
@@ -20,10 +20,11 @@ void Merger::ConstructJob(Compilation &C, const JobAction &JA,
const llvm::opt::ArgList &Args,
const char *LinkingOutput) const {
std::string Merger = getToolChain().GetProgramPath(getShortName());
+ // TODO: Use IFS library directly in the future.
llvm::opt::ArgStringList CmdArgs;
- CmdArgs.push_back("-action");
+ CmdArgs.push_back("--input-format=IFS");
const bool WriteBin = !Args.getLastArg(options::OPT_emit_merged_ifs);
- CmdArgs.push_back(WriteBin ? "write-bin" : "write-ifs");
+ CmdArgs.push_back(WriteBin ? "--output-format=ELF" : "--output-format=IFS");
CmdArgs.push_back("-o");
// Normally we want to write to a side-car file ending in ".ifso" so for
diff --git a/clang/test/InterfaceStubs/driver-test.c b/clang/test/InterfaceStubs/driver-test.c
index 894d896bb219e..741cdab3e9d31 100644
--- a/clang/test/InterfaceStubs/driver-test.c
+++ b/clang/test/InterfaceStubs/driver-test.c
@@ -12,7 +12,7 @@
// RUN: %clang -target x86_64-unknown-linux-gnu -x c -S \
// RUN: -fno-integrated-cc1 \
// RUN: -emit-interface-stubs %s %S/object.c %S/weak.cpp && \
-// RUN: llvm-nm %t/a.out.ifso 2>&1 | FileCheck --check-prefix=CHECK-IFS %s
+// RUN: llvm-nm -D %t/a.out.ifso 2>&1 | FileCheck --check-prefix=CHECK-IFS %s
// CHECK-IFS-DAG: data
// CHECK-IFS-DAG: foo
diff --git a/llvm/include/llvm/InterfaceStub/ELFObjHandler.h b/llvm/include/llvm/InterfaceStub/ELFObjHandler.h
index c87ba380bf964..20a02c6d5445f 100644
--- a/llvm/include/llvm/InterfaceStub/ELFObjHandler.h
+++ b/llvm/include/llvm/InterfaceStub/ELFObjHandler.h
@@ -22,7 +22,7 @@ namespace llvm {
class MemoryBuffer;
-namespace elfabi {
+namespace ifs {
/// Attempt to read a binary ELF file from a MemoryBuffer.
Expected<std::unique_ptr<IFSStub>> readELFFile(MemoryBufferRef Buf);
@@ -38,7 +38,7 @@ Expected<std::unique_ptr<IFSStub>> readELFFile(MemoryBufferRef Buf);
Error writeBinaryStub(StringRef FilePath, const IFSStub &Stub,
bool WriteIfChanged = false);
-} // end namespace elfabi
+} // end namespace ifs
} // end namespace llvm
#endif // LLVM_INTERFACESTUB_ELFOBJHANDLER_H
diff --git a/llvm/include/llvm/InterfaceStub/IFSHandler.h b/llvm/include/llvm/InterfaceStub/IFSHandler.h
index b7db286d46c27..de627492366fe 100644
--- a/llvm/include/llvm/InterfaceStub/IFSHandler.h
+++ b/llvm/include/llvm/InterfaceStub/IFSHandler.h
@@ -26,7 +26,7 @@ class raw_ostream;
class Error;
class StringRef;
-namespace elfabi {
+namespace ifs {
struct IFSStub;
@@ -54,7 +54,7 @@ void stripIFSTarget(IFSStub &Stub, bool StripTriple, bool StripArch,
/// Parse llvm triple string into a IFSTarget struct.
IFSTarget parseTriple(StringRef TripleStr);
-} // end namespace elfabi
+} // end namespace ifs
} // end namespace llvm
#endif // LLVM_INTERFACESTUB_IFSHANDLER_H
diff --git a/llvm/include/llvm/InterfaceStub/IFSStub.h b/llvm/include/llvm/InterfaceStub/IFSStub.h
index 99429ad370534..5b16b8304692a 100644
--- a/llvm/include/llvm/InterfaceStub/IFSStub.h
+++ b/llvm/include/llvm/InterfaceStub/IFSStub.h
@@ -20,7 +20,7 @@
#include <vector>
namespace llvm {
-namespace elfabi {
+namespace ifs {
typedef uint16_t IFSArch;
@@ -151,7 +151,7 @@ IFSEndiannessType convertELFEndiannessToIFS(uint8_t Endianness);
///
/// @param SymbolType Binary symbol st_info to extract symbol type from.
IFSSymbolType convertELFSymbolTypeToIFS(uint8_t SymbolType);
-} // end namespace elfabi
+} // namespace ifs
} // end namespace llvm
#endif // LLVM_INTERFACESTUB_IFSSTUB_H
diff --git a/llvm/lib/InterfaceStub/ELFObjHandler.cpp b/llvm/lib/InterfaceStub/ELFObjHandler.cpp
index bf7be906f7ba1..112c1cea354ac 100644
--- a/llvm/lib/InterfaceStub/ELFObjHandler.cpp
+++ b/llvm/lib/InterfaceStub/ELFObjHandler.cpp
@@ -27,7 +27,7 @@ using namespace llvm::object;
using namespace llvm::ELF;
namespace llvm {
-namespace elfabi {
+namespace ifs {
// Simple struct to hold relevant .dynamic entries.
struct DynamicEntries {
@@ -671,5 +671,5 @@ Error writeBinaryStub(StringRef FilePath, const IFSStub &Stub,
llvm_unreachable("invalid binary output target");
}
-} // namespace elfabi
+} // end namespace ifs
} // end namespace llvm
diff --git a/llvm/lib/InterfaceStub/IFSHandler.cpp b/llvm/lib/InterfaceStub/IFSHandler.cpp
index c400bf13ea1f0..d3d351fa2ed45 100644
--- a/llvm/lib/InterfaceStub/IFSHandler.cpp
+++ b/llvm/lib/InterfaceStub/IFSHandler.cpp
@@ -17,7 +17,7 @@
#include "llvm/Support/YAMLTraits.h"
using namespace llvm;
-using namespace llvm::elfabi;
+using namespace llvm::ifs;
LLVM_YAML_IS_SEQUENCE_VECTOR(IFSSymbol)
@@ -171,7 +171,7 @@ bool usesTriple(StringRef Buf) {
return true;
}
-Expected<std::unique_ptr<IFSStub>> elfabi::readIFSFromBuffer(StringRef Buf) {
+Expected<std::unique_ptr<IFSStub>> ifs::readIFSFromBuffer(StringRef Buf) {
yaml::Input YamlIn(Buf);
std::unique_ptr<IFSStubTriple> Stub(new IFSStubTriple());
if (usesTriple(Buf)) {
@@ -183,7 +183,7 @@ Expected<std::unique_ptr<IFSStub>> elfabi::readIFSFromBuffer(StringRef Buf) {
return createStringError(Err, "YAML failed reading as IFS");
}
- if (Stub->IfsVersion > elfabi::IFSVersionCurrent)
+ if (Stub->IfsVersion > IFSVersionCurrent)
return make_error<StringError>(
"IFS version " + Stub->IfsVersion.getAsString() + " is unsupported.",
std::make_error_code(std::errc::invalid_argument));
@@ -194,7 +194,7 @@ Expected<std::unique_ptr<IFSStub>> elfabi::readIFSFromBuffer(StringRef Buf) {
return std::move(Stub);
}
-Error elfabi::writeIFSToOutputStream(raw_ostream &OS, const IFSStub &Stub) {
+Error ifs::writeIFSToOutputStream(raw_ostream &OS, const IFSStub &Stub) {
yaml::Output YamlOut(OS, NULL, /*WrapColumn =*/0);
std::unique_ptr<IFSStubTriple> CopyStub(new IFSStubTriple(Stub));
if (Stub.Target.Arch) {
@@ -212,10 +212,10 @@ Error elfabi::writeIFSToOutputStream(raw_ostream &OS, const IFSStub &Stub) {
return Error::success();
}
-Error elfabi::overrideIFSTarget(IFSStub &Stub, Optional<IFSArch> OverrideArch,
- Optional<IFSEndiannessType> OverrideEndianness,
- Optional<IFSBitWidthType> OverrideBitWidth,
- Optional<std::string> OverrideTriple) {
+Error ifs::overrideIFSTarget(IFSStub &Stub, Optional<IFSArch> OverrideArch,
+ Optional<IFSEndiannessType> OverrideEndianness,
+ Optional<IFSBitWidthType> OverrideBitWidth,
+ Optional<std::string> OverrideTriple) {
std::error_code OverrideEC(1, std::generic_category());
if (OverrideArch) {
if (Stub.Target.Arch &&
@@ -252,7 +252,7 @@ Error elfabi::overrideIFSTarget(IFSStub &Stub, Optional<IFSArch> OverrideArch,
return Error::success();
}
-Error elfabi::validateIFSTarget(IFSStub &Stub, bool ParseTriple) {
+Error ifs::validateIFSTarget(IFSStub &Stub, bool ParseTriple) {
std::error_code ValidationEC(1, std::generic_category());
if (Stub.Target.Triple) {
if (Stub.Target.Arch || Stub.Target.BitWidth || Stub.Target.Endianness ||
@@ -287,7 +287,7 @@ Error elfabi::validateIFSTarget(IFSStub &Stub, bool ParseTriple) {
return Error::success();
}
-IFSTarget elfabi::parseTriple(StringRef TripleStr) {
+IFSTarget ifs::parseTriple(StringRef TripleStr) {
Triple IFSTriple(TripleStr);
IFSTarget RetTarget;
// TODO: Implement a Triple Arch enum to e_machine map.
@@ -308,8 +308,8 @@ IFSTarget elfabi::parseTriple(StringRef TripleStr) {
return RetTarget;
}
-void elfabi::stripIFSTarget(IFSStub &Stub, bool StripTriple, bool StripArch,
- bool StripEndianness, bool StripBitWidth) {
+void ifs::stripIFSTarget(IFSStub &Stub, bool StripTriple, bool StripArch,
+ bool StripEndianness, bool StripBitWidth) {
if (StripTriple || StripArch) {
Stub.Target.Arch.reset();
Stub.Target.ArchString.reset();
diff --git a/llvm/lib/InterfaceStub/IFSStub.cpp b/llvm/lib/InterfaceStub/IFSStub.cpp
index 83af97c358a0b..24c29f3db5b8f 100644
--- a/llvm/lib/InterfaceStub/IFSStub.cpp
+++ b/llvm/lib/InterfaceStub/IFSStub.cpp
@@ -11,7 +11,7 @@
#include "llvm/Support/Error.h"
using namespace llvm;
-using namespace llvm::elfabi;
+using namespace llvm::ifs;
IFSStub::IFSStub(IFSStub const &Stub) {
IfsVersion = Stub.IfsVersion;
@@ -58,7 +58,7 @@ bool IFSTarget::empty() {
!BitWidth;
}
-uint8_t elfabi::convertIFSBitWidthToELF(IFSBitWidthType BitWidth) {
+uint8_t ifs::convertIFSBitWidthToELF(IFSBitWidthType BitWidth) {
switch (BitWidth) {
case IFSBitWidthType::IFS32:
return ELF::ELFCLASS32;
@@ -69,7 +69,7 @@ uint8_t elfabi::convertIFSBitWidthToELF(IFSBitWidthType BitWidth) {
}
}
-uint8_t elfabi::convertIFSEndiannessToELF(IFSEndiannessType Endianness) {
+uint8_t ifs::convertIFSEndiannessToELF(IFSEndiannessType Endianness) {
switch (Endianness) {
case IFSEndiannessType::Little:
return ELF::ELFDATA2LSB;
@@ -80,7 +80,7 @@ uint8_t elfabi::convertIFSEndiannessToELF(IFSEndiannessType Endianness) {
}
}
-uint8_t elfabi::convertIFSSymbolTypeToELF(IFSSymbolType SymbolType) {
+uint8_t ifs::convertIFSSymbolTypeToELF(IFSSymbolType SymbolType) {
switch (SymbolType) {
case IFSSymbolType::Object:
return ELF::STT_OBJECT;
@@ -94,7 +94,7 @@ uint8_t elfabi::convertIFSSymbolTypeToELF(IFSSymbolType SymbolType) {
}
}
-IFSBitWidthType elfabi::convertELFBitWidthToIFS(uint8_t BitWidth) {
+IFSBitWidthType ifs::convertELFBitWidthToIFS(uint8_t BitWidth) {
switch (BitWidth) {
case ELF::ELFCLASS32:
return IFSBitWidthType::IFS32;
@@ -105,7 +105,7 @@ IFSBitWidthType elfabi::convertELFBitWidthToIFS(uint8_t BitWidth) {
}
}
-IFSEndiannessType elfabi::convertELFEndiannessToIFS(uint8_t Endianness) {
+IFSEndiannessType ifs::convertELFEndiannessToIFS(uint8_t Endianness) {
switch (Endianness) {
case ELF::ELFDATA2LSB:
return IFSEndiannessType::Little;
@@ -116,7 +116,7 @@ IFSEndiannessType elfabi::convertELFEndiannessToIFS(uint8_t Endianness) {
}
}
-IFSSymbolType elfabi::convertELFSymbolTypeToIFS(uint8_t SymbolType) {
+IFSSymbolType ifs::convertELFSymbolTypeToIFS(uint8_t SymbolType) {
SymbolType = SymbolType & 0xf;
switch (SymbolType) {
case ELF::STT_OBJECT:
diff --git a/llvm/test/CMakeLists.txt b/llvm/test/CMakeLists.txt
index fd60c5080099b..8ae9933eb150b 100644
--- a/llvm/test/CMakeLists.txt
+++ b/llvm/test/CMakeLists.txt
@@ -77,7 +77,6 @@ set(LLVM_TEST_DEPENDS
dsymutil
llvm-dwarfdump
llvm-dwp
- llvm-elfabi
llvm-exegesis
llvm-extract
llvm-gsymutil
diff --git a/llvm/test/tools/llvm-ifs/binary-read-add-soname.test b/llvm/test/tools/llvm-ifs/binary-read-add-soname.test
index f8d2948949d07..c94e4dca62d4b 100644
--- a/llvm/test/tools/llvm-ifs/binary-read-add-soname.test
+++ b/llvm/test/tools/llvm-ifs/binary-read-add-soname.test
@@ -1,5 +1,5 @@
# RUN: yaml2obj %s -o %t
-# RUN: llvm-elfabi --input-format=ELF --output-format=IFS --output=- --soname=best.so %t | FileCheck %s
+# RUN: llvm-ifs --input-format=ELF --output-format=IFS --output=- --soname=best.so %t | FileCheck %s
!ELF
FileHeader:
diff --git a/llvm/test/tools/llvm-ifs/binary-read-arch.test b/llvm/test/tools/llvm-ifs/binary-read-arch.test
index d1ba26c891b04..5491367894ee9 100644
--- a/llvm/test/tools/llvm-ifs/binary-read-arch.test
+++ b/llvm/test/tools/llvm-ifs/binary-read-arch.test
@@ -1,6 +1,6 @@
# RUN: yaml2obj --docnum=1 %s -o %t
-# RUN: llvm-elfabi --input-format=ELF --output-format=IFS --output=- %t | FileCheck %s -DTARGET="{ ObjectFormat: ELF, Arch: x86_64, Endianness: little, BitWidth: 64 }"
-# RUN: llvm-elfabi --input-format=ELF --output-format=IFS --output=- --hint-ifs-target="x86_64-linux-gnu" %t | FileCheck %s -DTARGET="x86_64-linux-gnu"
+# RUN: llvm-ifs --input-format=ELF --output-format=IFS --output=- %t | FileCheck %s -DTARGET="{ ObjectFormat: ELF, Arch: x86_64, Endianness: little, BitWidth: 64 }"
+# RUN: llvm-ifs --input-format=ELF --output-format=IFS --output=- --hint-ifs-target="x86_64-linux-gnu" %t | FileCheck %s -DTARGET="x86_64-linux-gnu"
--- !ELF
FileHeader:
@@ -52,7 +52,7 @@ ProgramHeaders:
# HINTERR: error: Triple hint does not match the actual [[MSG]]
# RUN: yaml2obj --docnum=1 %s -o %t
-# RUN: not llvm-elfabi --input-format=ELF --output-format=IFS --output=%t.tbe --hint-ifs-target="aarch64-linux-gnu" %t 2>&1 | FileCheck %s -DMSG=architecture --check-prefix=HINTERR
+# RUN: not llvm-ifs --input-format=ELF --output-format=IFS --output=%t.tbe --hint-ifs-target="aarch64-linux-gnu" %t 2>&1 | FileCheck %s -DMSG=architecture --check-prefix=HINTERR
--- !ELF
FileHeader:
@@ -96,7 +96,7 @@ ProgramHeaders:
LastSec: .dynamic
# RUN: yaml2obj --docnum=2 %s -o %t
-# RUN: not llvm-elfabi --input-format=ELF --output-format=IFS --output=%t.tbe --hint-ifs-target="x86_64-unknown-linux-gnu" %t 2>&1 | FileCheck %s -DMSG="endianness" --check-prefix=HINTERR
+# RUN: not llvm-ifs --input-format=ELF --output-format=IFS --output=%t.tbe --hint-ifs-target="x86_64-unknown-linux-gnu" %t 2>&1 | FileCheck %s -DMSG="endianness" --check-prefix=HINTERR
--- !ELF
FileHeader:
@@ -140,4 +140,4 @@ ProgramHeaders:
LastSec: .dynamic
# RUN: yaml2obj --docnum=3 %s -o %t
-# RUN: not llvm-elfabi --input-format=ELF --output-format=IFS --output=%t.tbe --hint-ifs-target="x86_64-unknown-linux-gnu" %t 2>&1 | FileCheck %s -DMSG="bit width" --check-prefix=HINTERR
+# RUN: not llvm-ifs --input-format=ELF --output-format=IFS --output=%t.tbe --hint-ifs-target="x86_64-unknown-linux-gnu" %t 2>&1 | FileCheck %s -DMSG="bit width" --check-prefix=HINTERR
diff --git a/llvm/test/tools/llvm-ifs/binary-read-bad-soname.test b/llvm/test/tools/llvm-ifs/binary-read-bad-soname.test
index 797e0972137d1..4fe2ca2133d4d 100644
--- a/llvm/test/tools/llvm-ifs/binary-read-bad-soname.test
+++ b/llvm/test/tools/llvm-ifs/binary-read-bad-soname.test
@@ -1,5 +1,5 @@
# RUN: yaml2obj %s -o %t
-# RUN: not llvm-elfabi --input-format=ELF --output-format=IFS --output=%t.tbe %t 2>&1 | FileCheck %s
+# RUN: not llvm-ifs --input-format=ELF --output-format=IFS --output=%t.tbe %t 2>&1 | FileCheck %s
!ELF
FileHeader:
diff --git a/llvm/test/tools/llvm-ifs/binary-read-bad-vaddr.test b/llvm/test/tools/llvm-ifs/binary-read-bad-vaddr.test
index 758549946d67d..4bf16a2dc89b0 100644
--- a/llvm/test/tools/llvm-ifs/binary-read-bad-vaddr.test
+++ b/llvm/test/tools/llvm-ifs/binary-read-bad-vaddr.test
@@ -1,5 +1,5 @@
# RUN: yaml2obj %s -o %t
-# RUN: not llvm-elfabi --input-format=ELF --output-format=IFS --output=%t.tbe %t 2>&1 | FileCheck %s
+# RUN: not llvm-ifs --input-format=ELF --output-format=IFS --output=%t.tbe %t 2>&1 | FileCheck %s
!ELF
FileHeader:
diff --git a/llvm/test/tools/llvm-ifs/binary-read-neededlibs-bad-offset.test b/llvm/test/tools/llvm-ifs/binary-read-neededlibs-bad-offset.test
index 6a9709d5eb36e..d803abe239e95 100644
--- a/llvm/test/tools/llvm-ifs/binary-read-neededlibs-bad-offset.test
+++ b/llvm/test/tools/llvm-ifs/binary-read-neededlibs-bad-offset.test
@@ -1,5 +1,5 @@
# RUN: yaml2obj %s -o %t
-# RUN: not llvm-elfabi --input-format=ELF --output-format=IFS --output=%t.tbe %t 2>&1 | FileCheck %s
+# RUN: not llvm-ifs --input-format=ELF --output-format=IFS --output=%t.tbe %t 2>&1 | FileCheck %s
!ELF
FileHeader:
diff --git a/llvm/test/tools/llvm-ifs/binary-read-neededlibs.test b/llvm/test/tools/llvm-ifs/binary-read-neededlibs.test
index 3669dc26a2cc1..ebdd5ae151656 100644
--- a/llvm/test/tools/llvm-ifs/binary-read-neededlibs.test
+++ b/llvm/test/tools/llvm-ifs/binary-read-neededlibs.test
@@ -1,5 +1,5 @@
# RUN: yaml2obj %s -o %t
-# RUN: llvm-elfabi --input-format=ELF --output-format=IFS --output=- %t | FileCheck %s
+# RUN: llvm-ifs --input-format=ELF --output-format=IFS --output=- %t | FileCheck %s
!ELF
FileHeader:
diff --git a/llvm/test/tools/llvm-ifs/binary-read-no-dt-strsz.test b/llvm/test/tools/llvm-ifs/binary-read-no-dt-strsz.test
index 8a7b41e51adea..bca357ccc00d3 100644
--- a/llvm/test/tools/llvm-ifs/binary-read-no-dt-strsz.test
+++ b/llvm/test/tools/llvm-ifs/binary-read-no-dt-strsz.test
@@ -1,5 +1,5 @@
# RUN: yaml2obj %s -o %t
-# RUN: not llvm-elfabi --input-format=ELF --output-format=IFS --output=%t.tbe %t 2>&1 | FileCheck %s
+# RUN: not llvm-ifs --input-format=ELF --output-format=IFS --output=%t.tbe %t 2>&1 | FileCheck %s
!ELF
FileHeader:
diff --git a/llvm/test/tools/llvm-ifs/binary-read-no-dt-strtab.test b/llvm/test/tools/llvm-ifs/binary-read-no-dt-strtab.test
index 16f8868bb8ccc..f9194592bf0e2 100644
--- a/llvm/test/tools/llvm-ifs/binary-read-no-dt-strtab.test
+++ b/llvm/test/tools/llvm-ifs/binary-read-no-dt-strtab.test
@@ -1,5 +1,5 @@
# RUN: yaml2obj %s -o %t
-# RUN: not llvm-elfabi --input-format=ELF --output-format=IFS --output=%t.tbe %t 2>&1 | FileCheck %s
+# RUN: not llvm-ifs --input-format=ELF --output-format=IFS --output=%t.tbe %t 2>&1 | FileCheck %s
!ELF
FileHeader:
diff --git a/llvm/test/tools/llvm-ifs/binary-read-no-dynamic.test b/llvm/test/tools/llvm-ifs/binary-read-no-dynamic.test
index 3c70639728586..3ea0bd39d023e 100644
--- a/llvm/test/tools/llvm-ifs/binary-read-no-dynamic.test
+++ b/llvm/test/tools/llvm-ifs/binary-read-no-dynamic.test
@@ -1,5 +1,5 @@
# RUN: yaml2obj %s -o %t
-# RUN: not llvm-elfabi --input-format=ELF --output-format=IFS --output=%t.tbe %t 2>&1 | FileCheck %s
+# RUN: not llvm-ifs --input-format=ELF --output-format=IFS --output=%t.tbe %t 2>&1 | FileCheck %s
!ELF
FileHeader:
diff --git a/llvm/test/tools/llvm-ifs/binary-read-replace-soname.test b/llvm/test/tools/llvm-ifs/binary-read-replace-soname.test
index e44feb677ea36..f845ab440cdc2 100644
--- a/llvm/test/tools/llvm-ifs/binary-read-replace-soname.test
+++ b/llvm/test/tools/llvm-ifs/binary-read-replace-soname.test
@@ -1,6 +1,6 @@
# RUN: yaml2obj %s -o %t
-# RUN: llvm-elfabi --input-format=ELF --output-format=IFS --output=- %t | FileCheck %s --check-prefix=ORIGINAL
-# RUN: llvm-elfabi --input-format=ELF --output-format=IFS --soname=libbest.so --output=- %t | FileCheck %s --check-prefix=REPLACED
+# RUN: llvm-ifs --input-format=ELF --output-format=IFS --output=- %t | FileCheck %s --check-prefix=ORIGINAL
+# RUN: llvm-ifs --input-format=ELF --output-format=IFS --soname=libbest.so --output=- %t | FileCheck %s --check-prefix=REPLACED
!ELF
FileHeader:
diff --git a/llvm/test/tools/llvm-ifs/binary-read-soname-no-null.test b/llvm/test/tools/llvm-ifs/binary-read-soname-no-null.test
index 4cbb40bf04f08..80b427ca1a62c 100644
--- a/llvm/test/tools/llvm-ifs/binary-read-soname-no-null.test
+++ b/llvm/test/tools/llvm-ifs/binary-read-soname-no-null.test
@@ -1,5 +1,5 @@
# RUN: yaml2obj %s -o %t
-# RUN: not llvm-elfabi --input-format=ELF --output-format=IFS --output=%t.tbe %t 2>&1 | FileCheck %s
+# RUN: not llvm-ifs --input-format=ELF --output-format=IFS --output=%t.tbe %t 2>&1 | FileCheck %s
!ELF
FileHeader:
diff --git a/llvm/test/tools/llvm-ifs/binary-read-soname.test b/llvm/test/tools/llvm-ifs/binary-read-soname.test
index 963eaf0c7ec8a..821a2fa36cf4e 100644
--- a/llvm/test/tools/llvm-ifs/binary-read-soname.test
+++ b/llvm/test/tools/llvm-ifs/binary-read-soname.test
@@ -1,5 +1,5 @@
# RUN: yaml2obj %s -o %t
-# RUN: llvm-elfabi --input-format=ELF --output-format=IFS --output=- %t | FileCheck %s
+# RUN: llvm-ifs --input-format=ELF --output-format=IFS --output=- %t | FileCheck %s
!ELF
FileHeader:
diff --git a/llvm/test/tools/llvm-ifs/binary-read-syms-gnu-hash.test b/llvm/test/tools/llvm-ifs/binary-read-syms-gnu-hash.test
index f2ff1f8b8889e..9553119c06864 100644
--- a/llvm/test/tools/llvm-ifs/binary-read-syms-gnu-hash.test
+++ b/llvm/test/tools/llvm-ifs/binary-read-syms-gnu-hash.test
@@ -1,4 +1,4 @@
-# RUN: llvm-elfabi --input-format=ELF --output-format=IFS --output=- %p/Inputs/gnu_hash.so | FileCheck %s
+# RUN: llvm-ifs --input-format=ELF --output-format=IFS --output=- %p/Inputs/gnu_hash.so | FileCheck %s
# CHECK: --- !ifs-v1
# CHECK-NEXT: IfsVersion: 3.0
@@ -9,14 +9,14 @@
# CHECK-NEXT: - libc.so.6
# CHECK-NEXT: - ld-linux-x86-64.so.2
# CHECK-NEXT: Symbols:
-# CHECK-NEXT: - { Name: __gmon_start__, Type: NoType, Undefined: true, Weak: true }
+# CHECK-NEXT: - { Name: AGlobalInteger, Type: Object, Size: 4 }
+# CHECK-NEXT: - { Name: AThreadLocalLongInteger, Type: TLS, Size: 8 }
# CHECK-NEXT: - { Name: _ITM_deregisterTMCloneTable, Type: NoType, Undefined: true, Weak: true }
# CHECK-NEXT: - { Name: _ITM_registerTMCloneTable, Type: NoType, Undefined: true, Weak: true }
+# CHECK-NEXT: - { Name: _Z11rotateArrayPii, Type: Func }
# CHECK-NEXT: - { Name: __cxa_finalize, Type: Func, Undefined: true, Weak: true }
+# CHECK-NEXT: - { Name: __gmon_start__, Type: NoType, Undefined: true, Weak: true }
# CHECK-NEXT: - { Name: __tls_get_addr, Type: Func, Undefined: true }
-# CHECK-NEXT: - { Name: _init, Type: Func }
# CHECK-NEXT: - { Name: _fini, Type: Func }
-# CHECK-NEXT: - { Name: AGlobalInteger, Type: Object, Size: 4 }
-# CHECK-NEXT: - { Name: AThreadLocalLongInteger, Type: TLS, Size: 8 }
-# CHECK-NEXT: - { Name: _Z11rotateArrayPii, Type: Func }
+# CHECK-NEXT: - { Name: _init, Type: Func }
# CHECK-NEXT: ...
diff --git a/llvm/test/tools/llvm-ifs/binary-read-syms-sysv-hash.test b/llvm/test/tools/llvm-ifs/binary-read-syms-sysv-hash.test
index a9caac4c30c7d..fdd8cb0fae60e 100644
--- a/llvm/test/tools/llvm-ifs/binary-read-syms-sysv-hash.test
+++ b/llvm/test/tools/llvm-ifs/binary-read-syms-sysv-hash.test
@@ -1,4 +1,4 @@
-# RUN: llvm-elfabi --input-format=ELF --output-format=IFS --output=- %p/Inputs/sysv_hash.so | FileCheck %s
+# RUN: llvm-ifs --input-format=ELF --output-format=IFS --output=- %p/Inputs/sysv_hash.so | FileCheck %s
# CHECK: --- !ifs-v1
# CHECK-NEXT: IfsVersion: 3.0
@@ -9,14 +9,14 @@
# CHECK-NEXT: - libc.so.6
# CHECK-NEXT: - ld-linux-x86-64.so.2
# CHECK-NEXT: Symbols:
-# CHECK-NEXT: - { Name: __gmon_start__, Type: NoType, Undefined: true, Weak: true }
-# CHECK-NEXT: - { Name: _init, Type: Func }
-# CHECK-NEXT: - { Name: _fini, Type: Func }
-# CHECK-NEXT: - { Name: _ITM_deregisterTMCloneTable, Type: NoType, Undefined: true, Weak: true }
-# CHECK-NEXT: - { Name: _ITM_registerTMCloneTable, Type: NoType, Undefined: true, Weak: true }
-# CHECK-NEXT: - { Name: __cxa_finalize, Type: Func, Undefined: true, Weak: true }
# CHECK-NEXT: - { Name: AGlobalInteger, Type: Object, Size: 4 }
# CHECK-NEXT: - { Name: AThreadLocalLongInteger, Type: TLS, Size: 8 }
+# CHECK-NEXT: - { Name: _ITM_deregisterTMCloneTable, Type: NoType, Undefined: true, Weak: true }
+# CHECK-NEXT: - { Name: _ITM_registerTMCloneTable, Type: NoType, Undefined: true, Weak: true }
# CHECK-NEXT: - { Name: _Z11rotateArrayPii, Type: Func }
+# CHECK-NEXT: - { Name: __cxa_finalize, Type: Func, Undefined: true, Weak: true }
+# CHECK-NEXT: - { Name: __gmon_start__, Type: NoType, Undefined: true, Weak: true }
# CHECK-NEXT: - { Name: __tls_get_addr, Type: Func, Undefined: true }
+# CHECK-NEXT: - { Name: _fini, Type: Func }
+# CHECK-NEXT: - { Name: _init, Type: Func }
# CHECK-NEXT: ...
diff --git a/llvm/test/tools/llvm-ifs/conflict-header-triple.ifs b/llvm/test/tools/llvm-ifs/conflict-header-triple.ifs
index b721ed5c148a6..623b76b4109ca 100644
--- a/llvm/test/tools/llvm-ifs/conflict-header-triple.ifs
+++ b/llvm/test/tools/llvm-ifs/conflict-header-triple.ifs
@@ -1,9 +1,8 @@
-# RUN: not llvm-ifs -action write-ifs -o - %s %S/object.ifs 2>&1 | \
+# RUN: not llvm-ifs --input-format=IFS --output-format=IFS -o - %s %S/object.ifs 2>&1 | \
# RUN: FileCheck %s --check-prefixes=CHECK-IFS
-# CHECK-IFS: error: Interface Stub: Triple Mismatch.
+# CHECK-IFS: error: Interface Stub: Target Mismatch.
# CHECK-IFS-NEXT: Filenames:
-# CHECK-IFS-NEXT: Triple Values: mips-unknown-linux x86_64-unknown-linux-gnu
--- !ifs-v1
IfsVersion: 3.0
diff --git a/llvm/test/tools/llvm-ifs/conflict-header-version.ifs b/llvm/test/tools/llvm-ifs/conflict-header-version.ifs
index ca8ba0aa647e3..25fcb0f57339b 100644
--- a/llvm/test/tools/llvm-ifs/conflict-header-version.ifs
+++ b/llvm/test/tools/llvm-ifs/conflict-header-version.ifs
@@ -1,7 +1,7 @@
-# RUN: not llvm-ifs -action write-ifs -o - %s %S/object.ifs 2>&1 | \
+# RUN: not llvm-ifs --input-format=IFS --output-format=IFS -o - %s %S/object.ifs 2>&1 | \
# RUN: FileCheck %s --check-prefixes=CHECK-IFS
-# RUN: not llvm-ifs -action write-ifs -o - %s 2>&1 | \
+# RUN: not llvm-ifs --input-format=IFS --output-format=IFS -o - %s 2>&1 | \
# RUN: FileCheck %s --check-prefixes=CHECK-IFS2
# CHECK-IFS: error: Interface Stub: IfsVersion Mismatch.
diff --git a/llvm/test/tools/llvm-ifs/conflict-size.ifs b/llvm/test/tools/llvm-ifs/conflict-size.ifs
index f16f18817d706..987a3c1a8e879 100644
--- a/llvm/test/tools/llvm-ifs/conflict-size.ifs
+++ b/llvm/test/tools/llvm-ifs/conflict-size.ifs
@@ -1,4 +1,4 @@
-# RUN: not llvm-ifs -action write-ifs -o - %s %S/object.ifs 2>&1 | \
+# RUN: not llvm-ifs --input-format=IFS --output-format=IFS -o - %s %S/object.ifs 2>&1 | \
# RUN: FileCheck %s --check-prefixes=CHECK-IFS
# Here we are testing to see if two symbols with identical names will fail to
diff --git a/llvm/test/tools/llvm-ifs/conflict-type.ifs b/llvm/test/tools/llvm-ifs/conflict-type.ifs
index 024da4c733ae7..0a9879fc6df4c 100644
--- a/llvm/test/tools/llvm-ifs/conflict-type.ifs
+++ b/llvm/test/tools/llvm-ifs/conflict-type.ifs
@@ -1,4 +1,4 @@
-# RUN: not llvm-ifs -action write-ifs -o - %s %S/func.ifs 2>&1 | \
+# RUN: not llvm-ifs --input-format=IFS --output-format=IFS -o - %s %S/func.ifs 2>&1 | \
# RUN: FileCheck %s --check-prefixes=CHECK-IFS
# Here we are testing to see if two symbols with identical names will fail to
diff --git a/llvm/test/tools/llvm-ifs/conflict-weak.ifs b/llvm/test/tools/llvm-ifs/conflict-weak.ifs
index 7628b472b01e2..4b0c522aa66ad 100644
--- a/llvm/test/tools/llvm-ifs/conflict-weak.ifs
+++ b/llvm/test/tools/llvm-ifs/conflict-weak.ifs
@@ -1,4 +1,4 @@
-# RUN: llvm-ifs -action write-ifs -o - %s %S/func.ifs 2>&1 | \
+# RUN: llvm-ifs --input-format=IFS --output-format=IFS -o - %s %S/func.ifs 2>&1 | \
# RUN: FileCheck %s --check-prefixes=CHECK-IFS
# CHECK-IFS: Symbols:
diff --git a/llvm/test/tools/llvm-ifs/default-empty.ifs b/llvm/test/tools/llvm-ifs/default-empty.ifs
index 111c2be08de84..419a7c0684294 100644
--- a/llvm/test/tools/llvm-ifs/default-empty.ifs
+++ b/llvm/test/tools/llvm-ifs/default-empty.ifs
@@ -1,9 +1,8 @@
-# RUN: llvm-ifs -action write-ifs -o - %s | FileCheck --check-prefixes=CHECK-DEFAULT %s
-# RUN: llvm-ifs -action write-ifs -o - %s %S/weak.ifs | FileCheck --check-prefixes=CHECK-MERGE %s
+# RUN: llvm-ifs --input-format=IFS --output-format=IFS -o - %s | FileCheck --check-prefixes=CHECK-DEFAULT %s
+# RUN: llvm-ifs --input-format=IFS --output-format=IFS -o - %S/weak.ifs %s | FileCheck --check-prefixes=CHECK-MERGE %s
# CHECK-DEFAULT: --- !ifs-v1
# CHECK-DEFAULT-NEXT: IfsVersion: 3.0
-# CHECK-DEFAULT-NEXT: Target: ''
# CHECK-DEFAULT-NEXT: Symbols: []
# CHECK-DEFAULT-NEXT: ...
@@ -17,6 +16,5 @@
--- !ifs-v1
IfsVersion: 3.0
-Target: ''
Symbols: []
...
diff --git a/llvm/test/tools/llvm-ifs/empty1.ifs b/llvm/test/tools/llvm-ifs/empty1.ifs
index 593cdad2108b5..9cbf0cd7cb6b7 100644
--- a/llvm/test/tools/llvm-ifs/empty1.ifs
+++ b/llvm/test/tools/llvm-ifs/empty1.ifs
@@ -1,4 +1,4 @@
-# RUN: llvm-ifs -action write-ifs -o - %s | FileCheck %s
+# RUN: llvm-ifs --input-format=IFS --output-format=IFS -o - %s | FileCheck %s
# CHECK: --- !ifs-v1
# CHECK-NEXT: IfsVersion: 3.0
diff --git a/llvm/test/tools/llvm-ifs/empty2.ifs b/llvm/test/tools/llvm-ifs/empty2.ifs
index 9f23fe6f9913b..d26ad6309358f 100644
--- a/llvm/test/tools/llvm-ifs/empty2.ifs
+++ b/llvm/test/tools/llvm-ifs/empty2.ifs
@@ -1,4 +1,4 @@
-# RUN: llvm-ifs -action write-ifs -o - %s | FileCheck %s
+# RUN: llvm-ifs --input-format=IFS --output-format=IFS -o - %s | FileCheck %s
# CHECK: --- !ifs-v1
# CHECK-NEXT: IfsVersion: 3.0
diff --git a/llvm/test/tools/llvm-ifs/fail-file-open.test b/llvm/test/tools/llvm-ifs/fail-file-open.test
index 882205415b5b4..072f266f5fcde 100644
--- a/llvm/test/tools/llvm-ifs/fail-file-open.test
+++ b/llvm/test/tools/llvm-ifs/fail-file-open.test
@@ -1,5 +1,5 @@
-# RUN: not llvm-elfabi --output-format=IFS --output=%t.tbe %s.NotAFileInTestingDir 2>&1 | FileCheck %s
+# RUN: not llvm-ifs --output-format=IFS --output=%t.tbe %s.NotAFileInTestingDir 2>&1 | FileCheck %s
-This file will not be read. An invalid file path is fed to llvm-elfabi.
+This file will not be read. An invalid file path is fed to llvm-ifs.
# CHECK: error: Could not open `{{.*}}.NotAFileInTestingDir`
diff --git a/llvm/test/tools/llvm-ifs/fail-file-write-windows.test b/llvm/test/tools/llvm-ifs/fail-file-write-windows.test
index 472ec1b248588..69ae7d5512126 100644
--- a/llvm/test/tools/llvm-ifs/fail-file-write-windows.test
+++ b/llvm/test/tools/llvm-ifs/fail-file-write-windows.test
@@ -3,7 +3,7 @@
# REQUIRES: system-windows
# RUN: touch %t.TestFile
# RUN: chmod 400 %t.TestFile
-# RUN: not llvm-elfabi --output-format=ELF --output=%t.TestFile %s 2>&1 | FileCheck -DMSG=%errc_EACCES %s --check-prefix=ERR
+# RUN: not llvm-ifs --output-format=ELF --output=%t.TestFile %s 2>&1 | FileCheck -DMSG=%errc_EACCES %s --check-prefix=ERR
# RUN: chmod 777 %t.TestFile
# RUN: rm -rf %t.TestFile
diff --git a/llvm/test/tools/llvm-ifs/fail-file-write.test b/llvm/test/tools/llvm-ifs/fail-file-write.test
index 6c2f339cef29c..1f63d8fef3a99 100644
--- a/llvm/test/tools/llvm-ifs/fail-file-write.test
+++ b/llvm/test/tools/llvm-ifs/fail-file-write.test
@@ -5,7 +5,7 @@
# RUN: mkdir %t.TestDir
# RUN: touch %t.TestDir/Output.TestFile
# RUN: chmod 400 %t.TestDir
-# RUN: not llvm-elfabi --output-format=ELF --output=%t.TestDir/Output.TestFile %s 2>&1 | FileCheck -DMSG=%errc_EACCES %s --check-prefix=ERR
+# RUN: not llvm-ifs --output-format=ELF --output=%t.TestDir/Output.TestFile %s 2>&1 | FileCheck -DMSG=%errc_EACCES %s --check-prefix=ERR
# RUN: chmod 777 %t.TestDir
# RUN: rm -rf %t.TestDir
diff --git a/llvm/test/tools/llvm-ifs/func.ifs b/llvm/test/tools/llvm-ifs/func.ifs
index eaceaae63649e..c8f3612259cf1 100644
--- a/llvm/test/tools/llvm-ifs/func.ifs
+++ b/llvm/test/tools/llvm-ifs/func.ifs
@@ -1,16 +1,14 @@
-# RUN: llvm-ifs -action write-ifs -o - %s %S/object.ifs | \
+# RUN: llvm-ifs --input-format=IFS --output-format=IFS -o - %s %S/object.ifs | \
# RUN: FileCheck %s --check-prefixes=CHECK-IFS
-# RUN: llvm-ifs -action write-bin -o - %s %S/object.ifs | \
+# RUN: llvm-ifs --input-format=IFS --output-format=ELF -o - %s %S/object.ifs | \
# RUN: llvm-readelf --all - | FileCheck %s --check-prefixes=CHECK-ELF
-# RUN: llvm-ifs -action write-bin -o - %s %S/object.ifs -use-interfacestub | \
-# RUN: llvm-readelf --all - | FileCheck %s --check-prefixes=CHECK-ELF
-
-# RUN: llvm-ifs -action write-bin -force-format TBD -o - %s %S/object.ifs | \
+# RUN: llvm-ifs --input-format=IFS --output-format=IFS --strip-ifs-target -o %t.tbd %s %S/object.ifs
+# RUN: llvm-ifs --input-format=IFS --output-format=TBD --target=x86_64-apple-darwin -o - %t.tbd | \
# RUN: FileCheck %s --check-prefixes=CHECK-DARWIN-TBD3
-# RUN: llvm-ifs -action write-ifs -o - %s %s | \
+# RUN: llvm-ifs --input-format=IFS --output-format=IFS -o - %s %s | \
# RUN: FileCheck %s --check-prefixes=CHECK-MERGE-IFS
# CHECK-IFS: --- !ifs-v1
diff --git a/llvm/test/tools/llvm-ifs/ifs-emits-current-version.test b/llvm/test/tools/llvm-ifs/ifs-emits-current-version.test
index fd7e3f04dd77f..1dbb974b96094 100644
--- a/llvm/test/tools/llvm-ifs/ifs-emits-current-version.test
+++ b/llvm/test/tools/llvm-ifs/ifs-emits-current-version.test
@@ -1,4 +1,4 @@
-# RUN: llvm-elfabi --output-format=IFS --output=- %s | FileCheck %s
+# RUN: llvm-ifs --output-format=IFS --output=- %s | FileCheck %s
--- !ifs-v1
IfsVersion: 3.0
diff --git a/llvm/test/tools/llvm-ifs/ifs-read-basic.test b/llvm/test/tools/llvm-ifs/ifs-read-basic.test
index 39cc095ca9858..24f952fd82f12 100644
--- a/llvm/test/tools/llvm-ifs/ifs-read-basic.test
+++ b/llvm/test/tools/llvm-ifs/ifs-read-basic.test
@@ -1,4 +1,4 @@
-# RUN: llvm-elfabi --output-format=IFS --output=- %s | FileCheck %s
+# RUN: llvm-ifs --output-format=IFS --output=- %s | FileCheck %s
--- !ifs-v1
SoName: somelib.so
@@ -17,9 +17,9 @@ Symbols:
# CHECK-NEXT: SoName: somelib.so
# CHECK-NEXT: Target: { ObjectFormat: ELF, Arch: x86_64, Endianness: little, BitWidth: 64 }
# CHECK-NEXT: Symbols:
-# CHECK-NEXT: - { Name: foo, Type: Func }
# CHECK-NEXT: - { Name: bar, Type: Object, Size: 42 }
# CHECK-NEXT: - { Name: baz, Type: Object, Size: 8 }
-# CHECK-NEXT: - { Name: not, Type: Object, Size: 128, Undefined: true }
+# CHECK-NEXT: - { Name: foo, Type: Func }
# CHECK-NEXT: - { Name: nor, Type: Func, Undefined: true }
+# CHECK-NEXT: - { Name: not, Type: Object, Size: 128, Undefined: true }
# CHECK-NEXT: ...
diff --git a/llvm/test/tools/llvm-ifs/ios-tbd.ifs b/llvm/test/tools/llvm-ifs/ios-tbd.ifs
index a6d3ed86567fe..7d2fac51e3c10 100644
--- a/llvm/test/tools/llvm-ifs/ios-tbd.ifs
+++ b/llvm/test/tools/llvm-ifs/ios-tbd.ifs
@@ -1,4 +1,4 @@
-# RUN: llvm-ifs --action write-bin -force-format TBD -o - %s | FileCheck %s
+# RUN: llvm-ifs --input-format=IFS --output-format=TBD -o - %s | FileCheck %s
# CHECK: --- !tapi-tbd-v3
# CHECK-NEXT: archs: [ arm64 ]
diff --git a/llvm/test/tools/llvm-ifs/macos-tbd.ifs b/llvm/test/tools/llvm-ifs/macos-tbd.ifs
index eb7ab6535f952..684127e7079b9 100644
--- a/llvm/test/tools/llvm-ifs/macos-tbd.ifs
+++ b/llvm/test/tools/llvm-ifs/macos-tbd.ifs
@@ -1,4 +1,4 @@
-# RUN: llvm-ifs --action write-bin -force-format TBD -o - %s | FileCheck %s
+# RUN: llvm-ifs --input-format=IFS --output-format=TBD -o - %s | FileCheck %s
# CHECK: --- !tapi-tbd-v3
# CHECK-NEXT: archs: [ arm64 ]
diff --git a/llvm/test/tools/llvm-ifs/object-function-size-weak-combo.ifs b/llvm/test/tools/llvm-ifs/object-function-size-weak-combo.ifs
index 470dcdc362c0f..803633395a043 100644
--- a/llvm/test/tools/llvm-ifs/object-function-size-weak-combo.ifs
+++ b/llvm/test/tools/llvm-ifs/object-function-size-weak-combo.ifs
@@ -1,7 +1,7 @@
-# RUN: llvm-ifs -action write-ifs -o - %s %S/func.ifs %S/object.ifs %S/weak.ifs | \
+# RUN: llvm-ifs --input-format=IFS --output-format=IFS -o - %s %S/func.ifs %S/object.ifs %S/weak.ifs | \
# RUN: FileCheck %s --check-prefixes=CHECK-IFS
-# RUN: llvm-ifs -action write-bin -o - %s %S/func.ifs %S/object.ifs %S/weak.ifs | \
+# RUN: llvm-ifs --input-format=IFS --output-format=ELF -o - %s %S/func.ifs %S/object.ifs %S/weak.ifs | \
# RUN: llvm-readelf --all - | FileCheck %s --check-prefixes=CHECK-ELF
# CHECK-IFS: --- !ifs-v1
diff --git a/llvm/test/tools/llvm-ifs/object.ifs b/llvm/test/tools/llvm-ifs/object.ifs
index 34e1ebc02c100..1e82151a05802 100644
--- a/llvm/test/tools/llvm-ifs/object.ifs
+++ b/llvm/test/tools/llvm-ifs/object.ifs
@@ -1,7 +1,7 @@
-# RUN: llvm-ifs -action write-ifs -o - %s | \
+# RUN: llvm-ifs --input-format=IFS --output-format=IFS -o - %s | \
# RUN: FileCheck %s --check-prefixes=CHECK-IFS
-# RUN: llvm-ifs -action write-bin -o - %s | \
+# RUN: llvm-ifs --input-format=IFS --output-format=ELF -o - %s | \
# RUN: llvm-readelf --all - | FileCheck %s --check-prefixes=CHECK-ELF
# CHECK-IFS: --- !ifs-v1
diff --git a/llvm/test/tools/llvm-ifs/output-target-error.test b/llvm/test/tools/llvm-ifs/output-target-error.test
index 8aa5fa8028465..7c6f8fba8657e 100644
--- a/llvm/test/tools/llvm-ifs/output-target-error.test
+++ b/llvm/test/tools/llvm-ifs/output-target-error.test
@@ -1,7 +1,7 @@
-## Test running llvm-elfabi without specifying a valid target.
+## Test running llvm-ifs without specifying a valid target.
-# RUN: not llvm-elfabi --output=%t %s 2>&1 | FileCheck %s --check-prefix=MISSING
-# RUN: not llvm-elfabi --output-format=nope --output=%t %s 2>&1 | FileCheck %s --check-prefix=INVALID
+# RUN: not llvm-ifs --output=%t %s 2>&1 | FileCheck %s --check-prefix=MISSING
+# RUN: not llvm-ifs --output-format=nope --output=%t %s 2>&1 | FileCheck %s --check-prefix=INVALID
--- !ifs-v1
SoName: somelib.so
@@ -10,6 +10,6 @@ Target: { ObjectFormat: ELF, Arch: x86_64, Endianness: little, BitWidth: 64 }
Symbols: []
...
-# MISSING: llvm-elfabi: for the --output-format option: must be specified at least once!
+# MISSING: {{llvm-ifs(\.exe)?}}: for the --output-format option: must be specified at least once!
-# INVALID: llvm-elfabi: for the --output-format option: Cannot find option named 'nope'!
+# INVALID: {{llvm-ifs(\.exe)?}}: for the --output-format option: Cannot find option named 'nope'!
diff --git a/llvm/test/tools/llvm-ifs/preserve-dates-ifs.test b/llvm/test/tools/llvm-ifs/preserve-dates-ifs.test
index ef5989fad11b0..51e1cd2895ab2 100644
--- a/llvm/test/tools/llvm-ifs/preserve-dates-ifs.test
+++ b/llvm/test/tools/llvm-ifs/preserve-dates-ifs.test
@@ -1,8 +1,8 @@
## Test writing unchanged content to TBE file with --write-if-changed flag.
-# RUN: llvm-elfabi --input-format=ELF --output-format=IFS --output=%t %p/Inputs/gnu_hash.so
+# RUN: llvm-ifs --input-format=ELF --output-format=IFS --output=%t %p/Inputs/gnu_hash.so
# RUN: env TZ=GMT touch -m -t 197001010000 %t
-# RUN: llvm-elfabi --input-format=ELF --output-format=IFS --output=%t --write-if-changed %p/Inputs/gnu_hash.so
+# RUN: llvm-ifs --input-format=ELF --output-format=IFS --output=%t --write-if-changed %p/Inputs/gnu_hash.so
# RUN: env TZ=GMT ls -l %t | FileCheck %s
# CHECK: {{[[:space:]]1970}}
diff --git a/llvm/test/tools/llvm-ifs/preserve-dates-stub.test b/llvm/test/tools/llvm-ifs/preserve-dates-stub.test
index 3ca0f13672bb5..875f6d272d92d 100644
--- a/llvm/test/tools/llvm-ifs/preserve-dates-stub.test
+++ b/llvm/test/tools/llvm-ifs/preserve-dates-stub.test
@@ -1,8 +1,8 @@
## Test writing unchanged content to ELF Stub file with --write-if-changed flag.
-# RUN: llvm-elfabi --output-format=ELF --output=%t %s
+# RUN: llvm-ifs --output-format=ELF --output=%t %s
# RUN: env TZ=GMT touch -m -t 197001010000 %t
-# RUN: llvm-elfabi --output-format=ELF --output=%t --write-if-changed %s
+# RUN: llvm-ifs --output-format=ELF --output=%t --write-if-changed %s
# RUN: env TZ=GMT ls -l %t | FileCheck %s
--- !ifs-v1
diff --git a/llvm/test/tools/llvm-ifs/read-elf-dynsym.test b/llvm/test/tools/llvm-ifs/read-elf-dynsym.test
index 87347e7c91f7b..848c1b89f6851 100644
--- a/llvm/test/tools/llvm-ifs/read-elf-dynsym.test
+++ b/llvm/test/tools/llvm-ifs/read-elf-dynsym.test
@@ -3,28 +3,28 @@
## * Section headers are stripped but there is a DT_GNU_HASH dynamic tag.
## * Section headers are stripped but there is a DT_HASH dynamic tag.
-## Test if llvm-elfabi reads DT_SYMTAB size through section headers by puting the wrong terminator in DT_GNU_HASH.
+## Test if llvm-ifs reads DT_SYMTAB size through section headers by puting the wrong terminator in DT_GNU_HASH.
# RUN: yaml2obj %s -o %tfull -DGNUHASHVALUE="[0x9]" -DTAG1="DT_GNU_HASH" -DVAL1="0xC00"
-# RUN: llvm-elfabi --input-format=ELF --output-format=IFS --output=- %tfull | FileCheck %s
+# RUN: llvm-ifs --input-format=ELF --output-format=IFS --output=- %tfull | FileCheck %s
-## Test if llvm-elfabi fails to read DT_SYMTAB size through section headers when the value of sh_entsize is invalid.
+## Test if llvm-ifs fails to read DT_SYMTAB size through section headers when the value of sh_entsize is invalid.
# RUN: yaml2obj %s -o %tfull -DGNUHASHVALUE="[0x9]" -DTAG1="DT_GNU_HASH" -DVAL1="0xC00" -DENTSIZE="0x19"
-# RUN: not llvm-elfabi --input-format=ELF --output-format=IFS --output=- %tfull 2>&1 | FileCheck %s --check-prefix=BADENTSIZE
+# RUN: not llvm-ifs --input-format=ELF --output-format=IFS --output=- %tfull 2>&1 | FileCheck %s --check-prefix=BADENTSIZE
-## Test if llvm-elfabi reads DT_SYMTAB size through DT_GNU_HASH.
+## Test if llvm-ifs reads DT_SYMTAB size through DT_GNU_HASH.
# RUN: yaml2obj %s -o %tw.gnu.hash -DGNUHASHVALUE="[0x8, 0x9]" -DTAG1="DT_GNU_HASH" -DVAL1="0xC00" -DNOHEADER="true"
-# RUN: llvm-elfabi --input-format=ELF --output-format=IFS --output=- %tw.gnu.hash | FileCheck %s
+# RUN: llvm-ifs --input-format=ELF --output-format=IFS --output=- %tw.gnu.hash | FileCheck %s
-## Test if llvm-elfabi fails to read DT_SYMTAB size through DT_GNU_HASH when there is no terminator.
+## Test if llvm-ifs fails to read DT_SYMTAB size through DT_GNU_HASH when there is no terminator.
# RUN: yaml2obj %s -o %tw.gnu.hash -DGNUHASHVALUE="[0x8, 0xA]" -DTAG1="DT_GNU_HASH" -DVAL1="0xC00" -DNOHEADER="true"
-# RUN: not llvm-elfabi --input-format=ELF --output-format=IFS --output=- %tw.gnu.hash 2>&1 | FileCheck %s --check-prefix=NOTERMINATOR
+# RUN: not llvm-ifs --input-format=ELF --output-format=IFS --output=- %tw.gnu.hash 2>&1 | FileCheck %s --check-prefix=NOTERMINATOR
# CHECK: --- !ifs-v1
# CHECK-NEXT: IfsVersion: 3.0
# CHECK-NEXT: Target: { ObjectFormat: ELF, Arch: AArch64, Endianness: little, BitWidth: 64 }
# CHECK-NEXT: Symbols:
-# CHECK-NEXT: - { Name: foo, Type: Func, Undefined: true }
# CHECK-NEXT: - { Name: bar, Type: Object, Size: 0, Undefined: true }
+# CHECK-NEXT: - { Name: foo, Type: Func, Undefined: true }
# CHECK-NEXT: ...
# BADENTSIZE: SHT_DYNSYM section has sh_size (72) % sh_entsize (25) that is not 0
diff --git a/llvm/test/tools/llvm-ifs/read-ifs-as-elf.test b/llvm/test/tools/llvm-ifs/read-ifs-as-elf.test
index a977fcba7d3f2..22047a3ba2ecb 100644
--- a/llvm/test/tools/llvm-ifs/read-ifs-as-elf.test
+++ b/llvm/test/tools/llvm-ifs/read-ifs-as-elf.test
@@ -1,4 +1,4 @@
-# RUN: not llvm-elfabi --input-format=ELF --output-format=IFS --output=%t %s 2>&1 | FileCheck %s
+# RUN: not llvm-ifs --input-format=ELF --output-format=IFS --output=%t %s 2>&1 | FileCheck %s
--- !ifs-v1
SoName: somelib.so
diff --git a/llvm/test/tools/llvm-ifs/read-ifs-as-ifs.test b/llvm/test/tools/llvm-ifs/read-ifs-as-ifs.test
index cff2d4ffa5a6d..77ad93488a28d 100644
--- a/llvm/test/tools/llvm-ifs/read-ifs-as-ifs.test
+++ b/llvm/test/tools/llvm-ifs/read-ifs-as-ifs.test
@@ -1,4 +1,4 @@
-# RUN: llvm-elfabi --input-format=IFS --output-format=IFS --output=- %s | FileCheck %s
+# RUN: llvm-ifs --input-format=IFS --output-format=IFS --output=- %s | FileCheck %s
--- !ifs-v1
IfsVersion: 3.0
diff --git a/llvm/test/tools/llvm-ifs/read-ifs-with-bad-bitwidth.test b/llvm/test/tools/llvm-ifs/read-ifs-with-bad-bitwidth.test
index f7b2505ff3168..8f5e6d7aad36d 100644
--- a/llvm/test/tools/llvm-ifs/read-ifs-with-bad-bitwidth.test
+++ b/llvm/test/tools/llvm-ifs/read-ifs-with-bad-bitwidth.test
@@ -1,6 +1,6 @@
## Test reading TBE file with bad bit width.
-# RUN: not llvm-elfabi --output-format=IFS --output=- %s 2>&1 | FileCheck %s
+# RUN: not llvm-ifs --output-format=IFS --output=- %s 2>&1 | FileCheck %s
--- !ifs-v1
SoName: somelib.so
diff --git a/llvm/test/tools/llvm-ifs/read-ifs-with-bad-endianness.test b/llvm/test/tools/llvm-ifs/read-ifs-with-bad-endianness.test
index 3b76ffa1ad16b..6ce8e0dfdf0a2 100644
--- a/llvm/test/tools/llvm-ifs/read-ifs-with-bad-endianness.test
+++ b/llvm/test/tools/llvm-ifs/read-ifs-with-bad-endianness.test
@@ -1,6 +1,6 @@
## Test reading TBE file with bad endianness.
-# RUN: not llvm-elfabi --output-format=IFS --output=- %s 2>&1 | FileCheck %s
+# RUN: not llvm-ifs --output-format=IFS --output=- %s 2>&1 | FileCheck %s
--- !ifs-v1
SoName: somelib.so
diff --git a/llvm/test/tools/llvm-ifs/read-unsupported-file.test b/llvm/test/tools/llvm-ifs/read-unsupported-file.test
index d5582dd85b170..49ea6ffe2bf95 100644
--- a/llvm/test/tools/llvm-ifs/read-unsupported-file.test
+++ b/llvm/test/tools/llvm-ifs/read-unsupported-file.test
@@ -1,6 +1,6 @@
-# RUN: not llvm-elfabi --output-format=IFS --output=- %s 2>&1| FileCheck %s
+# RUN: not llvm-ifs --output-format=IFS --output=- %s 2>&1| FileCheck %s
-This is just some text that cannot be read by llvm-elfabi.
+This is just some text that cannot be read by llvm-ifs.
# CHECK: The file was not recognized as a valid object file
# CHECK: YAML failed reading as IFS
diff --git a/llvm/test/tools/llvm-ifs/strip-target.test b/llvm/test/tools/llvm-ifs/strip-target.test
index 61ef05884056f..b1b3adadc2234 100644
--- a/llvm/test/tools/llvm-ifs/strip-target.test
+++ b/llvm/test/tools/llvm-ifs/strip-target.test
@@ -1,10 +1,10 @@
## Test writing tbe with stripped target information.
-# RUN: llvm-elfabi --input-format=ELF --output-format=IFS --strip-ifs-target --output=- %p/Inputs/sysv_hash.so | FileCheck %s --check-prefix=NOTARGET
-# RUN: llvm-elfabi --input-format=ELF --output-format=IFS --strip-ifs-arch --strip-ifs-endianness --strip-ifs-bitwidth --output=- %p/Inputs/sysv_hash.so | FileCheck %s --check-prefix=NOTARGET
-# RUN: llvm-elfabi --input-format=ELF --output-format=IFS --strip-ifs-arch --output=- %p/Inputs/sysv_hash.so | FileCheck %s -DELFTARGET="ObjectFormat: ELF, Endianness: little, BitWidth: 64" --check-prefix=CHECK
-# RUN: llvm-elfabi --input-format=ELF --output-format=IFS --strip-ifs-endianness --output=- %p/Inputs/sysv_hash.so | FileCheck %s -DELFTARGET="ObjectFormat: ELF, Arch: x86_64, BitWidth: 64" --check-prefix=CHECK
-# RUN: llvm-elfabi --input-format=ELF --output-format=IFS --strip-ifs-bitwidth --output=- %p/Inputs/sysv_hash.so | FileCheck %s -DELFTARGET="ObjectFormat: ELF, Arch: x86_64, Endianness: little" --check-prefix=CHECK
+# RUN: llvm-ifs --input-format=ELF --output-format=IFS --strip-ifs-target --output=- %p/Inputs/sysv_hash.so | FileCheck %s --check-prefix=NOTARGET
+# RUN: llvm-ifs --input-format=ELF --output-format=IFS --strip-ifs-arch --strip-ifs-endianness --strip-ifs-bitwidth --output=- %p/Inputs/sysv_hash.so | FileCheck %s --check-prefix=NOTARGET
+# RUN: llvm-ifs --input-format=ELF --output-format=IFS --strip-ifs-arch --output=- %p/Inputs/sysv_hash.so | FileCheck %s -DELFTARGET="ObjectFormat: ELF, Endianness: little, BitWidth: 64" --check-prefix=CHECK
+# RUN: llvm-ifs --input-format=ELF --output-format=IFS --strip-ifs-endianness --output=- %p/Inputs/sysv_hash.so | FileCheck %s -DELFTARGET="ObjectFormat: ELF, Arch: x86_64, BitWidth: 64" --check-prefix=CHECK
+# RUN: llvm-ifs --input-format=ELF --output-format=IFS --strip-ifs-bitwidth --output=- %p/Inputs/sysv_hash.so | FileCheck %s -DELFTARGET="ObjectFormat: ELF, Arch: x86_64, Endianness: little" --check-prefix=CHECK
# CHECK: --- !ifs-v1
diff --git a/llvm/test/tools/llvm-ifs/strong.ifs b/llvm/test/tools/llvm-ifs/strong.ifs
index d9e41cb130318..8ae4f92e12b02 100644
--- a/llvm/test/tools/llvm-ifs/strong.ifs
+++ b/llvm/test/tools/llvm-ifs/strong.ifs
@@ -1,4 +1,4 @@
-# RUN: llvm-ifs -action write-ifs -o - %s %S/strong.ifs | FileCheck %s --check-prefixes=CHECK-IFS
+# RUN: llvm-ifs --input-format=IFS --output-format=IFS -o - %s %S/strong.ifs | FileCheck %s --check-prefixes=CHECK-IFS
# CHECK-IFS: --- !ifs-v1
# CHECK-IFS-NEXT: IfsVersion: 3.0
diff --git a/llvm/test/tools/llvm-ifs/tvos-tbd.ifs b/llvm/test/tools/llvm-ifs/tvos-tbd.ifs
index e8986efcb64f0..1f7c9d3651942 100644
--- a/llvm/test/tools/llvm-ifs/tvos-tbd.ifs
+++ b/llvm/test/tools/llvm-ifs/tvos-tbd.ifs
@@ -1,4 +1,4 @@
-# RUN: llvm-ifs --action write-bin -force-format TBD -o - %s | FileCheck %s
+# RUN: llvm-ifs --input-format=IFS --output-format=TBD -o - %s | FileCheck %s
# CHECK: --- !tapi-tbd-v3
# CHECK-NEXT: archs: [ arm64 ]
diff --git a/llvm/test/tools/llvm-ifs/version-ok.ifs b/llvm/test/tools/llvm-ifs/version-ok.ifs
index 1a5aaf0d3eab3..cf3cd4f707114 100644
--- a/llvm/test/tools/llvm-ifs/version-ok.ifs
+++ b/llvm/test/tools/llvm-ifs/version-ok.ifs
@@ -1,4 +1,4 @@
-# RUN: llvm-ifs -action write-ifs -o - %s %S/object.ifs
+# RUN: llvm-ifs --input-format=IFS --output-format=IFS -o - %s %S/object.ifs
--- !ifs-v1
IfsVersion: 3.0
diff --git a/llvm/test/tools/llvm-ifs/watchos-tbd.ifs b/llvm/test/tools/llvm-ifs/watchos-tbd.ifs
index ec6a6a486d338..4210481a46331 100644
--- a/llvm/test/tools/llvm-ifs/watchos-tbd.ifs
+++ b/llvm/test/tools/llvm-ifs/watchos-tbd.ifs
@@ -1,4 +1,4 @@
-# RUN: llvm-ifs --action write-bin -force-format TBD -o - %s | FileCheck %s
+# RUN: llvm-ifs --input-format=IFS --output-format=TBD -o - %s | FileCheck %s
# CHECK: --- !tapi-tbd-v3
# CHECK-NEXT: archs: [ arm64 ]
diff --git a/llvm/test/tools/llvm-ifs/weak-mismatch.ifs b/llvm/test/tools/llvm-ifs/weak-mismatch.ifs
index 8c8330a9eac3f..9bcdaaac6cbbb 100644
--- a/llvm/test/tools/llvm-ifs/weak-mismatch.ifs
+++ b/llvm/test/tools/llvm-ifs/weak-mismatch.ifs
@@ -1,5 +1,5 @@
-# RUN: not llvm-ifs -action write-ifs -o - %s %S/Inputs/strong-mismatch-size.ifs 2>&1 | FileCheck %s --check-prefixes=CHECK-SIZE
-# RUN: not llvm-ifs -action write-ifs -o - %s %S/Inputs/strong-mismatch-type.ifs 2>&1 | FileCheck %s --check-prefixes=CHECK-TYPE
+# RUN: not llvm-ifs --input-format=IFS --output-format=IFS -o - %s %S/Inputs/strong-mismatch-size.ifs 2>&1 | FileCheck %s --check-prefixes=CHECK-SIZE
+# RUN: not llvm-ifs --input-format=IFS --output-format=IFS -o - %s %S/Inputs/strong-mismatch-type.ifs 2>&1 | FileCheck %s --check-prefixes=CHECK-TYPE
# CHECK-SIZE: error: Interface Stub: Size Mismatch for foobar.
# CHECK-SIZE-NEXT: Filename:
diff --git a/llvm/test/tools/llvm-ifs/weak.ifs b/llvm/test/tools/llvm-ifs/weak.ifs
index 2e9617843722e..04939c0ec72eb 100644
--- a/llvm/test/tools/llvm-ifs/weak.ifs
+++ b/llvm/test/tools/llvm-ifs/weak.ifs
@@ -1,4 +1,4 @@
-# RUN: llvm-ifs -action write-ifs -o - %s | FileCheck %s --check-prefixes=CHECK-IFS
+# RUN: llvm-ifs --input-format=IFS --output-format=IFS -o - %s | FileCheck %s --check-prefixes=CHECK-IFS
# CHECK-IFS: --- !ifs-v1
# CHECK-IFS-NEXT: IfsVersion: 3.0
diff --git a/llvm/test/tools/llvm-ifs/write-stub-no-nonlocal-symbol.test b/llvm/test/tools/llvm-ifs/write-stub-no-nonlocal-symbol.test
index e1bf7e87c6325..bd02f459fd272 100644
--- a/llvm/test/tools/llvm-ifs/write-stub-no-nonlocal-symbol.test
+++ b/llvm/test/tools/llvm-ifs/write-stub-no-nonlocal-symbol.test
@@ -1,6 +1,6 @@
## Test writing stub elf when symbol table contains no non-local symbol.
-# RUN: llvm-elfabi --output-format=ELF --output=%t %s
+# RUN: llvm-ifs --output-format=ELF --output=%t %s
# RUN: llvm-readobj -S %t | FileCheck %s -DCLASS="64-bit (0x2)" -DDE="LittleEndian (0x1)" -DHS=64 -DPHES=56 -DSHES=64 -DDYNSYMAL=8 -DDYNSYMES=24 -DDYNAMICAL=8 -DDYNAMICES=16 -DDYNTABZ=000000000
--- !ifs-v1
diff --git a/llvm/test/tools/llvm-ifs/write-stub.test b/llvm/test/tools/llvm-ifs/write-stub.test
index 44015e7624cec..60b9b648722cf 100644
--- a/llvm/test/tools/llvm-ifs/write-stub.test
+++ b/llvm/test/tools/llvm-ifs/write-stub.test
@@ -1,35 +1,35 @@
## Test writing stub elf with minimal sections.
-# RUN: llvm-elfabi --output-format=ELF --output=%t.elf32l --arch=x86_64 --bitwidth=32 --endianness=little %s
+# RUN: llvm-ifs --output-format=ELF --output=%t.elf32l --arch=x86_64 --bitwidth=32 --endianness=little %s
# RUN: llvm-readobj -h -S --string-dump .dynstr --string-dump .shstrtab --dyn-symbols --dynamic-table %t.elf32l | FileCheck %s -DCLASS="32-bit (0x1)" -DDE="LittleEndian (0x1)" -DHS=52 -DPHES=32 -DSHES=40 -DDYNSYMAL=4 -DDYNSYMES=16 -DDYNAMICAL=4 -DDYNAMICES=8 -DDYNTABZ=0
-# RUN: llvm-elfabi --output-format=ELF --output=%t.elf32b --arch=x86_64 --bitwidth=32 --endianness=big %s
+# RUN: llvm-ifs --output-format=ELF --output=%t.elf32b --arch=x86_64 --bitwidth=32 --endianness=big %s
# RUN: llvm-readobj -h -S --string-dump .dynstr --string-dump .shstrtab --dyn-symbols --dynamic-table %t.elf32b | FileCheck %s -DCLASS="32-bit (0x1)" -DDE="BigEndian (0x2)" -DHS=52 -DPHES=32 -DSHES=40 -DDYNSYMAL=4 -DDYNSYMES=16 -DDYNAMICAL=4 -DDYNAMICES=8 -DDYNTABZ=0
-# RUN: llvm-elfabi --output-format=ELF --output=%t.elf64l --arch=x86_64 --bitwidth=64 --endianness=little %s
+# RUN: llvm-ifs --output-format=ELF --output=%t.elf64l --arch=x86_64 --bitwidth=64 --endianness=little %s
# RUN: llvm-readobj -h -S --string-dump .dynstr --string-dump .shstrtab --dyn-symbols --dynamic-table %t.elf64l | FileCheck %s -DCLASS="64-bit (0x2)" -DDE="LittleEndian (0x1)" -DHS=64 -DPHES=56 -DSHES=64 -DDYNSYMAL=8 -DDYNSYMES=24 -DDYNAMICAL=8 -DDYNAMICES=16 -DDYNTABZ=000000000
-# RUN: llvm-elfabi --output-format=ELF --output=%t.elf64l --target=x86_64-linux-gnu %s
+# RUN: llvm-ifs --output-format=ELF --output=%t.elf64l --target=x86_64-linux-gnu %s
# RUN: llvm-readobj -h -S --string-dump .dynstr --string-dump .shstrtab --dyn-symbols --dynamic-table %t.elf64l | FileCheck %s -DCLASS="64-bit (0x2)" -DDE="LittleEndian (0x1)" -DHS=64 -DPHES=56 -DSHES=64 -DDYNSYMAL=8 -DDYNSYMES=24 -DDYNAMICAL=8 -DDYNAMICES=16 -DDYNTABZ=000000000
-# RUN: llvm-elfabi --output-format=ELF --output=%t.elf64b --arch=x86_64 --bitwidth=64 --endianness=big %s
+# RUN: llvm-ifs --output-format=ELF --output=%t.elf64b --arch=x86_64 --bitwidth=64 --endianness=big %s
# RUN: llvm-readobj -h -S --string-dump .dynstr --string-dump .shstrtab --dyn-symbols --dynamic-table %t.elf64b | FileCheck %s -DCLASS="64-bit (0x2)" -DDE="BigEndian (0x2)" -DHS=64 -DPHES=56 -DSHES=64 -DDYNSYMAL=8 -DDYNSYMES=24 -DDYNAMICAL=8 -DDYNAMICES=16 -DDYNTABZ=000000000
-# RUN: not llvm-elfabi --output-format=ELF --output=%t --arch=x86_64 --bitwidth=64 --endianness=big --target=x86_64-linux-gnu %s 2>&1 | FileCheck %s --check-prefix=TRIPLEERR
+# RUN: not llvm-ifs --output-format=ELF --output=%t --arch=x86_64 --bitwidth=64 --endianness=big --target=x86_64-linux-gnu %s 2>&1 | FileCheck %s --check-prefix=TRIPLEERR
-# RUN: not llvm-elfabi --output-format=ELF --output=%t --bitwidth=64 --endianness=big %s 2>&1 | FileCheck %s -DMSG="Arch" --check-prefix=TARGETERR
+# RUN: not llvm-ifs --output-format=ELF --output=%t --bitwidth=64 --endianness=big %s 2>&1 | FileCheck %s -DMSG="Arch" --check-prefix=TARGETERR
-# RUN: not llvm-elfabi --output-format=ELF --output=%t --arch=x86_64 --endianness=big %s 2>&1 | FileCheck %s -DMSG="BitWidth" --check-prefix=TARGETERR
+# RUN: not llvm-ifs --output-format=ELF --output=%t --arch=x86_64 --endianness=big %s 2>&1 | FileCheck %s -DMSG="BitWidth" --check-prefix=TARGETERR
-# RUN: not llvm-elfabi --output-format=ELF --output=%t --arch=x86_64 --bitwidth=64 %s 2>&1 | FileCheck %s -DMSG="Endianness" --check-prefix=TARGETERR
+# RUN: not llvm-ifs --output-format=ELF --output=%t --arch=x86_64 --bitwidth=64 %s 2>&1 | FileCheck %s -DMSG="Endianness" --check-prefix=TARGETERR
-# RUN: llvm-elfabi --output-format=IFS --output=%t.target --target=x86_64-linux-gnu %s
-# RUN: not llvm-elfabi --output-format=ELF --output=%t --target=aarch64-linux-gnu %t.target 2>&1 | FileCheck %s -DMSG="Triple" --check-prefix=CONFLICTERR
+# RUN: llvm-ifs --output-format=IFS --output=%t.target --target=x86_64-linux-gnu %s
+# RUN: not llvm-ifs --output-format=ELF --output=%t --target=aarch64-linux-gnu %t.target 2>&1 | FileCheck %s -DMSG="Triple" --check-prefix=CONFLICTERR
-# RUN: llvm-elfabi --output-format=IFS --output=%t.target --arch=x86_64 --endianness=little --bitwidth=64 %s
-# RUN: not llvm-elfabi --output-format=ELF --output=%t --arch=AArch64 %t.target 2>&1 | FileCheck %s -DMSG=Arch --check-prefix=CONFLICTERR
-# RUN: not llvm-elfabi --output-format=ELF --output=%t --endianness=big %t.target 2>&1 | FileCheck %s -DMSG=Endianness --check-prefix=CONFLICTERR
-# RUN: not llvm-elfabi --output-format=ELF --output=%t --bitwidth=32 %t.target 2>&1 | FileCheck %s -DMSG=BitWidth --check-prefix=CONFLICTERR
+# RUN: llvm-ifs --output-format=IFS --output=%t.target --arch=x86_64 --endianness=little --bitwidth=64 %s
+# RUN: not llvm-ifs --output-format=ELF --output=%t --arch=AArch64 %t.target 2>&1 | FileCheck %s -DMSG=Arch --check-prefix=CONFLICTERR
+# RUN: not llvm-ifs --output-format=ELF --output=%t --endianness=big %t.target 2>&1 | FileCheck %s -DMSG=Endianness --check-prefix=CONFLICTERR
+# RUN: not llvm-ifs --output-format=ELF --output=%t --bitwidth=32 %t.target 2>&1 | FileCheck %s -DMSG=BitWidth --check-prefix=CONFLICTERR
--- !ifs-v1
IfsVersion: 3.0
diff --git a/llvm/tools/llvm-elfabi/CMakeLists.txt b/llvm/tools/llvm-elfabi/CMakeLists.txt
deleted file mode 100644
index 85eb3a4ed7785..0000000000000
--- a/llvm/tools/llvm-elfabi/CMakeLists.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-set(LLVM_LINK_COMPONENTS
- BinaryFormat
- InterfaceStub
- Object
- Support
- TextAPI
- )
-
-add_llvm_tool(llvm-elfabi
- ErrorCollector.cpp
- llvm-elfabi.cpp
- )
diff --git a/llvm/tools/llvm-elfabi/llvm-elfabi.cpp b/llvm/tools/llvm-elfabi/llvm-elfabi.cpp
deleted file mode 100644
index 4e80fcaf17998..0000000000000
--- a/llvm/tools/llvm-elfabi/llvm-elfabi.cpp
+++ /dev/null
@@ -1,233 +0,0 @@
-//===- llvm-elfabi.cpp ----------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===-----------------------------------------------------------------------===/
-
-#include "ErrorCollector.h"
-#include "llvm/InterfaceStub/ELFObjHandler.h"
-#include "llvm/InterfaceStub/IFSHandler.h"
-#include "llvm/Support/CommandLine.h"
-#include "llvm/Support/Errc.h"
-#include "llvm/Support/FileOutputBuffer.h"
-#include "llvm/Support/MemoryBuffer.h"
-#include "llvm/Support/Path.h"
-#include "llvm/Support/WithColor.h"
-#include "llvm/Support/raw_ostream.h"
-#include <string>
-
-namespace llvm {
-namespace elfabi {
-
-enum class FileFormat { IFS, ELF };
-
-} // namespace elfabi
-} // end namespace llvm
-
-using namespace llvm;
-using namespace llvm::elfabi;
-
-// Command line flags:
-cl::opt<std::string> InputFilePath(cl::Positional, cl::desc("input"),
- cl::Required);
-cl::opt<FileFormat> InputFormat(
- "input-format", cl::desc("Specify the input file format"),
- cl::values(clEnumValN(FileFormat::IFS, "IFS", "Text based ELF stub file"),
- clEnumValN(FileFormat::ELF, "ELF", "ELF object file")));
-cl::opt<FileFormat> OutputFormat(
- "output-format", cl::desc("Specify the output file format"),
- cl::values(clEnumValN(FileFormat::IFS, "IFS", "Text based ELF stub file"),
- clEnumValN(FileFormat::ELF, "ELF", "ELF stub file")),
- cl::Required);
-cl::opt<std::string> OptArch("arch",
- cl::desc("Specify the architecture, e.g. x86_64"));
-cl::opt<IFSBitWidthType> OptBitWidth(
- "bitwidth", cl::desc("Specify the bit width"),
- cl::values(clEnumValN(IFSBitWidthType::IFS32, "32", "32 bits"),
- clEnumValN(IFSBitWidthType::IFS64, "64", "64 bits")));
-cl::opt<IFSEndiannessType> OptEndianness(
- "endianness", cl::desc("Specify the endianness"),
- cl::values(clEnumValN(IFSEndiannessType::Little, "little", "Little Endian"),
- clEnumValN(IFSEndiannessType::Big, "big", "Big Endian")));
-cl::opt<std::string> OptTargetTriple(
- "target", cl::desc("Specify the target triple, e.g. x86_64-linux-gnu"));
-cl::opt<std::string> OptTargetTripleHint(
- "hint-ifs-target",
- cl::desc("When --output-format is 'IFS', this flag will hint the expected "
- "target triple for IFS output"));
-cl::opt<bool> StripIFSArch(
- "strip-ifs-arch",
- cl::desc("Strip target architecture information away from IFS output"));
-cl::opt<bool> StripIFSBitWidth(
- "strip-ifs-bitwidth",
- cl::desc("Strip target bit width information away from IFS output"));
-cl::opt<bool> StripIFSEndiannessWidth(
- "strip-ifs-endianness",
- cl::desc("Strip target endianness information away from IFS output"));
-cl::opt<bool> StripIFSTarget(
- "strip-ifs-target",
- cl::desc("Strip all target information away from IFS output"));
-cl::opt<std::string>
- SOName("soname",
- cl::desc("Manually set the DT_SONAME entry of any emitted files"),
- cl::value_desc("name"));
-cl::opt<std::string> OutputFilePath("output", cl::desc("Output file"));
-cl::opt<bool> WriteIfChanged(
- "write-if-changed",
- cl::desc("Write the output file only if it is new or has changed."));
-
-/// writeIFS() writes a Text-Based ELF stub to a file using the latest version
-/// of the YAML parser.
-static Error writeIFS(StringRef FilePath, IFSStub &Stub) {
- // Write IFS to memory first.
- std::string IFSStr;
- raw_string_ostream OutStr(IFSStr);
- Error YAMLErr = writeIFSToOutputStream(OutStr, Stub);
- if (YAMLErr)
- return YAMLErr;
- OutStr.flush();
-
- if (WriteIfChanged) {
- if (ErrorOr<std::unique_ptr<MemoryBuffer>> BufOrError =
- MemoryBuffer::getFile(FilePath)) {
- // Compare IFS output with existing IFS file.
- // If IFS file unchanged, abort updating.
- if ((*BufOrError)->getBuffer() == IFSStr)
- return Error::success();
- }
- }
- // Open IFS file for writing.
- std::error_code SysErr;
- raw_fd_ostream Out(FilePath, SysErr);
- if (SysErr)
- return createStringError(SysErr, "Couldn't open `%s` for writing",
- FilePath.data());
- Out << IFSStr;
- return Error::success();
-}
-
-/// readInputFile populates an IFSStub by attempting to read the
-/// input file using both the IFS and binary ELF parsers.
-static Expected<std::unique_ptr<IFSStub>> readInputFile(StringRef FilePath) {
- // Read in file.
- ErrorOr<std::unique_ptr<MemoryBuffer>> BufOrError =
- MemoryBuffer::getFile(FilePath);
- if (!BufOrError) {
- return createStringError(BufOrError.getError(), "Could not open `%s`",
- FilePath.data());
- }
-
- std::unique_ptr<MemoryBuffer> FileReadBuffer = std::move(*BufOrError);
- ErrorCollector EC(/*UseFatalErrors=*/false);
-
- // First try to read as a binary (fails fast if not binary).
- if (InputFormat.getNumOccurrences() == 0 || InputFormat == FileFormat::ELF) {
- Expected<std::unique_ptr<IFSStub>> StubFromELF =
- readELFFile(FileReadBuffer->getMemBufferRef());
- if (StubFromELF) {
- return std::move(*StubFromELF);
- }
- EC.addError(StubFromELF.takeError(), "BinaryRead");
- }
-
- // Fall back to reading as a ifs.
- if (InputFormat.getNumOccurrences() == 0 || InputFormat == FileFormat::IFS) {
- Expected<std::unique_ptr<IFSStub>> StubFromIFS =
- readIFSFromBuffer(FileReadBuffer->getBuffer());
- if (StubFromIFS) {
- return std::move(*StubFromIFS);
- }
- EC.addError(StubFromIFS.takeError(), "YamlParse");
- }
-
- // If both readers fail, build a new error that includes all information.
- EC.addError(createStringError(errc::not_supported,
- "No file readers succeeded reading `%s` "
- "(unsupported/malformed file?)",
- FilePath.data()),
- "ReadInputFile");
- EC.escalateToFatal();
- return EC.makeError();
-}
-
-static void fatalError(Error Err) {
- WithColor::defaultErrorHandler(std::move(Err));
- exit(1);
-}
-
-int main(int argc, char *argv[]) {
- // Parse arguments.
- cl::ParseCommandLineOptions(argc, argv);
- Expected<std::unique_ptr<IFSStub>> StubOrErr = readInputFile(InputFilePath);
- if (!StubOrErr)
- fatalError(StubOrErr.takeError());
-
- std::unique_ptr<IFSStub> TargetStub = std::move(StubOrErr.get());
-
- // Change SoName before emitting stubs.
- if (SOName.getNumOccurrences() == 1)
- TargetStub->SoName = SOName;
- Optional<IFSArch> OverrideArch;
- Optional<IFSEndiannessType> OverrideEndianness;
- Optional<IFSBitWidthType> OverrideBitWidth;
- Optional<std::string> OverrideTriple;
- if (OptArch.getNumOccurrences() == 1) {
- OverrideArch = ELF::convertArchNameToEMachine(OptArch.getValue());
- }
- if (OptEndianness.getNumOccurrences() == 1)
- OverrideEndianness = OptEndianness.getValue();
- if (OptBitWidth.getNumOccurrences() == 1)
- OverrideBitWidth = OptBitWidth.getValue();
- if (OptTargetTriple.getNumOccurrences() == 1)
- OverrideTriple = OptTargetTriple.getValue();
- Error OverrideError =
- overrideIFSTarget(*TargetStub, OverrideArch, OverrideEndianness,
- OverrideBitWidth, OverrideTriple);
- if (OverrideError)
- fatalError(std::move(OverrideError));
- switch (OutputFormat.getValue()) {
- case FileFormat::IFS: {
- TargetStub->IfsVersion = IFSVersionCurrent;
- if (InputFormat.getValue() == FileFormat::ELF &&
- OptTargetTripleHint.getNumOccurrences() == 1) {
- std::error_code HintEC(1, std::generic_category());
- IFSTarget HintTarget = parseTriple(OptTargetTripleHint);
- if (TargetStub->Target.Arch.getValue() != HintTarget.Arch.getValue()) {
- fatalError(make_error<StringError>(
- "Triple hint does not match the actual architecture", HintEC));
- }
- if (TargetStub->Target.Endianness.getValue() !=
- HintTarget.Endianness.getValue()) {
- fatalError(make_error<StringError>(
- "Triple hint does not match the actual endianness", HintEC));
- }
- if (TargetStub->Target.BitWidth.getValue() !=
- HintTarget.BitWidth.getValue()) {
- fatalError(make_error<StringError>(
- "Triple hint does not match the actual bit width", HintEC));
- }
- stripIFSTarget(*TargetStub, true, false, false, false);
- TargetStub->Target.Triple = OptTargetTripleHint.getValue();
- } else {
- stripIFSTarget(*TargetStub, StripIFSTarget, StripIFSArch,
- StripIFSEndiannessWidth, StripIFSBitWidth);
- }
- Error IFSWriteError = writeIFS(OutputFilePath.getValue(), *TargetStub);
- if (IFSWriteError)
- fatalError(std::move(IFSWriteError));
- break;
- }
- case FileFormat::ELF: {
- Error TargetError = validateIFSTarget(*TargetStub, true);
- if (TargetError)
- fatalError(std::move(TargetError));
- Error BinaryWriteError =
- writeBinaryStub(OutputFilePath, *TargetStub, WriteIfChanged);
- if (BinaryWriteError)
- fatalError(std::move(BinaryWriteError));
- break;
- }
- }
-}
diff --git a/llvm/tools/llvm-ifs/CMakeLists.txt b/llvm/tools/llvm-ifs/CMakeLists.txt
index 373ef2ba2c287..e36e27f6d1d8f 100644
--- a/llvm/tools/llvm-ifs/CMakeLists.txt
+++ b/llvm/tools/llvm-ifs/CMakeLists.txt
@@ -7,5 +7,6 @@ set(LLVM_LINK_COMPONENTS
)
add_llvm_tool(llvm-ifs
+ ErrorCollector.cpp
llvm-ifs.cpp
)
diff --git a/llvm/tools/llvm-elfabi/ErrorCollector.cpp b/llvm/tools/llvm-ifs/ErrorCollector.cpp
similarity index 98%
rename from llvm/tools/llvm-elfabi/ErrorCollector.cpp
rename to llvm/tools/llvm-ifs/ErrorCollector.cpp
index a52aeff8266bf..087a30c502c22 100644
--- a/llvm/tools/llvm-elfabi/ErrorCollector.cpp
+++ b/llvm/tools/llvm-ifs/ErrorCollector.cpp
@@ -14,7 +14,7 @@
#include <vector>
using namespace llvm;
-using namespace llvm::elfabi;
+using namespace llvm::ifs;
void ErrorCollector::escalateToFatal() { ErrorsAreFatal = true; }
diff --git a/llvm/tools/llvm-elfabi/ErrorCollector.h b/llvm/tools/llvm-ifs/ErrorCollector.h
similarity index 93%
rename from llvm/tools/llvm-elfabi/ErrorCollector.h
rename to llvm/tools/llvm-ifs/ErrorCollector.h
index e2eb1c5ed9f3b..67996f4b00527 100644
--- a/llvm/tools/llvm-elfabi/ErrorCollector.h
+++ b/llvm/tools/llvm-ifs/ErrorCollector.h
@@ -18,14 +18,14 @@
///
//===-----------------------------------------------------------------------===/
-#ifndef LLVM_TOOLS_ELFABI_ERRORCOLLECTOR_H
-#define LLVM_TOOLS_ELFABI_ERRORCOLLECTOR_H
+#ifndef LLVM_TOOLS_LLVM_IFS_ERRORCOLLECTOR_H
+#define LLVM_TOOLS_LLVM_IFS_ERRORCOLLECTOR_H
#include "llvm/Support/Error.h"
#include <vector>
namespace llvm {
-namespace elfabi {
+namespace ifs {
class ErrorCollector {
public:
@@ -68,7 +68,7 @@ class ErrorCollector {
std::vector<std::string> Tags;
};
-} // end namespace elfabi
+} // end namespace ifs
} // end namespace llvm
-#endif // LLVM_TOOLS_ELFABI_ERRORCOLLECTOR_H
+#endif // LLVM_TOOLS_LLVM_IFS_ERRORCOLLECTOR_H
diff --git a/llvm/tools/llvm-ifs/llvm-ifs.cpp b/llvm/tools/llvm-ifs/llvm-ifs.cpp
index 41c193c778c1c..324dd3931265f 100644
--- a/llvm/tools/llvm-ifs/llvm-ifs.cpp
+++ b/llvm/tools/llvm-ifs/llvm-ifs.cpp
@@ -6,6 +6,7 @@
//
//===-----------------------------------------------------------------------===/
+#include "ErrorCollector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/ADT/Triple.h"
@@ -34,41 +35,68 @@
using namespace llvm;
using namespace llvm::yaml;
using namespace llvm::MachO;
+using namespace llvm::ifs;
#define DEBUG_TYPE "llvm-ifs"
namespace {
-const VersionTuple IFSVersionCurrent(3, 0);
-} // end anonymous namespace
-
-static cl::opt<std::string> Action("action", cl::desc("<llvm-ifs action>"),
- cl::value_desc("write-ifs | write-bin"),
- cl::init("write-ifs"));
-
-static cl::opt<std::string> ForceFormat("force-format",
- cl::desc("<force object format>"),
- cl::value_desc("ELF | TBD"),
- cl::init(""));
+const VersionTuple IfsVersionCurrent(3, 0);
-static cl::list<std::string> InputFilenames(cl::Positional,
- cl::desc("<input ifs files>"),
- cl::ZeroOrMore);
-
-static cl::opt<std::string> OutputFilename("o", cl::desc("<output file>"),
- cl::value_desc("path"));
-
-static cl::opt<bool> UseInterfaceStub(
- "use-interfacestub",
- cl::desc("Write output ELF file using latest InterfaceStub backend"),
- cl::init(false));
+enum class FileFormat { IFS, ELF, TBD };
+} // end anonymous namespace
-enum class IFSSymbolType {
- NoType = 0,
- Object,
- Func,
- // Type information is 4 bits, so 16 is safely out of range.
- Unknown = 16,
-};
+// TODO: Use OptTable for option parsing in the future.
+// Command line flags:
+cl::list<std::string> InputFilePaths(cl::Positional, cl::desc("input"),
+ cl::ZeroOrMore);
+cl::opt<FileFormat> InputFormat(
+ "input-format", cl::desc("Specify the input file format"),
+ cl::values(clEnumValN(FileFormat::IFS, "IFS", "Text based ELF stub file"),
+ clEnumValN(FileFormat::ELF, "ELF", "ELF object file")));
+cl::opt<FileFormat> OutputFormat(
+ "output-format", cl::desc("Specify the output file format"),
+ cl::values(clEnumValN(FileFormat::IFS, "IFS", "Text based ELF stub file"),
+ clEnumValN(FileFormat::ELF, "ELF", "ELF stub file"),
+ clEnumValN(FileFormat::TBD, "TBD", "Apple TBD text stub file")),
+ cl::Required);
+cl::opt<std::string> OptArch("arch",
+ cl::desc("Specify the architecture, e.g. x86_64"));
+cl::opt<IFSBitWidthType> OptBitWidth(
+ "bitwidth", cl::desc("Specify the bit width"),
+ cl::values(clEnumValN(IFSBitWidthType::IFS32, "32", "32 bits"),
+ clEnumValN(IFSBitWidthType::IFS64, "64", "64 bits")));
+cl::opt<IFSEndiannessType> OptEndianness(
+ "endianness", cl::desc("Specify the endianness"),
+ cl::values(clEnumValN(IFSEndiannessType::Little, "little", "Little Endian"),
+ clEnumValN(IFSEndiannessType::Big, "big", "Big Endian")));
+cl::opt<std::string> OptTargetTriple(
+ "target", cl::desc("Specify the target triple, e.g. x86_64-linux-gnu"));
+cl::opt<std::string> OptTargetTripleHint(
+ "hint-ifs-target",
+ cl::desc("When --output-format is 'IFS', this flag will hint the expected "
+ "target triple for IFS output"));
+cl::opt<bool> StripIFSArch(
+ "strip-ifs-arch",
+ cl::desc("Strip target architecture information away from IFS output"));
+cl::opt<bool> StripIFSBitWidth(
+ "strip-ifs-bitwidth",
+ cl::desc("Strip target bit width information away from IFS output"));
+cl::opt<bool> StripIFSEndiannessWidth(
+ "strip-ifs-endianness",
+ cl::desc("Strip target endianness information away from IFS output"));
+cl::opt<bool> StripIFSTarget(
+ "strip-ifs-target",
+ cl::desc("Strip all target information away from IFS output"));
+cl::opt<std::string>
+ SoName("soname",
+ cl::desc("Manually set the DT_SONAME entry of any emitted files"),
+ cl::value_desc("name"));
+cl::opt<std::string> OutputFilePath("output", cl::desc("Output file"));
+cl::alias OutputFilePathA("o", cl::desc("Alias for --output"),
+ cl::aliasopt(OutputFilePath));
+cl::opt<bool> WriteIfChanged(
+ "write-if-changed",
+ cl::desc("Write the output file only if it is new or has changed."));
static std::string getTypeName(IFSSymbolType Type) {
switch (Type) {
@@ -78,108 +106,14 @@ static std::string getTypeName(IFSSymbolType Type) {
return "Func";
case IFSSymbolType::Object:
return "Object";
+ case IFSSymbolType::TLS:
+ return "TLS";
case IFSSymbolType::Unknown:
return "Unknown";
}
llvm_unreachable("Unexpected ifs symbol type.");
}
-struct IFSSymbol {
- IFSSymbol() = default;
- IFSSymbol(std::string SymbolName) : Name(SymbolName) {}
- std::string Name;
- uint64_t Size;
- IFSSymbolType Type;
- bool Weak;
- Optional<std::string> Warning;
- bool operator<(const IFSSymbol &RHS) const { return Name < RHS.Name; }
-};
-
-LLVM_YAML_IS_SEQUENCE_VECTOR(IFSSymbol)
-
-namespace llvm {
-namespace yaml {
-/// YAML traits for IFSSymbolType.
-template <> struct ScalarEnumerationTraits<IFSSymbolType> {
- static void enumeration(IO &IO, IFSSymbolType &SymbolType) {
- IO.enumCase(SymbolType, "NoType", IFSSymbolType::NoType);
- IO.enumCase(SymbolType, "Func", IFSSymbolType::Func);
- IO.enumCase(SymbolType, "Object", IFSSymbolType::Object);
- IO.enumCase(SymbolType, "Unknown", IFSSymbolType::Unknown);
- // Treat other symbol types as noise, and map to Unknown.
- if (!IO.outputting() && IO.matchEnumFallback())
- SymbolType = IFSSymbolType::Unknown;
- }
-};
-
-/// YAML traits for IFSSymbol.
-template <> struct MappingTraits<IFSSymbol> {
- static void mapping(IO &IO, IFSSymbol &Symbol) {
- IO.mapRequired("Name", Symbol.Name);
- IO.mapRequired("Type", Symbol.Type);
- // The need for symbol size depends on the symbol type.
- if (Symbol.Type == IFSSymbolType::NoType)
- IO.mapOptional("Size", Symbol.Size, (uint64_t)0);
- else if (Symbol.Type == IFSSymbolType::Func)
- Symbol.Size = 0;
- else
- IO.mapRequired("Size", Symbol.Size);
- IO.mapOptional("Weak", Symbol.Weak, false);
- IO.mapOptional("Warning", Symbol.Warning);
- }
-
- // Compacts symbol information into a single line.
- static const bool flow = true;
-};
-
-} // namespace yaml
-} // namespace llvm
-
-// A cumulative representation of ELF stubs.
-// Both textual and binary stubs will read into and write from this object.
-class IFSStub {
- // TODO: Add support for symbol versioning.
-public:
- VersionTuple IfsVersion;
- std::string Triple;
- std::string ObjectFileFormat;
- Optional<std::string> SOName;
- std::vector<std::string> NeededLibs;
- std::vector<IFSSymbol> Symbols;
-
- IFSStub() = default;
- IFSStub(const IFSStub &Stub)
- : IfsVersion(Stub.IfsVersion), Triple(Stub.Triple),
- ObjectFileFormat(Stub.ObjectFileFormat), SOName(Stub.SOName),
- NeededLibs(Stub.NeededLibs), Symbols(Stub.Symbols) {}
- IFSStub(IFSStub &&Stub)
- : IfsVersion(std::move(Stub.IfsVersion)), Triple(std::move(Stub.Triple)),
- ObjectFileFormat(std::move(Stub.ObjectFileFormat)),
- SOName(std::move(Stub.SOName)), NeededLibs(std::move(Stub.NeededLibs)),
- Symbols(std::move(Stub.Symbols)) {}
-};
-
-namespace llvm {
-namespace yaml {
-/// YAML traits for IFSStub objects.
-template <> struct MappingTraits<IFSStub> {
- static void mapping(IO &IO, IFSStub &Stub) {
- if (!IO.mapTag("!ifs-v1", true))
- IO.setError("Not a .ifs YAML file.");
-
- auto OldContext = IO.getContext();
- IO.setContext(&Stub);
- IO.mapRequired("IfsVersion", Stub.IfsVersion);
- IO.mapOptional("Target", Stub.Triple);
- IO.mapOptional("SOName", Stub.SOName);
- IO.mapOptional("NeededLibs", Stub.NeededLibs);
- IO.mapRequired("Symbols", Stub.Symbols);
- IO.setContext(&OldContext);
- }
-};
-} // namespace yaml
-} // namespace llvm
-
static Expected<std::unique_ptr<IFSStub>> readInputFile(StringRef FilePath) {
// Read in file.
ErrorOr<std::unique_ptr<MemoryBuffer>> BufOrError =
@@ -189,19 +123,46 @@ static Expected<std::unique_ptr<IFSStub>> readInputFile(StringRef FilePath) {
FilePath.data());
std::unique_ptr<MemoryBuffer> FileReadBuffer = std::move(*BufOrError);
- yaml::Input YamlIn(FileReadBuffer->getBuffer());
- std::unique_ptr<IFSStub> Stub(new IFSStub());
- YamlIn >> *Stub;
-
- if (std::error_code Err = YamlIn.error())
- return createStringError(Err, "Failed reading Interface Stub File.");
+ ErrorCollector EC(/*UseFatalErrors=*/false);
+
+ // First try to read as a binary (fails fast if not binary).
+ if (InputFormat.getNumOccurrences() == 0 || InputFormat == FileFormat::ELF) {
+ Expected<std::unique_ptr<IFSStub>> StubFromELF =
+ readELFFile(FileReadBuffer->getMemBufferRef());
+ if (StubFromELF) {
+ (*StubFromELF)->IfsVersion = IfsVersionCurrent;
+ return std::move(*StubFromELF);
+ }
+ EC.addError(StubFromELF.takeError(), "BinaryRead");
+ }
- if (Stub->IfsVersion > IFSVersionCurrent)
- return make_error<StringError>(
- "IFS version " + Stub->IfsVersion.getAsString() + " is unsupported.",
- std::make_error_code(std::errc::invalid_argument));
+ // Fall back to reading as a ifs.
+ if (InputFormat.getNumOccurrences() == 0 || InputFormat == FileFormat::IFS) {
+ Expected<std::unique_ptr<IFSStub>> StubFromIFS =
+ readIFSFromBuffer(FileReadBuffer->getBuffer());
+ if (StubFromIFS) {
+ if ((*StubFromIFS)->IfsVersion > IfsVersionCurrent)
+ EC.addError(
+ createStringError(errc::not_supported,
+ "IFS version " +
+ (*StubFromIFS)->IfsVersion.getAsString() +
+ " is unsupported."),
+ "ReadInputFile");
+ else
+ return std::move(*StubFromIFS);
+ } else {
+ EC.addError(StubFromIFS.takeError(), "YamlParse");
+ }
+ }
- return std::move(Stub);
+ // If both readers fail, build a new error that includes all information.
+ EC.addError(createStringError(errc::not_supported,
+ "No file readers succeeded reading `%s` "
+ "(unsupported/malformed file?)",
+ FilePath.data()),
+ "ReadInputFile");
+ EC.escalateToFatal();
+ return EC.makeError();
}
static int writeTbdStub(const Triple &T, const std::vector<IFSSymbol> &Symbols,
@@ -220,10 +181,6 @@ static int writeTbdStub(const Triple &T, const std::vector<IFSSymbol> &Symbols,
if (T.isiOS())
return llvm::MachO::PlatformKind::iOS;
- // TODO: Add an option for ForceTriple, but keep ForceFormat for now.
- if (ForceFormat == "TBD")
- return llvm::MachO::PlatformKind::macOS;
-
return createStringError(errc::not_supported, "Invalid Platform.\n");
}(T);
@@ -266,209 +223,69 @@ static int writeTbdStub(const Triple &T, const std::vector<IFSSymbol> &Symbols,
return 0;
}
-static int writeElfStub(const Triple &T, const std::vector<IFSSymbol> &Symbols,
- const StringRef Format, raw_ostream &Out) {
- SmallString<0> Storage;
- Storage.clear();
- raw_svector_ostream OS(Storage);
-
- OS << "--- !ELF\n";
- OS << "FileHeader:\n";
- OS << " Class: ELFCLASS";
- OS << (T.isArch64Bit() ? "64" : "32");
- OS << "\n";
- OS << " Data: ELFDATA2";
- OS << (T.isLittleEndian() ? "LSB" : "MSB");
- OS << "\n";
- OS << " Type: ET_DYN\n";
- OS << " Machine: "
- << llvm::StringSwitch<llvm::StringRef>(T.getArchName())
- .Case("x86_64", "EM_X86_64")
- .Case("i386", "EM_386")
- .Case("i686", "EM_386")
- .Case("aarch64", "EM_AARCH64")
- .Case("amdgcn", "EM_AMDGPU")
- .Case("r600", "EM_AMDGPU")
- .Case("arm", "EM_ARM")
- .Case("thumb", "EM_ARM")
- .Case("avr", "EM_AVR")
- .Case("mips", "EM_MIPS")
- .Case("mipsel", "EM_MIPS")
- .Case("mips64", "EM_MIPS")
- .Case("mips64el", "EM_MIPS")
- .Case("msp430", "EM_MSP430")
- .Case("ppc", "EM_PPC")
- .Case("ppc64", "EM_PPC64")
- .Case("ppc64le", "EM_PPC64")
- .Case("x86", T.isOSIAMCU() ? "EM_IAMCU" : "EM_386")
- .Case("x86_64", "EM_X86_64")
- .Default("EM_NONE")
- << "\nSections:"
- << "\n - Name: .text"
- << "\n Type: SHT_PROGBITS"
- << "\n - Name: .data"
- << "\n Type: SHT_PROGBITS"
- << "\n - Name: .rodata"
- << "\n Type: SHT_PROGBITS"
- << "\nSymbols:\n";
- for (const auto &Symbol : Symbols) {
- OS << " - Name: " << Symbol.Name << "\n"
- << " Type: STT_";
- switch (Symbol.Type) {
- default:
- case IFSSymbolType::NoType:
- OS << "NOTYPE";
- break;
- case IFSSymbolType::Object:
- OS << "OBJECT";
- break;
- case IFSSymbolType::Func:
- OS << "FUNC";
- break;
- }
- OS << "\n Section: .text"
- << "\n Binding: STB_" << (Symbol.Weak ? "WEAK" : "GLOBAL")
- << "\n";
- }
- OS << "...\n";
-
- std::string YamlStr = std::string(OS.str());
-
- // Only or debugging. Not an offical format.
- LLVM_DEBUG({
- if (ForceFormat == "ELFOBJYAML") {
- Out << YamlStr;
- return 0;
- }
- });
-
- yaml::Input YIn(YamlStr);
- auto ErrHandler = [](const Twine &Msg) {
- WithColor::error(errs(), "llvm-ifs") << Msg << "\n";
- };
- return convertYAML(YIn, Out, ErrHandler) ? 0 : 1;
+static void fatalError(Error Err) {
+ WithColor::defaultErrorHandler(std::move(Err));
+ exit(1);
}
-static Error convertIFSStub(const IFSStub &IfsStub, elfabi::IFSStub &ElfStub) {
- ElfStub.IfsVersion = IfsStub.IfsVersion;
- ElfStub.SoName = IfsStub.SOName;
- ElfStub.Target.Triple = IfsStub.Triple;
- ElfStub.NeededLibs = IfsStub.NeededLibs;
- for (const IFSSymbol &IfsSymbol : IfsStub.Symbols) {
- elfabi::IFSSymbol ElfSymbol(IfsSymbol.Name);
- switch (IfsSymbol.Type) {
- case IFSSymbolType::Func:
- ElfSymbol.Type = elfabi::IFSSymbolType::Func;
- break;
- case IFSSymbolType::NoType:
- ElfSymbol.Type = elfabi::IFSSymbolType::NoType;
- break;
- case IFSSymbolType::Object:
- ElfSymbol.Type = elfabi::IFSSymbolType::Object;
- break;
- default:
- ElfSymbol.Type = elfabi::IFSSymbolType::Unknown;
- break;
- // TODO: Add support for TLS?
+/// writeIFS() writes a Text-Based ELF stub to a file using the latest version
+/// of the YAML parser.
+static Error writeIFS(StringRef FilePath, IFSStub &Stub) {
+ // Write IFS to memory first.
+ std::string IFSStr;
+ raw_string_ostream OutStr(IFSStr);
+ Error YAMLErr = writeIFSToOutputStream(OutStr, Stub);
+ if (YAMLErr)
+ return YAMLErr;
+ OutStr.flush();
+
+ if (WriteIfChanged) {
+ if (ErrorOr<std::unique_ptr<MemoryBuffer>> BufOrError =
+ MemoryBuffer::getFile(FilePath)) {
+ // Compare IFS output with the existing IFS file. If unchanged, avoid changing the file.
+ if ((*BufOrError)->getBuffer() == IFSStr)
+ return Error::success();
}
- ElfSymbol.Size = IfsSymbol.Size;
- ElfSymbol.Undefined = false;
- ElfSymbol.Weak = IfsSymbol.Weak;
- ElfSymbol.Warning = IfsSymbol.Warning;
- ElfStub.Symbols.push_back(ElfSymbol);
}
- return llvm::elfabi::validateIFSTarget(ElfStub, true);
-}
-
-static int writeIfso(const IFSStub &Stub, bool IsWriteIfs) {
- std::string ObjectFileFormat =
- ForceFormat.empty() ? std::string("ELF") : ForceFormat;
-
- // Use InterfaceStub library if the option is enabled and output
- // format is ELF.
- if (UseInterfaceStub && (!IsWriteIfs) && ObjectFileFormat != "TBD") {
- elfabi::IFSStub IfsStub;
- Error ConvertError = convertIFSStub(Stub, IfsStub);
- if (ConvertError) {
- return -1;
- }
- Error BinaryWriteError = elfabi::writeBinaryStub(OutputFilename, IfsStub);
- if (BinaryWriteError) {
- return -1;
- }
- return 0;
- }
-
- // Open file for writing.
+ // Open IFS file for writing.
std::error_code SysErr;
- raw_fd_ostream Out(OutputFilename, SysErr);
- if (SysErr) {
- WithColor::error() << "Couldn't open " << OutputFilename
- << " for writing.\n";
- return -1;
- }
-
- if (IsWriteIfs) {
- yaml::Output YamlOut(Out, NULL, /*WrapColumn =*/0);
- YamlOut << const_cast<IFSStub &>(Stub);
- return 0;
- }
-
- if (ObjectFileFormat == "ELF" || ForceFormat == "ELFOBJYAML")
- return writeElfStub(llvm::Triple(Stub.Triple), Stub.Symbols,
- Stub.ObjectFileFormat, Out);
- if (ObjectFileFormat == "TBD")
- return writeTbdStub(llvm::Triple(Stub.Triple), Stub.Symbols,
- Stub.ObjectFileFormat, Out);
-
- WithColor::error()
- << "Invalid ObjectFileFormat: Only ELF and TBD are supported.\n";
- return -1;
+ raw_fd_ostream Out(FilePath, SysErr);
+ if (SysErr)
+ return createStringError(SysErr, "Couldn't open `%s` for writing",
+ FilePath.data());
+ Out << IFSStr;
+ return Error::success();
}
-// TODO: Drop ObjectFileFormat, it can be subsumed from the triple.
-// New Interface Stubs Yaml Format:
-// --- !experimental-ifs-v2
-// IfsVersion: 2.0
-// Triple: <llvm triple>
-// ObjectFileFormat: <ELF | others not yet supported>
-// Symbols:
-// _ZSymbolName: { Type: <type> }
-// ...
-
int main(int argc, char *argv[]) {
// Parse arguments.
cl::ParseCommandLineOptions(argc, argv);
- if (InputFilenames.empty())
- InputFilenames.push_back("-");
+ if (InputFilePaths.empty())
+ InputFilePaths.push_back("-");
+ // If input files are more than one, they can only be IFS files.
+ if (InputFilePaths.size() > 1)
+ InputFormat.setValue(FileFormat::IFS);
+
+ // Attempt to merge input.
IFSStub Stub;
std::map<std::string, IFSSymbol> SymbolMap;
-
std::string PreviousInputFilePath;
- for (const std::string &InputFilePath : InputFilenames) {
+ for (const std::string &InputFilePath : InputFilePaths) {
Expected<std::unique_ptr<IFSStub>> StubOrErr = readInputFile(InputFilePath);
- if (!StubOrErr) {
- WithColor::error() << StubOrErr.takeError() << "\n";
- return -1;
- }
- std::unique_ptr<IFSStub> TargetStub = std::move(StubOrErr.get());
+ if (!StubOrErr)
+ fatalError(StubOrErr.takeError());
- if (Stub.Triple.empty()) {
- PreviousInputFilePath = InputFilePath;
+ std::unique_ptr<IFSStub> TargetStub = std::move(StubOrErr.get());
+ if (PreviousInputFilePath.empty()) {
Stub.IfsVersion = TargetStub->IfsVersion;
- Stub.Triple = TargetStub->Triple;
- Stub.ObjectFileFormat = TargetStub->ObjectFileFormat;
- Stub.SOName = TargetStub->SOName;
+ Stub.Target = TargetStub->Target;
+ Stub.SoName = TargetStub->SoName;
Stub.NeededLibs = TargetStub->NeededLibs;
} else {
- Stub.ObjectFileFormat = !Stub.ObjectFileFormat.empty()
- ? Stub.ObjectFileFormat
- : TargetStub->ObjectFileFormat;
-
if (Stub.IfsVersion != TargetStub->IfsVersion) {
- if (Stub.IfsVersion.getMajor() != IFSVersionCurrent.getMajor()) {
+ if (Stub.IfsVersion.getMajor() != IfsVersionCurrent.getMajor()) {
WithColor::error()
<< "Interface Stub: IfsVersion Mismatch."
<< "\nFilenames: " << PreviousInputFilePath << " "
@@ -479,29 +296,20 @@ int main(int argc, char *argv[]) {
if (TargetStub->IfsVersion > Stub.IfsVersion)
Stub.IfsVersion = TargetStub->IfsVersion;
}
- if (Stub.ObjectFileFormat != TargetStub->ObjectFileFormat &&
- !TargetStub->ObjectFileFormat.empty()) {
- WithColor::error() << "Interface Stub: ObjectFileFormat Mismatch."
+ if (Stub.Target != TargetStub->Target && !TargetStub->Target.empty()) {
+ WithColor::error() << "Interface Stub: Target Mismatch."
<< "\nFilenames: " << PreviousInputFilePath << " "
- << InputFilePath << "\nObjectFileFormat Values: "
- << Stub.ObjectFileFormat << " "
- << TargetStub->ObjectFileFormat << "\n";
+ << InputFilePath;
+ // << "\nTriple Values: " << Stub.Triple << " "
+ // << TargetStub->Triple << "\n";
return -1;
}
- if (Stub.Triple != TargetStub->Triple && !TargetStub->Triple.empty()) {
- WithColor::error() << "Interface Stub: Triple Mismatch."
+ if (Stub.SoName != TargetStub->SoName) {
+ WithColor::error() << "Interface Stub: SoName Mismatch."
<< "\nFilenames: " << PreviousInputFilePath << " "
<< InputFilePath
- << "\nTriple Values: " << Stub.Triple << " "
- << TargetStub->Triple << "\n";
- return -1;
- }
- if (Stub.SOName != TargetStub->SOName) {
- WithColor::error() << "Interface Stub: SOName Mismatch."
- << "\nFilenames: " << PreviousInputFilePath << " "
- << InputFilePath
- << "\nSOName Values: " << Stub.SOName << " "
- << TargetStub->SOName << "\n";
+ << "\nSoName Values: " << Stub.SoName << " "
+ << TargetStub->SoName << "\n";
return -1;
}
if (Stub.NeededLibs != TargetStub->NeededLibs) {
@@ -549,16 +357,92 @@ int main(int argc, char *argv[]) {
PreviousInputFilePath = InputFilePath;
}
- if (Stub.IfsVersion != IFSVersionCurrent)
- if (Stub.IfsVersion.getMajor() != IFSVersionCurrent.getMajor()) {
+ if (Stub.IfsVersion != IfsVersionCurrent)
+ if (Stub.IfsVersion.getMajor() != IfsVersionCurrent.getMajor()) {
WithColor::error() << "Interface Stub: Bad IfsVersion: "
<< Stub.IfsVersion << ", llvm-ifs supported version: "
- << IFSVersionCurrent << ".\n";
+ << IfsVersionCurrent << ".\n";
return -1;
}
for (auto &Entry : SymbolMap)
Stub.Symbols.push_back(Entry.second);
- return writeIfso(Stub, (Action == "write-ifs"));
+ // Change SoName before emitting stubs.
+ if (SoName.getNumOccurrences() == 1)
+ Stub.SoName = SoName;
+ Optional<IFSArch> OverrideArch;
+ Optional<IFSEndiannessType> OverrideEndianness;
+ Optional<IFSBitWidthType> OverrideBitWidth;
+ Optional<std::string> OverrideTriple;
+ if (OptArch.getNumOccurrences() == 1)
+ OverrideArch = ELF::convertArchNameToEMachine(OptArch.getValue());
+ if (OptEndianness.getNumOccurrences() == 1)
+ OverrideEndianness = OptEndianness.getValue();
+ if (OptBitWidth.getNumOccurrences() == 1)
+ OverrideBitWidth = OptBitWidth.getValue();
+ if (OptTargetTriple.getNumOccurrences() == 1)
+ OverrideTriple = OptTargetTriple.getValue();
+ Error OverrideError = overrideIFSTarget(
+ Stub, OverrideArch, OverrideEndianness, OverrideBitWidth, OverrideTriple);
+ if (OverrideError)
+ fatalError(std::move(OverrideError));
+
+ switch (OutputFormat.getValue()) {
+ case FileFormat::TBD: {
+ std::error_code SysErr;
+ raw_fd_ostream Out(OutputFilePath, SysErr);
+ if (SysErr) {
+ WithColor::error() << "Couldn't open " << OutputFilePath
+ << " for writing.\n";
+ return -1;
+ }
+ if (!Stub.Target.Triple) {
+ WithColor::error()
+ << "Triple should be defined when output format is TBD";
+ return -1;
+ }
+ return writeTbdStub(llvm::Triple(Stub.Target.Triple.getValue()),
+ Stub.Symbols, "TBD", Out);
+ }
+ case FileFormat::IFS: {
+ Stub.IfsVersion = IfsVersionCurrent;
+ if (InputFormat.getValue() == FileFormat::ELF &&
+ OptTargetTripleHint.getNumOccurrences() == 1) {
+ std::error_code HintEC(1, std::generic_category());
+ IFSTarget HintTarget = parseTriple(OptTargetTripleHint);
+ if (Stub.Target.Arch.getValue() != HintTarget.Arch.getValue())
+ fatalError(make_error<StringError>(
+ "Triple hint does not match the actual architecture", HintEC));
+ if (Stub.Target.Endianness.getValue() !=
+ HintTarget.Endianness.getValue())
+ fatalError(make_error<StringError>(
+ "Triple hint does not match the actual endianness", HintEC));
+ if (Stub.Target.BitWidth.getValue() != HintTarget.BitWidth.getValue())
+ fatalError(make_error<StringError>(
+ "Triple hint does not match the actual bit width", HintEC));
+
+ stripIFSTarget(Stub, true, false, false, false);
+ Stub.Target.Triple = OptTargetTripleHint.getValue();
+ } else {
+ stripIFSTarget(Stub, StripIFSTarget, StripIFSArch,
+ StripIFSEndiannessWidth, StripIFSBitWidth);
+ }
+ Error IFSWriteError = writeIFS(OutputFilePath.getValue(), Stub);
+ if (IFSWriteError)
+ fatalError(std::move(IFSWriteError));
+ break;
+ }
+ case FileFormat::ELF: {
+ Error TargetError = validateIFSTarget(Stub, true);
+ if (TargetError)
+ fatalError(std::move(TargetError));
+ Error BinaryWriteError =
+ writeBinaryStub(OutputFilePath, Stub, WriteIfChanged);
+ if (BinaryWriteError)
+ fatalError(std::move(BinaryWriteError));
+ break;
+ }
+ }
+ return 0;
}
diff --git a/llvm/unittests/InterfaceStub/ELFYAMLTest.cpp b/llvm/unittests/InterfaceStub/ELFYAMLTest.cpp
index f3035fe61f956..f6418f8f2a251 100644
--- a/llvm/unittests/InterfaceStub/ELFYAMLTest.cpp
+++ b/llvm/unittests/InterfaceStub/ELFYAMLTest.cpp
@@ -17,7 +17,7 @@
using namespace llvm;
using namespace llvm::ELF;
-using namespace llvm::elfabi;
+using namespace llvm::ifs;
void compareByLine(StringRef LHS, StringRef RHS) {
StringRef Line1;
diff --git a/llvm/utils/gn/secondary/llvm/test/BUILD.gn b/llvm/utils/gn/secondary/llvm/test/BUILD.gn
index e87dc56627005..19fa5a07ea95c 100644
--- a/llvm/utils/gn/secondary/llvm/test/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/test/BUILD.gn
@@ -246,7 +246,6 @@ group("test") {
"//llvm/tools/llvm-dis",
"//llvm/tools/llvm-dwarfdump",
"//llvm/tools/llvm-dwp",
- "//llvm/tools/llvm-elfabi",
"//llvm/tools/llvm-exegesis",
"//llvm/tools/llvm-extract",
"//llvm/tools/llvm-gsymutil:llvm-gsymutil",
diff --git a/llvm/utils/gn/secondary/llvm/tools/llvm-elfabi/BUILD.gn b/llvm/utils/gn/secondary/llvm/tools/llvm-elfabi/BUILD.gn
deleted file mode 100644
index 0b3cb1ec41ba2..0000000000000
--- a/llvm/utils/gn/secondary/llvm/tools/llvm-elfabi/BUILD.gn
+++ /dev/null
@@ -1,12 +0,0 @@
-executable("llvm-elfabi") {
- deps = [
- "//llvm/lib/InterfaceStub",
- "//llvm/lib/Object",
- "//llvm/lib/Support",
- "//llvm/lib/TextAPI",
- ]
- sources = [
- "ErrorCollector.cpp",
- "llvm-elfabi.cpp",
- ]
-}
More information about the llvm-commits
mailing list