4 // including system elf header, which allows for interpretation of the return values of the methods
8 #include <boost/filesystem.hpp>
12 namespace linuxdeploy {
15 // thrown by constructor if file is not an ELF file
16 class ElfFileParseError : public std::runtime_error {
18 explicit ElfFileParseError(const std::string& msg) : std::runtime_error(msg) {}
21 // thrown by traceDynamicDependencies() if a dependency is missing
22 class DependencyNotFoundError : public std::runtime_error {
24 explicit DependencyNotFoundError(const std::string& msg) : std::runtime_error(msg) {}
33 explicit ElfFile(const boost::filesystem::path& path);
37 // return system ELF OS ABI
38 static uint8_t getSystemElfABI();
40 // return system ELF class (32-bit or 64-bit)
41 static uint8_t getSystemElfClass();
43 // return system (ELF) endianness
44 static uint8_t getSystemElfEndianness();
47 // recursively trace dynamic library dependencies of a given ELF file
48 // this works for both libraries and executables
49 // the resulting vector consists of absolute paths to the libraries determined by the same methods a system's
51 std::vector<boost::filesystem::path> traceDynamicDependencies();
53 // fetch rpath stored in binary
54 // it appears that according to the ELF standard, the rpath is ignored in libraries, therefore if the path
55 // points to an executable, an empty string is returned
56 std::string getRPath();
58 // set rpath in ELF file
59 // returns true on success, false otherwise
60 bool setRPath(const std::string& value);
63 uint8_t getElfClass();
68 // check if this file is a debug symbols file
69 bool isDebugSymbolsFile();
71 // check whether the file contains a dynsym section
72 bool isDynamicallyLinked();