Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion llvm/docs/CommandGuide/llvm-ifs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ by the :program:`llvm-ifs`:
- { Name: sym2, Type: Func, Weak: false }
- { Name: sym3, Type: TLS }
- { Name: sym4, Type: Unknown, Warning: foo }
- { Name: sym5, Version: VER_1, Type: Func }
VersionDefinitions: /* Optional */
- { Name: libtest.so }
- { Name: VER_1 }
VersionRequirements: /* Optional */
- { File: libc.so.6, Names: [ GLIBC_2.14, GLIBC_2.4, GLIBC_2.2.5, GLIBC_2.3.4 ] }
...

* ``IFSVersion``: Version of the IFS file for reader compatibility.
Expand Down Expand Up @@ -67,6 +73,10 @@ by the :program:`llvm-ifs`:

+ ``Warning`` (optional): Warning text to output when this symbol is linked against.

* ``VersionDefinitions`` (optional): A collection of symbol versions defined in this shared object file.

* ``VersionRequirements`` (optional): A collection of symbol versions defined in external shared objects that this library depends on.

This YAML based text format contains everything that is needed to generate a
linkable ELF shared object as well as an Apple TAPI format file. The ordering
of symbols is sorted, so these files can be easily compared using diff tools.
Expand All @@ -81,12 +91,20 @@ A minimum ELF file that can be used by linker should have following sections pro

* ELF header.

* Program headers. (optional)

* Section headers.

* Dynamic symbol table (``.dynsym`` section).

* Dynamic string table (``.dynstr`` section).

* Version symbol table (``.gnu.version`` section). (optional)

* Version definition table (``.gnu.version_d`` section). (optional)

* Version requirement table (``.gnu.version_r`` section). (optional)

* Dynamic table (``.dynamic`` section).

+ ``DT_SYMTAB`` entry.
Expand All @@ -99,6 +117,12 @@ A minimum ELF file that can be used by linker should have following sections pro

+ ``DT_SONAME`` entry. (optional)

+ ``DT_VERSYM`` entry. (optional)

+ ``DT_VERDEF`` entry. (optional)

+ ``DT_VERNEED`` entry. (optional)

* Section header string table (``.shstrtab`` section)

This ELF file may have compatibility issues with ELF analysis tools that rely on the program headers.
Expand Down Expand Up @@ -163,7 +187,7 @@ OPTIONS
triple in the output IFS file. If the value matches the target information
from the object file, this value will be used in the 'Target:' filed in the
generated IFS. If it conflicts with the input object file, an error will be
reported and the program will stop.
reported and the program will stop.

.. option:: --hint-ifs-target

Expand Down
36 changes: 35 additions & 1 deletion llvm/include/llvm/InterfaceStub/IFSStub.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ enum class IFSBitWidthType {

struct IFSSymbol {
IFSSymbol() = default;
explicit IFSSymbol(std::string SymbolName) : Name(std::move(SymbolName)) {}
explicit IFSSymbol(std::string SymbolName, std::string SymVer)
: Name(std::move(SymbolName)), Version(std::move(SymVer)) {}
std::string Name;
std::string Version;
std::optional<uint64_t> Size;
IFSSymbolType Type = IFSSymbolType::NoType;
bool Undefined = false;
Expand All @@ -62,6 +64,36 @@ struct IFSSymbol {
bool operator<(const IFSSymbol &RHS) const { return Name < RHS.Name; }
};

struct IFSVerDef {
std::string Name;
std::vector<std::string> Parents;
};

inline bool operator==(const IFSVerDef &Lhs, const IFSVerDef &Rhs) {
if (Lhs.Name != Rhs.Name || Lhs.Parents != Rhs.Parents)
return false;
return true;
}

inline bool operator!=(const IFSVerDef &Lhs, const IFSVerDef &Rhs) {
return !(Lhs == Rhs);
}

struct IFSVerNeed {
std::string File;
std::vector<std::string> Names;
};

inline bool operator==(const IFSVerNeed &Lhs, const IFSVerNeed &Rhs) {
if (Lhs.File != Rhs.File || Lhs.Names != Rhs.Names)
return false;
return true;
}

inline bool operator!=(const IFSVerNeed &Lhs, const IFSVerNeed &Rhs) {
return !(Lhs == Rhs);
}

struct IFSTarget {
std::optional<std::string> Triple;
std::optional<std::string> ObjectFormat;
Expand Down Expand Up @@ -94,6 +126,8 @@ struct IFSStub {
IFSTarget Target;
std::vector<std::string> NeededLibs;
std::vector<IFSSymbol> Symbols;
std::vector<IFSVerDef> VersionDefinitions;
std::vector<IFSVerNeed> VersionRequirements;

IFSStub() = default;
LLVM_ABI IFSStub(const IFSStub &Stub);
Expand Down
Loading