25#include "llvm/ADT/SmallVector.h"
26#include "llvm/ADT/StringMap.h"
27#include "llvm/Object/Binary.h"
29#include <unordered_set>
32namespace saq::bartleby {
42 llvm::Triple::ArchType
Arch;
59 [[nodiscard]] uint64_t
pack() const noexcept;
61 bool operator==(const
ObjectFormat &Other) const noexcept;
70 bool matches(const llvm::Triple &Triple) const noexcept;
73 friend llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
78 inline size_t operator()(
const ObjectFormat &ObjFormat)
const noexcept {
79 return static_cast<size_t>(ObjFormat.
pack());
104 [[nodiscard]] llvm::
Error
105 addBinary(llvm::
object::OwningBinary<llvm::
object::Binary> Binary) noexcept;
125 [[nodiscard]]
static llvm::Error
133 [[nodiscard]]
static llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>>
140 llvm::object::ObjectFile *Handle;
149 std::unique_ptr<llvm::object::Binary> Owner;
152 llvm::SmallString<32> Name;
161 using ObjectFormatSet = std::unordered_set<ObjectFormat, ObjectFormat::Hash>;
168 using ObjectFormatVariant =
169 std::variant<std::monostate, ObjectFormat, ObjectFormatSet>;
174 [[nodiscard]]
bool isMachOUniversalBinary() const noexcept;
186 objectFormatMatches(const ObjectFormat &ObjFmt) const noexcept;
193 [[nodiscard]] llvm::Error addMachOUniversalBinary(
194 llvm::
object::OwningBinary<llvm::
object::Binary> OwningBinary) noexcept;
200 llvm::SmallVector<ObjectFile, 128> Objects;
203 llvm::SmallVector<llvm::
object::OwningBinary<llvm::
object::Binary>, 128>
210 ObjectFormatVariant ObjFormat;
Bartleby library specification.
Bartleby handle.
Definition: Bartleby.h:85
const SymbolMap & getSymbols() const noexcept
Gets a const reference to the map of symbols.
Definition: Bartleby.h:110
llvm::Error addBinary(llvm::object::OwningBinary< llvm::object::Binary > Binary) noexcept
Adds a new binary to Bartleby.
Definition: Bartleby.cpp:152
size_t prefixGlobalAndDefinedSymbols(llvm::StringRef Prefix) noexcept
Applies a prefix to all global and defined symbols.
Definition: Bartleby.cpp:218
Bartleby() noexcept
Constructs an empty Bartleby handle.
static llvm::Error buildFinalArchive(Bartleby &&B, llvm::StringRef OutFilepath) noexcept
Builds the final archive and writes its content to a file.
Definition: ArchiveWriter.cpp:327
llvm::StringMap< Symbol > SymbolMap
Symbol map type.
Definition: Bartleby.h:88
Custom error info for Bartleby.
Definition: Error.h:34