diff options
author | Haowei Wu <haowei@google.com> | 2021-03-31 16:48:56 -0700 |
---|---|---|
committer | Haowei Wu <haowei@google.com> | 2021-07-19 11:22:43 -0700 |
commit | 8b4acb067fd38ac33a63669ef46966dfee59257e (patch) | |
tree | ed1872874f34be4bac45fc55a4cc75ce53f86fbb /llvm/tools/llvm-ifs/llvm-ifs.cpp | |
parent | 6c0e6895d014096ad7375e95997575ad1e8da020 (diff) | |
download | llvm-8b4acb067fd38ac33a63669ef46966dfee59257e.zip llvm-8b4acb067fd38ac33a63669ef46966dfee59257e.tar.gz llvm-8b4acb067fd38ac33a63669ef46966dfee59257e.tar.bz2 |
[elfabi] Prepare elfabi/ifs merging.
This change implements unified text stub format and command line
interface proposed in the elfabi/ifs merge plan.
Differential Revision: https://reviews.llvm.org/D99399
Diffstat (limited to 'llvm/tools/llvm-ifs/llvm-ifs.cpp')
-rw-r--r-- | llvm/tools/llvm-ifs/llvm-ifs.cpp | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/llvm/tools/llvm-ifs/llvm-ifs.cpp b/llvm/tools/llvm-ifs/llvm-ifs.cpp index b6a1b4a..8ab5ef9 100644 --- a/llvm/tools/llvm-ifs/llvm-ifs.cpp +++ b/llvm/tools/llvm-ifs/llvm-ifs.cpp @@ -10,6 +10,8 @@ #include "llvm/ADT/StringSwitch.h" #include "llvm/ADT/Triple.h" #include "llvm/InterfaceStub/ELFObjHandler.h" +#include "llvm/InterfaceStub/ELFStub.h" +#include "llvm/InterfaceStub/TBEHandler.h" #include "llvm/ObjectYAML/yaml2obj.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" @@ -348,23 +350,10 @@ static int writeElfStub(const Triple &T, const std::vector<IFSSymbol> &Symbols, return convertYAML(YIn, Out, ErrHandler) ? 0 : 1; } -static elfabi::ELFTarget convertIFSStub(const IFSStub &IfsStub, - elfabi::ELFStub &ElfStub) { +static Error convertIFSStub(const IFSStub &IfsStub, elfabi::ELFStub &ElfStub) { ElfStub.TbeVersion = IfsStub.IfsVersion; ElfStub.SoName = IfsStub.SOName; - // TODO: Support more archs and targets. - Triple IFSTriple(IfsStub.Triple); - elfabi::ELFTarget Target = elfabi::ELFTarget::ELF64LE; - switch (IFSTriple.getArch()) { - case Triple::ArchType::aarch64: - ElfStub.Arch = (elfabi::ELFArch)ELF::EM_AARCH64; - break; - case Triple::ArchType::x86_64: - ElfStub.Arch = (elfabi::ELFArch)ELF::EM_X86_64; - break; - default: - ElfStub.Arch = (elfabi::ELFArch)ELF::EM_NONE; - } + ElfStub.Target.Triple = IfsStub.Triple; ElfStub.NeededLibs = IfsStub.NeededLibs; for (const IFSSymbol &IfsSymbol : IfsStub.Symbols) { elfabi::ELFSymbol ElfSymbol(IfsSymbol.Name); @@ -387,9 +376,9 @@ static elfabi::ELFTarget convertIFSStub(const IFSStub &IfsStub, ElfSymbol.Undefined = false; ElfSymbol.Weak = IfsSymbol.Weak; ElfSymbol.Warning = IfsSymbol.Warning; - ElfStub.Symbols.insert(ElfSymbol); + ElfStub.Symbols.push_back(ElfSymbol); } - return Target; + return llvm::elfabi::validateTBETarget(ElfStub, true); } static int writeIfso(const IFSStub &Stub, bool IsWriteIfs) { @@ -400,9 +389,11 @@ static int writeIfso(const IFSStub &Stub, bool IsWriteIfs) { // format is ELF. if (UseInterfaceStub && (!IsWriteIfs) && ObjectFileFormat != "TBD") { elfabi::ELFStub ElfStub; - elfabi::ELFTarget Target = convertIFSStub(Stub, ElfStub); - Error BinaryWriteError = - elfabi::writeBinaryStub(OutputFilename, ElfStub, Target); + Error ConvertError = convertIFSStub(Stub, ElfStub); + if (ConvertError) { + return -1; + } + Error BinaryWriteError = elfabi::writeBinaryStub(OutputFilename, ElfStub); if (BinaryWriteError) { return -1; } |