LLVM-IFS(1)

🌸 LLVM-IFS(1) β€” the llvm-ifs page, bestie edition πŸ’…

okay so you opened the llvm-ifs man page from the LLVM manual and honestly? it's giving "small tool, huge glow-up energy." let's get into it 🫢


✨ NAME ✨

llvm-ifs β€” shared object stubbing tool

that's it. that's the whole vibe. it stubs shared objects. iconic.


πŸ¦‹ SYNOPSIS πŸ¦‹

llvm-ifs [options] inputs

πŸ’– DESCRIPTION πŸ’–

so llvm-ifs is the tool that, like, jointly produces two things for you, no cap:

  • human readable text-based stubs (the .ifs files) for shared objects, and
  • linkable shared object stubs (the .so files)

...and it can make them from either ELF shared objects or text-based stubs. pick your fighter πŸ’…

the text-based stubs are lowkey the main character for monitoring ABI changes of the shared object. and the linkable shared object stubs? those are the ones that save you from unnecessary relinks when the ABI of shared libraries doesn't change. literally so considerate of them 😭


πŸŽ€ IFS FORMATS πŸŽ€

here's an example of the text representation (IFS) of a shared object produced by llvm-ifs β€” study it, it's cute:

--- !ifs-v1
IFSVersion: 3.0
SoName: libtest.so /* Optional */
Target: x86_64-unknown-linux-gnu   /* Optional, format 1, same format as llvm target triple */
Target: { Arch: x86_64, Endianness: little, Bitwidth: 64 } /* Optional, format 2 */
NeededLibs:
  - libc.so.6
Symbols:
  - { Name: sym0, Type: Notype }
  - { Name: sym1, Type: Object, Size: 0 }
  - { Name: sym2, Type: Func, Weak: false }
  - { Name: sym3, Type: TLS }
  - { Name: sym4, Type: Unknown, Warning: foo }
...

now let's break down every field, because details matter and we're not skipping any πŸ‘‘

  • IFSVersion: the version of the IFS file, for reader compatibility.
  • SoName (optional): the name of the shared object file that is being stubbed.
  • Target (optional): the architecture, endianness and bitwise information of this shared object. it can be either in explicit format or in implicit LLVM triple format. it can be optional, and it can be overridden from command line options.
  • NeededLibs: the list of the external shared objects that this library depends on.
  • Symbols: a collection of all data needed to link objects for each symbol, sorted by name in ascending order. inside each one:
    • Name: symbol name.
    • Type: whether the symbol is an object, function, no-type, thread local storage, or unknown. symbol types not explicitly supported are mapped as unknown to improve signal-to-noise ratio. (that part is a whole mood, ngl)
    • Size: the size of the symbol in question β€” doesn't apply to functions, and is optional for NoType symbols.
    • Undefined: whether or not the symbol is defined in this shared object file.
    • Weak: whether or not the symbol should be treated as weak.
    • Warning (optional): warning text to output when this symbol is linked against.

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. and because the ordering of symbols is sorted, these files can be easily compared using diff tools. periodt. so if the content of the file changes, that indicates a potentially ABI breaking change β€” like, pay attention 🚨


🧚 ELF STUB FORMAT 🧚

a minimum ELF file that can be used by linker should have the following sections properly populated:

  • ELF header.
  • Section headers.
  • Dynamic symbol table (.dynsym section).
  • Dynamic string table (.dynstr section).
  • Dynamic table (.dynamic section).
    • DT_SYMTAB entry.
    • DT_STRTAB entry.
    • DT_STRSZ entry.
    • DT_NEEDED entries. (optional)
    • DT_SONAME entry. (optional)
  • Section header string table (.shstrtab section)
heads up bestie 🫢 β€” this ELF file may have compatibility issues with ELF analysis tools that rely on the program headers. linkers like LLD work fine with such a minimum ELF file without errors, though. so like, it depends on who's looking at it πŸ’€

πŸ”₯ OPTIONS πŸ”₯

every single one, no skipping. let's go πŸƒβ€β™€οΈπŸ’¨

  • --input-format=[IFS|ELF|OtherObjectFileFormats] β€” specify input file format. currently, only text IFS files and ELF shared object files are supported. this flag is optional as the input format can be inferred.
  • --output-elf=<output-filename> β€” specify the output file for ELF shared object stub.
  • --output-ifs=<output-filename> β€” specify the output file for text IFS.
  • --output-tbd=<output-filename> β€” specify the output file for Apple TAPI tbd.
  • --arch=[x86_64|AArch64|...] β€” this flag is optional and it should only be used when reading an IFS file which does not define the Arch (architecture). this flag defines the architecture of the output file, and can be any string supported by ELF e_machine field. if the value is conflicting with the IFS file, an error will be reported and the program will stop. πŸ›‘
  • --endianness=[little|big] β€” this flag is optional and it should only be used when reading an IFS file which does not define the Endianness. this flag defines the endianness of the output file. if the value is conflicting with the IFS file, an error will be reported and the program will stop. πŸ›‘
  • --bitwidth=[32|64] β€” this flag is optional and it should only be used when reading an IFS file which does not define the BitWidth. this flag defines the bit width of the output file. if the value is conflicting with the input IFS file, an error will be reported and the program will stop. πŸ›‘
  • --target=<target triple> β€” this flag is optional and should only be used when reading an IFS file which does not define any target information. this flag defines architecture, endianness and bit width of the output file using llvm target triple. this flag cannot be used simultaneously with other target related flags. πŸ™…β€β™€οΈ
  • --hint-ifs-target=<target triple> β€” this flag is optional and should only be used when reading an ELF shared object and generating an IFS file. by default, llvm-ifs will use the 'Arch, Endianness and BitWidth' fields to reflect the target information from the input object file. using this flag will tell llvm-ifs the expected target 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. πŸ›‘
  • --hint-ifs-target β€” this flag is optional and should only be used when outputting an IFS file. this flag strips the Arch field from the IFS file so it can be overridden later.
  • --strip-ifs-endianness β€” this flag is optional and should only be used when outputting an IFS file. this flag strips the Endianness field from the IFS file so it can be overridden later.
  • --strip-ifs-bitwidth β€” this flag is optional and should only be used when outputting an IFS file. this flag strips the BitWidth field from the IFS file so it can be overridden later.
  • --strip-ifs-target β€” this flag is optional and should only be used when outputting an IFS file. this flag strips the Target field from the IFS file so it can be overridden later.
  • --write-if-changed β€” when this flag is set, llvm-ifs will only write the output file if it does not already exist or the content will be different from the existing file. (a respectful queen who doesn't touch things unnecessarily πŸ‘‘)
  • --strip-size β€” when this flag is set, llvm-ifs will remove the size field from the output ifs file. this is useful for shared objects that only intend to be linked against position independent code which doesn't need copy relocations, or where the size of an object is not a useful part of the abi to track.

⭐ EXIT STATUS ⭐

if llvm-ifs succeeds, it will exit with 0. otherwise, if an error occurs, it will exit with a non-zero value. simple as that bestie ✨


πŸ’œ AUTHOR πŸ’œ

maintained by the LLVM Team (https://llvm.org/). shoutout 🫢


2003-2023, LLVM Project


and that's the whole page, you ate that πŸ“πŸ’… β€” this was LLVM-IFS(1) from the LLVM manual, version 15, dated 2023-07-14. go stub something iconic βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from